docusaurus/packages/create-docusaurus/templates/shared/docs/tutorial-basics/markdown-features.mdx

151 lines
3.0 KiB
Plaintext
Raw Permalink Normal View History

---
feat(v2): auto-generated sidebars, frontmatter-less sites (#4582) * POC of autogenerated sidebars * use combine-promises utility lib * autogenerated sidebar poc working * Revert "autogenerated sidebar poc working" This reverts commit c81da980 * POC of auto-generated sidebars for community docs * update tests * add initial test suite for autogenerated sidebars + fix some edge cases * Improve autogen sidebars: strip more number prefixes in folder breadcrumb + slugs * fix typo! * Add tests for partially generated sidebars + fix edge cases + extract sidebar generation code * Ability to read category metadatas file from a file in the category * fix tests * change position of API * ability to extract number prefix * stable system to enable position frontmatter * fix tests for autogen sidebar position * renamings * restore community sidebars * rename frontmatter position -> sidebar_position * make sidebarItemsGenerator fn configurable * minor changes * rename dirPath => dirName * Make the init template use autogenerated sidebars * fix options * fix docusaurus site: remove test docs * add _category_ file to docs pathsToWatch * add _category_ file to docs pathsToWatch * tutorial: use sidebar_position instead of file number prefixes * Adapt Docusaurus tutorial for autogenerated sidebars * remove slug: / * polish the homepage template * rename _category_ sidebar_position to just "position" * test for custom sidebarItemsGenerator fn * fix category metadata + add link to report tutorial issues * fix absolute path breaking tests * fix absolute path breaking tests * Add test for floating number sidebar_position * add sidebarItemsGenerator unit tests * add processSidebars unit tests * Fix init template broken links * windows test * increase code translations test timeout * cleanup mockCategoryMetadataFiles after windows test fixed * update init template positions * fix windows tests * fix comment * Add autogenerated sidebar items documentation + rewrite the full sidebars page doc * add useful comment * fix code block title
2021-04-15 10:20:11 -04:00
sidebar_position: 4
---
feat(v2): auto-generated sidebars, frontmatter-less sites (#4582) * POC of autogenerated sidebars * use combine-promises utility lib * autogenerated sidebar poc working * Revert "autogenerated sidebar poc working" This reverts commit c81da980 * POC of auto-generated sidebars for community docs * update tests * add initial test suite for autogenerated sidebars + fix some edge cases * Improve autogen sidebars: strip more number prefixes in folder breadcrumb + slugs * fix typo! * Add tests for partially generated sidebars + fix edge cases + extract sidebar generation code * Ability to read category metadatas file from a file in the category * fix tests * change position of API * ability to extract number prefix * stable system to enable position frontmatter * fix tests for autogen sidebar position * renamings * restore community sidebars * rename frontmatter position -> sidebar_position * make sidebarItemsGenerator fn configurable * minor changes * rename dirPath => dirName * Make the init template use autogenerated sidebars * fix options * fix docusaurus site: remove test docs * add _category_ file to docs pathsToWatch * add _category_ file to docs pathsToWatch * tutorial: use sidebar_position instead of file number prefixes * Adapt Docusaurus tutorial for autogenerated sidebars * remove slug: / * polish the homepage template * rename _category_ sidebar_position to just "position" * test for custom sidebarItemsGenerator fn * fix category metadata + add link to report tutorial issues * fix absolute path breaking tests * fix absolute path breaking tests * Add test for floating number sidebar_position * add sidebarItemsGenerator unit tests * add processSidebars unit tests * Fix init template broken links * windows test * increase code translations test timeout * cleanup mockCategoryMetadataFiles after windows test fixed * update init template positions * fix windows tests * fix comment * Add autogenerated sidebar items documentation + rewrite the full sidebars page doc * add useful comment * fix code block title
2021-04-15 10:20:11 -04:00
# Markdown Features
Docusaurus supports **[Markdown](https://daringfireball.net/projects/markdown/syntax)** and a few **additional features**.
## Front Matter
feat(v2): auto-generated sidebars, frontmatter-less sites (#4582) * POC of autogenerated sidebars * use combine-promises utility lib * autogenerated sidebar poc working * Revert "autogenerated sidebar poc working" This reverts commit c81da980 * POC of auto-generated sidebars for community docs * update tests * add initial test suite for autogenerated sidebars + fix some edge cases * Improve autogen sidebars: strip more number prefixes in folder breadcrumb + slugs * fix typo! * Add tests for partially generated sidebars + fix edge cases + extract sidebar generation code * Ability to read category metadatas file from a file in the category * fix tests * change position of API * ability to extract number prefix * stable system to enable position frontmatter * fix tests for autogen sidebar position * renamings * restore community sidebars * rename frontmatter position -> sidebar_position * make sidebarItemsGenerator fn configurable * minor changes * rename dirPath => dirName * Make the init template use autogenerated sidebars * fix options * fix docusaurus site: remove test docs * add _category_ file to docs pathsToWatch * add _category_ file to docs pathsToWatch * tutorial: use sidebar_position instead of file number prefixes * Adapt Docusaurus tutorial for autogenerated sidebars * remove slug: / * polish the homepage template * rename _category_ sidebar_position to just "position" * test for custom sidebarItemsGenerator fn * fix category metadata + add link to report tutorial issues * fix absolute path breaking tests * fix absolute path breaking tests * Add test for floating number sidebar_position * add sidebarItemsGenerator unit tests * add processSidebars unit tests * Fix init template broken links * windows test * increase code translations test timeout * cleanup mockCategoryMetadataFiles after windows test fixed * update init template positions * fix windows tests * fix comment * Add autogenerated sidebar items documentation + rewrite the full sidebars page doc * add useful comment * fix code block title
2021-04-15 10:20:11 -04:00
Markdown documents have metadata at the top called [Front Matter](https://jekyllrb.com/docs/front-matter/):
feat(v2): auto-generated sidebars, frontmatter-less sites (#4582) * POC of autogenerated sidebars * use combine-promises utility lib * autogenerated sidebar poc working * Revert "autogenerated sidebar poc working" This reverts commit c81da980 * POC of auto-generated sidebars for community docs * update tests * add initial test suite for autogenerated sidebars + fix some edge cases * Improve autogen sidebars: strip more number prefixes in folder breadcrumb + slugs * fix typo! * Add tests for partially generated sidebars + fix edge cases + extract sidebar generation code * Ability to read category metadatas file from a file in the category * fix tests * change position of API * ability to extract number prefix * stable system to enable position frontmatter * fix tests for autogen sidebar position * renamings * restore community sidebars * rename frontmatter position -> sidebar_position * make sidebarItemsGenerator fn configurable * minor changes * rename dirPath => dirName * Make the init template use autogenerated sidebars * fix options * fix docusaurus site: remove test docs * add _category_ file to docs pathsToWatch * add _category_ file to docs pathsToWatch * tutorial: use sidebar_position instead of file number prefixes * Adapt Docusaurus tutorial for autogenerated sidebars * remove slug: / * polish the homepage template * rename _category_ sidebar_position to just "position" * test for custom sidebarItemsGenerator fn * fix category metadata + add link to report tutorial issues * fix absolute path breaking tests * fix absolute path breaking tests * Add test for floating number sidebar_position * add sidebarItemsGenerator unit tests * add processSidebars unit tests * Fix init template broken links * windows test * increase code translations test timeout * cleanup mockCategoryMetadataFiles after windows test fixed * update init template positions * fix windows tests * fix comment * Add autogenerated sidebar items documentation + rewrite the full sidebars page doc * add useful comment * fix code block title
2021-04-15 10:20:11 -04:00
```text title="my-doc.md"
// highlight-start
---
feat(v2): auto-generated sidebars, frontmatter-less sites (#4582) * POC of autogenerated sidebars * use combine-promises utility lib * autogenerated sidebar poc working * Revert "autogenerated sidebar poc working" This reverts commit c81da980 * POC of auto-generated sidebars for community docs * update tests * add initial test suite for autogenerated sidebars + fix some edge cases * Improve autogen sidebars: strip more number prefixes in folder breadcrumb + slugs * fix typo! * Add tests for partially generated sidebars + fix edge cases + extract sidebar generation code * Ability to read category metadatas file from a file in the category * fix tests * change position of API * ability to extract number prefix * stable system to enable position frontmatter * fix tests for autogen sidebar position * renamings * restore community sidebars * rename frontmatter position -> sidebar_position * make sidebarItemsGenerator fn configurable * minor changes * rename dirPath => dirName * Make the init template use autogenerated sidebars * fix options * fix docusaurus site: remove test docs * add _category_ file to docs pathsToWatch * add _category_ file to docs pathsToWatch * tutorial: use sidebar_position instead of file number prefixes * Adapt Docusaurus tutorial for autogenerated sidebars * remove slug: / * polish the homepage template * rename _category_ sidebar_position to just "position" * test for custom sidebarItemsGenerator fn * fix category metadata + add link to report tutorial issues * fix absolute path breaking tests * fix absolute path breaking tests * Add test for floating number sidebar_position * add sidebarItemsGenerator unit tests * add processSidebars unit tests * Fix init template broken links * windows test * increase code translations test timeout * cleanup mockCategoryMetadataFiles after windows test fixed * update init template positions * fix windows tests * fix comment * Add autogenerated sidebar items documentation + rewrite the full sidebars page doc * add useful comment * fix code block title
2021-04-15 10:20:11 -04:00
id: my-doc-id
title: My document title
description: My document description
feat(v2): auto-generated sidebars, frontmatter-less sites (#4582) * POC of autogenerated sidebars * use combine-promises utility lib * autogenerated sidebar poc working * Revert "autogenerated sidebar poc working" This reverts commit c81da980 * POC of auto-generated sidebars for community docs * update tests * add initial test suite for autogenerated sidebars + fix some edge cases * Improve autogen sidebars: strip more number prefixes in folder breadcrumb + slugs * fix typo! * Add tests for partially generated sidebars + fix edge cases + extract sidebar generation code * Ability to read category metadatas file from a file in the category * fix tests * change position of API * ability to extract number prefix * stable system to enable position frontmatter * fix tests for autogen sidebar position * renamings * restore community sidebars * rename frontmatter position -> sidebar_position * make sidebarItemsGenerator fn configurable * minor changes * rename dirPath => dirName * Make the init template use autogenerated sidebars * fix options * fix docusaurus site: remove test docs * add _category_ file to docs pathsToWatch * add _category_ file to docs pathsToWatch * tutorial: use sidebar_position instead of file number prefixes * Adapt Docusaurus tutorial for autogenerated sidebars * remove slug: / * polish the homepage template * rename _category_ sidebar_position to just "position" * test for custom sidebarItemsGenerator fn * fix category metadata + add link to report tutorial issues * fix absolute path breaking tests * fix absolute path breaking tests * Add test for floating number sidebar_position * add sidebarItemsGenerator unit tests * add processSidebars unit tests * Fix init template broken links * windows test * increase code translations test timeout * cleanup mockCategoryMetadataFiles after windows test fixed * update init template positions * fix windows tests * fix comment * Add autogenerated sidebar items documentation + rewrite the full sidebars page doc * add useful comment * fix code block title
2021-04-15 10:20:11 -04:00
slug: /my-custom-url
---
feat(v2): auto-generated sidebars, frontmatter-less sites (#4582) * POC of autogenerated sidebars * use combine-promises utility lib * autogenerated sidebar poc working * Revert "autogenerated sidebar poc working" This reverts commit c81da980 * POC of auto-generated sidebars for community docs * update tests * add initial test suite for autogenerated sidebars + fix some edge cases * Improve autogen sidebars: strip more number prefixes in folder breadcrumb + slugs * fix typo! * Add tests for partially generated sidebars + fix edge cases + extract sidebar generation code * Ability to read category metadatas file from a file in the category * fix tests * change position of API * ability to extract number prefix * stable system to enable position frontmatter * fix tests for autogen sidebar position * renamings * restore community sidebars * rename frontmatter position -> sidebar_position * make sidebarItemsGenerator fn configurable * minor changes * rename dirPath => dirName * Make the init template use autogenerated sidebars * fix options * fix docusaurus site: remove test docs * add _category_ file to docs pathsToWatch * add _category_ file to docs pathsToWatch * tutorial: use sidebar_position instead of file number prefixes * Adapt Docusaurus tutorial for autogenerated sidebars * remove slug: / * polish the homepage template * rename _category_ sidebar_position to just "position" * test for custom sidebarItemsGenerator fn * fix category metadata + add link to report tutorial issues * fix absolute path breaking tests * fix absolute path breaking tests * Add test for floating number sidebar_position * add sidebarItemsGenerator unit tests * add processSidebars unit tests * Fix init template broken links * windows test * increase code translations test timeout * cleanup mockCategoryMetadataFiles after windows test fixed * update init template positions * fix windows tests * fix comment * Add autogenerated sidebar items documentation + rewrite the full sidebars page doc * add useful comment * fix code block title
2021-04-15 10:20:11 -04:00
// highlight-end
## Markdown heading
Markdown text with [links](./hello.md)
```
## Links
Regular Markdown links are supported, using url paths or relative file paths.
```md
Let's see how to [Create a page](/create-a-page).
```
```md
Let's see how to [Create a page](./create-a-page.md).
```
**Result:** Let's see how to [Create a page](./create-a-page.md).
## Images
Regular Markdown images are supported.
You can use absolute paths to reference images in the static directory (`static/img/docusaurus.png`):
```md
![Docusaurus logo](/img/docusaurus.png)
```
![Docusaurus logo](/img/docusaurus.png)
chore: backport retro compatible commits for the Docusaurus v2.3 release (#8585) Co-authored-by: stnor <stefan@selessia.com> Co-authored-by: Joshua Chen <sidachen2003@gmail.com> Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matija Sirk <matija.sirk@kopit.si> Co-authored-by: AHMET BAYHAN BAYRAMOGLU <49499275+ABB65@users.noreply.github.com> Co-authored-by: Stefan Norberg <stefan@norberg.org> Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com> Co-authored-by: Muhammad Hammad <33136628+mhnaeem@users.noreply.github.com> Co-authored-by: Denis Al-Khelali <denis.al-khelali@itechart-group.com> Co-authored-by: Balthasar Hofer <lebalz@outlook.com> Co-authored-by: Danny Kim <0916dhkim@gmail.com> Co-authored-by: Frieder Bluemle <frieder.bluemle@gmail.com> Co-authored-by: John Reilly <johnny_reilly@hotmail.com> Co-authored-by: Robert Lawrence <62929526+r-lawrence@users.noreply.github.com> Co-authored-by: Sadegh Karimi <sadegh.krmi@gmail.com> Co-authored-by: Lachlan Heywood <lachieh@users.noreply.github.com> Co-authored-by: mturoci <64769322+mturoci@users.noreply.github.com> Co-authored-by: 宋锦丰 <36468758+SJFCS@users.noreply.github.com> Co-authored-by: Nguyễn Thành Nam <namnguyenthanh.work@gmail.com> Co-authored-by: Dongjoon Lee <djunnni@gmail.com> Co-authored-by: Thomas.CA <44041651+Thomascogez@users.noreply.github.com> Co-authored-by: Riccardo <riccardo.odone@gmail.com> Co-authored-by: Lane Goolsby <lanegoolsby@yahoo.com> Co-authored-by: Mariusz Krzaczkowski <m.krzaczkowski@yetiforce.com> Co-authored-by: Matija Sirk <sirkmatija@gmail.com> Co-authored-by: Jiří <zmrhal.j@gmail.com>
2023-01-27 11:02:15 -05:00
You can reference images relative to the current file as well. This is particularly useful to colocate images close to the Markdown files using them:
```md
![Docusaurus logo](./img/docusaurus.png)
```
## Code Blocks
Markdown code blocks are supported with Syntax highlighting.
```jsx title="src/components/HelloDocusaurus.js"
function HelloDocusaurus() {
return (
<h1>Hello, Docusaurus!</h1>
)
}
```
```jsx title="src/components/HelloDocusaurus.js"
function HelloDocusaurus() {
return <h1>Hello, Docusaurus!</h1>;
}
```
## Admonitions
Docusaurus has a special syntax to create admonitions and callouts:
:::tip My tip
Use this awesome feature option
:::
:::danger Take care
This action is dangerous
:::
:::tip My tip
Use this awesome feature option
:::
:::danger Take care
This action is dangerous
:::
## MDX and React Components
[MDX](https://mdxjs.com/) can make your documentation more **interactive** and allows using any **React components inside Markdown**:
```jsx
export const Highlight = ({children, color}) => (
<span
style={{
backgroundColor: color,
borderRadius: '20px',
color: '#fff',
padding: '10px',
cursor: 'pointer',
}}
onClick={() => {
alert(`You clicked the color ${color} with label ${children}`)
}}>
{children}
</span>
);
This is <Highlight color="#25c2a0">Docusaurus green</Highlight> !
This is <Highlight color="#1877F2">Facebook blue</Highlight> !
```
export const Highlight = ({children, color}) => (
<span
style={{
backgroundColor: color,
borderRadius: '20px',
color: '#fff',
padding: '10px',
cursor: 'pointer',
}}
onClick={() => {
alert(`You clicked the color ${color} with label ${children}`);
}}>
{children}
</span>
);
This is <Highlight color="#25c2a0">Docusaurus green</Highlight> !
This is <Highlight color="#1877F2">Facebook blue</Highlight> !