mirror of
https://github.com/edems-dev/md-discord-syntax.git
synced 2026-07-22 08:37:37 +00:00
ref: remove example
This commit is contained in:
parent
57723ed3bb
commit
c97f6d548f
11 changed files with 73 additions and 3021 deletions
33
README.md
33
README.md
|
|
@ -13,7 +13,6 @@ Monorepo bringing Discord-style Markdown formatting (`||spoiler||` and `-# subte
|
|||
| [`packages/core`](packages/core) | `@md-discord-syntax/core` | Platform-independent spoiler & subtext rules parser (zero dependencies). |
|
||||
| [`packages/remark`](packages/remark) | `remark-md-discord-syntax` | Remark plugin transforming `||spoiler||` and `-# subtext` for MDX. |
|
||||
| [`packages/obsidian`](packages/obsidian) | — | Obsidian Community Plugin adapter (`Discord Syntax`, plugin ID `md-discord-syntax`). |
|
||||
| [`examples/next-mdx`](examples/next-mdx) | — | Minimal Next.js MDX usage example consuming `remark-md-discord-syntax`. |
|
||||
| [`packages/quartz`](packages/quartz) | `@md-discord-syntax/quartz` | Reserved for future Quartz static site generator integration. |
|
||||
|
||||
---
|
||||
|
|
@ -37,23 +36,39 @@ const spoilers = findSpoilerRanges(text)
|
|||
// [{ from: 6, to: 16, contentFrom: 8, contentTo: 14 }]
|
||||
```
|
||||
|
||||
### 2. Remark Plugin (`remark-md-discord-syntax`)
|
||||
### 2. Next.js + `@next/mdx` (`remark-md-discord-syntax`)
|
||||
|
||||
In Next.js MDX config (`next.config.mjs`):
|
||||
Install the plugin:
|
||||
|
||||
```bash
|
||||
npm install remark-md-discord-syntax
|
||||
```
|
||||
|
||||
Configure `next.config.mjs`:
|
||||
|
||||
```js
|
||||
import createMDX from '@next/mdx'
|
||||
import { remarkMdDiscordSyntax } from 'remark-md-discord-syntax'
|
||||
|
||||
const withMDX = createMDX({
|
||||
options: {
|
||||
remarkPlugins: [remarkMdDiscordSyntax]
|
||||
}
|
||||
remarkPlugins: ['remark-md-discord-syntax'],
|
||||
},
|
||||
})
|
||||
|
||||
export default withMDX({
|
||||
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx']
|
||||
})
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
|
||||
}
|
||||
|
||||
export default withMDX(nextConfig)
|
||||
```
|
||||
|
||||
MDX syntax example:
|
||||
|
||||
```mdx
|
||||
This is a ||spoiler|| block.
|
||||
|
||||
-# This is subtext
|
||||
```
|
||||
|
||||
### 3. Obsidian Plugin (`packages/obsidian`)
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
Here is a normal paragraph with a ||secret spoiler|| in MDX.
|
||||
|
||||
-# This physical line is rendered as subtext using Discord syntax.
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
import React from 'react'
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
import React from 'react'
|
||||
import Content from './example.mdx'
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<main style={{ padding: '2rem', fontFamily: 'sans-serif' }}>
|
||||
<h1>Next.js MDX Discord Syntax Example</h1>
|
||||
<Content />
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
import type { MDXComponents } from 'mdx/types'
|
||||
import React from 'react'
|
||||
|
||||
function Spoiler({ children }: { children?: React.ReactNode }) {
|
||||
return (
|
||||
<span
|
||||
className="discord-spoiler"
|
||||
style={{
|
||||
backgroundColor: '#202225',
|
||||
color: '#202225',
|
||||
borderRadius: '3px',
|
||||
padding: '0 2px',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export function useMDXComponents(components: MDXComponents): MDXComponents {
|
||||
return {
|
||||
Spoiler,
|
||||
span: (props: React.HTMLAttributes<HTMLSpanElement> & { 'data-subtext'?: string }) => {
|
||||
if (props['data-subtext'] === 'true') {
|
||||
return <span style={{ fontSize: '0.85em', color: '#888' }} {...props} />
|
||||
}
|
||||
return <span {...props} />
|
||||
},
|
||||
...components,
|
||||
}
|
||||
}
|
||||
6
examples/next-mdx/next-env.d.ts
vendored
6
examples/next-mdx/next-env.d.ts
vendored
|
|
@ -1,6 +0,0 @@
|
|||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
import "./.next/types/routes.d.ts";
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import createMDX from '@next/mdx'
|
||||
import remarkMdDiscordSyntax from 'remark-md-discord-syntax'
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
|
||||
}
|
||||
|
||||
const withMDX = createMDX({
|
||||
options: {
|
||||
remarkPlugins: [remarkMdDiscordSyntax],
|
||||
rehypePlugins: [],
|
||||
},
|
||||
})
|
||||
|
||||
export default withMDX(nextConfig)
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"name": "example-next-mdx",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "^14.2.0 || ^15.0.0 || ^16.0.0",
|
||||
"react": "^18.0.0 || ^19.0.0",
|
||||
"react-dom": "^18.0.0 || ^19.0.0",
|
||||
"@next/mdx": "^14.2.0 || ^15.0.0 || ^16.0.0",
|
||||
"@mdx-js/loader": "^3.0.0",
|
||||
"@mdx-js/react": "^3.0.0",
|
||||
"remark-md-discord-syntax": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
"@types/react": "^18.0.0 || ^19.0.0",
|
||||
"@types/react-dom": "^18.0.0 || ^19.0.0",
|
||||
"@types/mdx": "^2.0.0",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"**/*.mdx",
|
||||
".next/types/**/*.ts",
|
||||
".next/dev/types/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
2918
package-lock.json
generated
2918
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,8 +4,7 @@
|
|||
"private": true,
|
||||
"description": "Monorepo for Discord syntax extensions (core, remark, obsidian)",
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
"examples/*"
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"prebuild": "npm run build -w @md-discord-syntax/core",
|
||||
|
|
|
|||
Loading…
Reference in a new issue