diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index 08a5bf77..47cf9410 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -36,6 +36,7 @@ function getGuideSidebar() { { text: 'Getting Started', link: '/guide/getting-started' }, { text: 'Configuration', link: '/guide/configuration' }, { text: 'Customization', link: '/guide/customization' }, + { text: 'Markdown Extensions', link: '/guide/markdown' }, { text: 'Deploying', link: '/guide/deploy' } ] } diff --git a/docs/guide/markdown.md b/docs/guide/markdown.md new file mode 100644 index 00000000..482f5fd1 --- /dev/null +++ b/docs/guide/markdown.md @@ -0,0 +1,456 @@ +# Markdown Extensions + +## Header Anchors + +Headers automatically get anchor links applied. Rendering of anchors can be configured using the `markdown.anchor` option. + + + +## Links + +### Internal Links + +Internal links are converted to router link for SPA navigation. Also, every `README.md` or `index.md` contained in each sub-directory will automatically be converted to `index.html`, with corresponding URL `/`. + +For example, given the following directory structure: + +``` +. +├─ README.md +├─ foo +│ ├─ README.md +│ ├─ one.md +│ └─ two.md +└─ bar + ├─ README.md + ├─ three.md + └─ four.md +``` + +And providing you are in `foo/one.md`: + +```md +[Home](/) +[foo](/foo/) +[foo heading](./#heading) +[bar - three](../bar/three.md) +[bar - four](../bar/four.html) +``` + +### Redirection for URLs + +VitePress supports redirecting to clean links. If a link `/foo` is not found, VitePress will look for a existing `/foo/` or `/foo.html`. Conversely, when one of `/foo/` or `/foo.html` is not found, VitePress will try the other. With this feature, we can customize your website’s URLs with the official plugin [vuepress-plugin-clean-urls](https://vuepress.github.io/plugins/clean-urls/). + +::: tip +Regardless of whether the permalink and clean-urls plugins are used, your relative path should be defined by the current file structure. In the above example, even though you set the path of `/foo/one.md` to `/foo/one/`, you should still access `/foo/two.md` via `./two.md`. +::: + +### Page Suffix + +Pages and internal links get generated with the `.html` suffix by default. + + + +### External Links + +Outbound links automatically get `target="_blank" rel="noopener noreferrer"`: + +- [vuejs.org](https://vuejs.org) +- [VitePress on GitHub](https://github.com/vuejs/vitepress) + +You can customize the attributes added to external links by setting [config.markdown.externalLinks](../config/README.md#markdown-externallinks). + +## Frontmatter + +[YAML frontmatter](https://jekyllrb.com/docs/frontmatter/) is supported out of the box: + +```yaml +--- +title: Blogging Like a Hacker +lang: en-US +--- + +``` + +This data will be available to the rest of the page, along with all custom and theming components. + + + +## GitHub-Style Tables + +**Input** + +``` +| Tables | Are | Cool | +| ------------- |:-------------:| -----:| +| col 3 is | right-aligned | $1600 | +| col 2 is | centered | $12 | +| zebra stripes | are neat | $1 | +``` + +**Output** + +| Tables | Are | Cool | +| ------------- | :-----------: | -----: | +| col 3 is | right-aligned | \$1600 | +| col 2 is | centered | \$12 | +| zebra stripes | are neat | \$1 | + +## Emoji :tada: + +**Input** + +``` +:tada: :100: +``` + +**Output** + +:tada: :100: + +A [list of all emojis](https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/data/full.json) is available. + +## Table of Contents + +**Input** + +``` +[[toc]] +``` + +**Output** + + + +[[toc]] + + + + + +Rendering of the TOC can be configured using the `markdown.toc` option. + +## Custom Containers + +Custom containers can be defined by their types, titles, and contents. + +### Default Title + +**Input** + +```md +::: tip +This is a tip +::: + +::: warning +This is a warning +::: + +::: danger +This is a dangerous warning +::: + +::: details +This is a details block, which does not work in IE / Edge +::: +``` + +**Output** + +::: tip +This is a tip +::: + +::: warning +This is a warning +::: + +::: danger +This is a dangerous warning +::: + + + +### Custom Title + +**Input** + +```md +::: danger STOP +Danger zone, do not proceed +::: +``` + + + +**Output** + +::: danger STOP +Danger zone, do not proceed +::: + + + +## Syntax Highlighting in Code Blocks + +VitePress uses [Prism](https://prismjs.com/) to highlight language syntax in Markdown code blocks, using coloured text. Prism supports a wide variety of programming languages. All you need to do is append a valid language alias to the beginning backticks for the code block: + +**Input** + +```` +``` js +export default { + name: 'MyComponent', + // ... +} +``` +```` + +**Output** + +```js +export default { + name: 'MyComponent' + // ... +} +``` + +**Input** + +```` +``` html +