mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 06:56:56 +02:00
parent
6fe2a05585
commit
2a94db2d64
25 changed files with 93 additions and 90 deletions
|
@ -11,20 +11,20 @@
|
|||
<p><code>title</code>: The title of your document. If this field is not present, the document's <code>title</code> will default to it's <code>id</code>.</p>
|
||||
<p><code>sidebar_label</code>: The text shown in the document sidebar for this document. If this field is not present, the document's <code>sidebar_label</code> will default to it's <code>title</code>.</p>
|
||||
<p>For example:</p>
|
||||
<pre><code><span class="hljs-meta">---</span>
|
||||
<span class="hljs-attr">id:</span> <span class="hljs-string">doc1</span>
|
||||
<span class="hljs-attr">title:</span> <span class="hljs-string">My</span> <span class="hljs-string">Document</span>
|
||||
<span class="hljs-attr">sidebar_label:</span> <span class="hljs-string">Document</span>
|
||||
<span class="hljs-meta">---</span>
|
||||
<pre><code class="hljs css markdown">---
|
||||
id: doc1
|
||||
title: My Document
|
||||
<span class="hljs-section">sidebar_label: Document
|
||||
---</span>
|
||||
</code></pre>
|
||||
<p>Versioned documents have their ids altered to include the version number when they get copied. The new <code>id</code> is <code>version-${version}-${id}</code> where <code>${version}</code> is the version number of that document and <code>${id}</code> is the original <code>id</code>. Additionally, versioned documents get an added <code>original_id</code> field with the original document id.</p>
|
||||
<p>For example:</p>
|
||||
<pre><code><span class="hljs-meta">---</span>
|
||||
<span class="hljs-attr">id:</span> <span class="hljs-string">version-1.0.0-doc1</span>
|
||||
<span class="hljs-attr">title:</span> <span class="hljs-string">My</span> <span class="hljs-string">Document</span>
|
||||
<span class="hljs-attr">sidebar_label:</span> <span class="hljs-string">Document</span>
|
||||
<span class="hljs-attr">original_id:</span> <span class="hljs-string">doc1</span>
|
||||
<span class="hljs-meta">---</span>
|
||||
<pre><code class="hljs css markdown">---
|
||||
id: version-1.0.0-doc1
|
||||
title: My Document
|
||||
sidebar_label: Document
|
||||
<span class="hljs-section">original_id: doc1
|
||||
---</span>
|
||||
</code></pre>
|
||||
<h2><a class="anchor" name="blog-posts"></a>Blog Posts <a class="hash-link" href="#blog-posts">#</a></h2>
|
||||
<p>Blog Posts use the following markdown header fields that are enclosed by a line <code>---</code> on either side:</p>
|
||||
|
@ -33,32 +33,32 @@
|
|||
<p><code>authorURL</code>: A page to link to when a site user clicks the author's name. If this field is omitted, the author's name will not link to anything.</p>
|
||||
<p><code>authorFBID</code>: The author's Facebook id, used only to get the author's profile picture to display with the blog post. If this field is omitted, no author picture will be shown for the blog post.</p>
|
||||
<p>For example:</p>
|
||||
<pre><code><span class="hljs-meta">---</span>
|
||||
<span class="hljs-attr">title:</span> <span class="hljs-string">My</span> <span class="hljs-string">First</span> <span class="hljs-string">Blog</span> <span class="hljs-string">Post</span>
|
||||
<span class="hljs-attr">author:</span> <span class="hljs-string">Frank</span> <span class="hljs-string">Li</span>
|
||||
<span class="hljs-attr">authorURL:</span> <span class="hljs-attr">http://twitter.com/franchementli</span>
|
||||
<span class="hljs-attr">authorFBID:</span> <span class="hljs-number">100002976521003</span>
|
||||
<span class="hljs-meta">---</span>
|
||||
<pre><code class="hljs css markdown">---
|
||||
title: My First Blog Post
|
||||
author: Frank Li
|
||||
authorURL: http://twitter.com/franchementli
|
||||
<span class="hljs-section">authorFBID: 100002976521003
|
||||
---</span>
|
||||
</code></pre>
|
||||
<h2><a class="anchor" name="extra-features"></a>Extra Features <a class="hash-link" href="#extra-features">#</a></h2>
|
||||
<p>Docusaurus supports some extra features when writing documentation in markdown.</p>
|
||||
<h2><a class="anchor" name="linking-other-documents"></a>Linking other Documents <a class="hash-link" href="#linking-other-documents">#</a></h2>
|
||||
<p>You can use relative urls to other documentation files which will automatically get converted to the corresponding html links when they get rendered.</p>
|
||||
<p>Example:</p>
|
||||
<pre><code class="language-markdown">[<span class="hljs-string">This links to another document</span>](<span class="hljs-link">other-document.md</span>)
|
||||
<pre><code class="hljs css markdown">[<span class="hljs-string">This links to another document</span>](<span class="hljs-link">other-document.md</span>)
|
||||
</code></pre>
|
||||
<p>This markdown will automatically get converted into a link to <code>/docs/other-document.html</code> (or the appropriately translated/versioned link) once it gets rendered.</p>
|
||||
<p>This can help when you want to navigate through docs on GitHub since the links there will be functional links to other documents (still on GitHub), but the documents will have the correct html links when they get rendered.</p>
|
||||
<h2><a class="anchor" name="linking-to-images-and-other-assets"></a>Linking to Images and Other Assets <a class="hash-link" href="#linking-to-images-and-other-assets">#</a></h2>
|
||||
<p>Static assets can be linked to in the same way that documents are, using relative urls. Static assets used in documents and blogs should go into <code>docs/assets</code> and <code>website/blog/assets</code>, respectively. The markdown will get converted into correct link paths so that these paths will work for documents of all languages and versions.</p>
|
||||
<p>Example:</p>
|
||||
<pre><code class="language-markdown">
|
||||
<pre><code class="hljs css markdown">
|
||||
</code></pre>
|
||||
<h2><a class="anchor" name="generating-table-of-contents"></a>Generating Table of Contents <a class="hash-link" href="#generating-table-of-contents">#</a></h2>
|
||||
<p>You can make an autogenerated list of links, which can be useful as a table of contents for API docs.</p>
|
||||
<p>In your markdown file, insert a line with the text <<code>AUTOGENERATED_TABLE_OF_CONTENTS</code>>. Write your documentation using <code>h3</code> headers for each function inside a code block. These will be found by Docusaurus and a list of links to these sections will inserted at the text <<code>AUTOGENERATED_TABLE_OF_CONTENTS</code>>.</p>
|
||||
<p>Example:</p>
|
||||
<pre><code class="language-markdown"><span class="hljs-section">### `docusaurus.function(a, b)`</span>
|
||||
<pre><code class="hljs css markdown"><span class="hljs-section">### `docusaurus.function(a, b)`</span>
|
||||
|
||||
Text describing my function
|
||||
|
||||
|
@ -68,13 +68,13 @@ Text describing my function
|
|||
Text describing my function
|
||||
</code></pre>
|
||||
<p>will lead to a table of contents of the functions:</p>
|
||||
<pre><code class="language-markdown"><span class="hljs-bullet">- </span><span class="hljs-code">`docusaurus.function(a, b)`</span>
|
||||
<pre><code class="hljs css markdown"><span class="hljs-bullet">- </span><span class="hljs-code">`docusaurus.function(a, b)`</span>
|
||||
<span class="hljs-bullet">- </span><span class="hljs-code">`docdoc(file)`</span>
|
||||
</code></pre>
|
||||
<p>and each function will link to their corresponding sections in the page.</p>
|
||||
<h2><a class="anchor" name="syntax-highlighting"></a>Syntax Highlighting <a class="hash-link" href="#syntax-highlighting">#</a></h2>
|
||||
<p>Syntax highlighting is enabled by default on fenced code blocks. The language should be detected automatically, but you can sometimes get better results by specifying the language. You can do so using an <a href="https://github.github.com/gfm/#example-111">info string</a>, following the three opening backticks. The following JavaScript example...</p>
|
||||
<pre><code>```javascript
|
||||
<pre><code class="hljs">```javascript
|
||||
ReactDOM.render(
|
||||
<h1>Hello, world!</h1>,
|
||||
document.getElementById('root')
|
||||
|
@ -82,24 +82,24 @@ ReactDOM.render(
|
|||
```
|
||||
</code></pre>
|
||||
<p>...would be rendered with syntax highlighting like so:</p>
|
||||
<pre><code class="language-javascript">ReactDOM.render(
|
||||
<pre><code class="hljs css javascript">ReactDOM.render(
|
||||
<span class="xml"><span class="hljs-tag"><<span class="hljs-name">h1</span>></span>Hello, world!<span class="hljs-tag"></<span class="hljs-name">h1</span>></span></span>,
|
||||
<span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'root'</span>)
|
||||
);
|
||||
</code></pre>
|
||||
<p>Highlighting is provided by <a href="https://highlightjs.org">Highlight.js</a> using the theme specified in your <code>siteConfig.js</code> file as part of the <code>highlight</code> key:</p>
|
||||
<pre><code><span class="hljs-selector-tag">highlight</span>: {
|
||||
<span class="hljs-attribute">theme</span>: <span class="hljs-string">'default'</span>
|
||||
<pre><code class="hljs css javascript">highlight: {
|
||||
<span class="hljs-attr">theme</span>: <span class="hljs-string">'default'</span>
|
||||
}
|
||||
</code></pre>
|
||||
<p>You can find the full list of supported themes in the Highlight.js <a href="https://github.com/isagalaev/highlight.js/tree/master/src/styles"><code>styles</code></a> directory.</p>
|
||||
<h3><a class="anchor" name="registering-additional-languages"></a>Registering additional languages <a class="hash-link" href="#registering-additional-languages">#</a></h3>
|
||||
<p>While Highlight.js provides support for <a href="https://highlightjs.org/static/demo/">many popular languages out of the box</a>, you may find the need to register additional language support. For these cases, we provide an escape valve by exposing the <code>hljs</code> constant as part of the <code>highlight</code> config key. This in turn allows you to call <a href="http://highlightjs.readthedocs.io/en/latest/api.html#registerlanguage-name-language"><code>registerLanguage</code></a>:</p>
|
||||
<pre><code><span class="hljs-selector-tag">highlight</span>: {
|
||||
<span class="hljs-attribute">theme</span>: <span class="hljs-string">'default'</span>,
|
||||
hljs: <span class="hljs-built_in">function</span>(hljs) {
|
||||
hljs.<span class="hljs-built_in">registerLanguage</span>(<span class="hljs-string">'galacticbasic'</span>, function(hljs) {
|
||||
// ...
|
||||
<pre><code class="hljs css javascript">highlight: {
|
||||
<span class="hljs-attr">theme</span>: <span class="hljs-string">'default'</span>,
|
||||
<span class="hljs-attr">hljs</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">hljs</span>) </span>{
|
||||
hljs.registerLanguage(<span class="hljs-string">'galacticbasic'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">hljs</span>) </span>{
|
||||
<span class="hljs-comment">// ...</span>
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -111,4 +111,4 @@ ReactDOM.render(
|
|||
indexName: 'docusaurus',
|
||||
inputSelector: '#search_input_react'
|
||||
});
|
||||
</script><script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script><script>hljs.initHighlightingOnLoad();</script></body></html>
|
||||
</script></body></html>
|
Loading…
Add table
Add a link
Reference in a new issue