MDC Support

2024-12-09 17:47:57 总结 418 words 3 min read

本站使用自定义的 Nuxt MDC 组件模块 @sunshj/mdc,支持常见 Markdown 语法,并扩展了一些自定义语法。

Heading

Preview
Code

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6
          # Heading 1

## Heading 2

### Heading 3

#### Heading 4

##### Heading 5

###### Heading 6

        
Preview
Code
          [Internal Link](/articles)

[External Link](https://github.com/sunshj/mdc)

[`InlineCode Link`](https://github.com/sunshj/mdc)

        

Blockquote

Preview
Code

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

          > Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

        

Code Block

Preview
Code
ts
          export default () => {
  console.log('Code block')
}

        
With Title
          export default () => {
  console.log('Code block')
}

        
Highlight Lines
          export default () => {
  console.log('Code block');
};

        
Diff Lines
          export default () => {
  console.log('Code blcok')   console.log('Code block') }

        
          ```ts
export default () => {
  console.log('Code block')
}
```

```ts [With Title]
export default () => {
  console.log('Code block')
}
```

```ts{2} [Highlight Lines]
export default () => {
  console.log('Code block');
};
```

```ts [Diff Lines]
export default () => {
  console.log('Code blcok') // [!code --]
  console.log('Code block') // [!code ++]
}
```

        

Code Group

Preview
Code
npm
pnpm
yarn
bun
          npm run dev

        
          pnpm dev

        
          yarn dev

        
          bun run dev

        
          ::code-group
  ```bash [npm]
  npm run dev
  ```

  ```bash [pnpm]
  pnpm dev
  ```

  ```bash [yarn]
  yarn dev
  ```

  ```bash [bun]
  bun run dev
  ```
::

        

Inline Code

Preview
Code

code inline

const codeInline: string = 'highlighted code inline'

          `code inline`

`const codeInline: string = 'highlighted code inline'`{lang="ts"}

        

Horizontal Rule

Preview
Code

Before


After

          Before

---

After

        

Image

Preview
Code

Photo by Drew BeamerGet image from unsplash.com

npm versionnpm version NuxtNuxt

          ![Photo by Drew Beamer](https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80 "Get image from unsplash.com")

[![npm version](https://img.shields.io/npm/v/@sunshj/mdc/latest.svg?style=flat&colorA=020420&colorB=00DC82)](https://npmjs.com/package/@sunshj/mdc) [![Nuxt](https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js)](https://nuxt.com)

        

Unordered List

Preview
Code
  • First item
  • Second item
  • Third item
    • Indented item
    • Indented item
  • Fourth item
          - First item
- Second item
- Third item
    - Indented item
    - Indented item
- Fourth item

        

Ordered List

Preview
Code
  1. First item
  2. Second item
  3. Third item
    1. Indented item
    2. Indented item
  4. Fourth item
          1. First item
2. Second item
3. Third item
    1. Indented item
    2. Indented item
4. Fourth item

        

Paragraph

Preview
Code

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

        

Strong

Preview
Code

Just a strong paragraph.

          **Just a strong paragraph.**

        

Italic

Preview
Code

Just an italic paragraph.

          *Just an italic paragraph.*

        

Table

Preview
Code
KeyTypeDescription
1WonderfulTable with some long code snippet example
2WonderfulData
3WonderfulWebsite
          | Key | Type      | Description                                 |
| --- | --------- | ------------------------------------------- |
| 1   | Wonderful | Table with `some long code snippet example` |
| 2   | Wonderful | Data                                        |
| 3   | Wonderful | Website                                     |

        

Strikethrough

Preview
Code

Just a strikethrough paragraph.

          ~~Just a strikethrough paragraph.~~

        

Task List

Preview
Code
  • Foo
  • Bar
  • Baz
          - [x] Foo
- [ ] Bar
- [ ] Baz

        

Emoji

Preview
Code

😄 ❤️ 🚀

          :smile:
:heart:
:rocket:

        

Shortcut

Preview
Code

Ctrl K
xs sm md

          :shortcut{value="meta"} :shortcut{value="K"} :br
:shortcut{value="xs" size="xs"} :shortcut{value="sm"} :shortcut{value="md" size="md"}

        

MDC Support
http://localhost/articles/mdc-support
作者
sunshj
发布于
2024-12-09 17:47
许可
博客迁移至 Nuxt
之前的博客使用的是 Hexo + Keep主题,最近开始学习 Nuxt,于是就使用 Nuxt 技术栈重写了博客。
© 2021-2024 sunshj's Blog