mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-20 20:46:58 +02:00
update website [ci skip]
This commit is contained in:
parent
7275161e21
commit
731f677df8
14 changed files with 14 additions and 14 deletions
|
@ -4,7 +4,7 @@
|
|||
toggler.onclick = function() {
|
||||
nav.classList.toggle('docsSliderActive');
|
||||
};
|
||||
</script></nav></div><div class="container mainContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/facebookexperimental/docusaurus/edit/master/docs/api-pages.md" target="_blank">Edit this Doc</a><h1>Pages and Styles</h1></header><article><div><p>Docusaurus provides support for writing pages as React components inside the <code>website/pages</code> folder which will share the same header, footer, and styles as the rest of the site.</p><h2><a class="anchor" name="urls-for-pages"></a>Urls for Pages <a class="hash-link" href="#urls-for-pages">#</a></h2><p>Any <code>.js</code> files in <code>website/pages</code> will be rendered to static html using the path of the file after "pages". Files in <code>website/pages/en</code> will also get copied out into <code>pages</code> and will OVERRIDE any files of the same name in <code>pages</code>. For example, the page for the <code>website/pages/en/help.js</code> file will be found at the url <code>${baseUrl}en/help.js</code> as well as the url <code>${baseUrl}help.js</code>, where <code>${baseUrl}</code> is the <code>baseUrl</code> field set in your <a href="/docs/en/site-config.html" target="">siteConfig.js file</a>.</p><h2><a class="anchor" name="page-require-paths"></a>Page Require Paths <a class="hash-link" href="#page-require-paths">#</a></h2><p>Docusaurus provides a few useful React components for users to write their own pages, found in the <code>CompLibrary</code> module. This module is provided as part of Docusaurus in <code>node_modules/docusaurus</code>, so to access it, pages in the <code>pages</code> folder are temporarily copied into <code>node_modules/docusaurus</code> when rendering to static html. As seen in the example files, this means that a user page at <code>pages/en/index.js</code> uses a require path to <code>"../../core/CompLibrary.js"</code> to import the provided components.</p><p>What this means to the user is that if you wish to use the <code>CompLibrary</code> module, make sure the require path is set correctly. For example, a page at <code>page/mypage.js</code> would use a path <code>"../core/CompLibrary.js"</code>.</p><p>If you wish to use your own components inside the website folder, use <code>process.cwd()</code> which will refer to the <code>website</code> folder to construct require paths. For example, if you add a component to <code>website/core/mycomponent.js</code>, you can use the require path, <code>"process.cwd() + /core/mycomponent.js"</code>.</p><h2><a class="anchor" name="provided-components"></a>Provided Components <a class="hash-link" href="#provided-components">#</a></h2><p>Docusaurus provides the following components in <code>CompLibrary</code>:</p><h3><a class="anchor" name="complibrarymarked"></a><code>CompLibrary.Marked</code> <a class="hash-link" href="#complibrarymarked">#</a></h3><p>A React component that parses Markdown to html.</p><p>Example:</p><pre class="prism language-jsx"><span class="token keyword">const</span> Marked <span class="token operator">=</span> CompLibrary<span class="token punctuation">.</span>Marked<span class="token punctuation">;</span>
|
||||
</script></nav></div><div class="container mainContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/facebookexperimental/docusaurus/edit/master/docs/api-pages.md" target="_blank">Edit</a><h1>Pages and Styles</h1></header><article><div><p>Docusaurus provides support for writing pages as React components inside the <code>website/pages</code> folder which will share the same header, footer, and styles as the rest of the site.</p><h2><a class="anchor" name="urls-for-pages"></a>Urls for Pages <a class="hash-link" href="#urls-for-pages">#</a></h2><p>Any <code>.js</code> files in <code>website/pages</code> will be rendered to static html using the path of the file after "pages". Files in <code>website/pages/en</code> will also get copied out into <code>pages</code> and will OVERRIDE any files of the same name in <code>pages</code>. For example, the page for the <code>website/pages/en/help.js</code> file will be found at the url <code>${baseUrl}en/help.js</code> as well as the url <code>${baseUrl}help.js</code>, where <code>${baseUrl}</code> is the <code>baseUrl</code> field set in your <a href="/docs/en/site-config.html" target="">siteConfig.js file</a>.</p><h2><a class="anchor" name="page-require-paths"></a>Page Require Paths <a class="hash-link" href="#page-require-paths">#</a></h2><p>Docusaurus provides a few useful React components for users to write their own pages, found in the <code>CompLibrary</code> module. This module is provided as part of Docusaurus in <code>node_modules/docusaurus</code>, so to access it, pages in the <code>pages</code> folder are temporarily copied into <code>node_modules/docusaurus</code> when rendering to static html. As seen in the example files, this means that a user page at <code>pages/en/index.js</code> uses a require path to <code>"../../core/CompLibrary.js"</code> to import the provided components.</p><p>What this means to the user is that if you wish to use the <code>CompLibrary</code> module, make sure the require path is set correctly. For example, a page at <code>page/mypage.js</code> would use a path <code>"../core/CompLibrary.js"</code>.</p><p>If you wish to use your own components inside the website folder, use <code>process.cwd()</code> which will refer to the <code>website</code> folder to construct require paths. For example, if you add a component to <code>website/core/mycomponent.js</code>, you can use the require path, <code>"process.cwd() + /core/mycomponent.js"</code>.</p><h2><a class="anchor" name="provided-components"></a>Provided Components <a class="hash-link" href="#provided-components">#</a></h2><p>Docusaurus provides the following components in <code>CompLibrary</code>:</p><h3><a class="anchor" name="complibrarymarked"></a><code>CompLibrary.Marked</code> <a class="hash-link" href="#complibrarymarked">#</a></h3><p>A React component that parses Markdown to html.</p><p>Example:</p><pre class="prism language-jsx"><span class="token keyword">const</span> Marked <span class="token operator">=</span> CompLibrary<span class="token punctuation">.</span>Marked<span class="token punctuation">;</span>
|
||||
|
||||
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Marked</span><span class="token punctuation">></span></span><span class="token punctuation">[</span>Markdown syntax <span class="token keyword">for</span> a link<span class="token punctuation">]</span><span class="token punctuation">(</span>http<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>www<span class="token punctuation">.</span>example<span class="token punctuation">.</span>com<span class="token punctuation">)</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Marked</span><span class="token punctuation">></span></span></pre><h3><a class="anchor" name="complibrarycontainer"></a><code>CompLibrary.Container</code> <a class="hash-link" href="#complibrarycontainer">#</a></h3><p>A React container component using Docusaurus styles. Has optional padding and background color attributes that you can configure.</p><p>Padding choices: <code>all</code>, <code>bottom</code>, <code>left</code>, <code>right</code>, <code>top</code>.<br/>Background choices: <code>dark</code>, <code>highlight</code>, <code>light</code>.</p><p>Example:</p><pre class="prism language-jsx"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Container</span> <span class="token attr-name">padding</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token string">"bottom"</span><span class="token punctuation">,</span> <span class="token string">"top"</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token attr-name">background</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>light<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
|
||||
<span class="token operator">...</span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue