mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
feat(v2): style navbar (#1044)
This commit is contained in:
parent
31dd833b6c
commit
ba96992225
13 changed files with 177 additions and 78 deletions
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
id: baz
|
id: baz
|
||||||
title: Test Markdown
|
title: Markdown
|
||||||
---
|
---
|
||||||
|
|
||||||
## Images
|
## Images
|
||||||
|
@ -17,12 +17,10 @@ With a reference later in the document defining the URL location:
|
||||||
|
|
||||||
[link text](http://dev.nodeca.com)
|
[link text](http://dev.nodeca.com)
|
||||||
|
|
||||||
[link with title](http://nodeca.github.io/pica/demo/ "title text!")
|
[link with title](http://nodeca.github.io/pica/demo/ 'title text!')
|
||||||
|
|
||||||
Autoconverted link https://github.com/nodeca/pica (enable linkify to see)
|
Autoconverted link https://github.com/nodeca/pica (enable linkify to see)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Footnotes
|
## Footnotes
|
||||||
|
|
||||||
Footnote 1 link[^first].
|
Footnote 1 link[^first].
|
||||||
|
@ -39,15 +37,13 @@ Duplicated footnote reference[^second].
|
||||||
|
|
||||||
[^second]: Footnote text.
|
[^second]: Footnote text.
|
||||||
|
|
||||||
|
|
||||||
## Definition lists
|
## Definition lists
|
||||||
|
|
||||||
Term 1
|
Term 1
|
||||||
|
|
||||||
: Definition 1
|
: Definition 1 with lazy continuation.
|
||||||
with lazy continuation.
|
|
||||||
|
|
||||||
Term 2 with *inline markup*
|
Term 2 with _inline markup_
|
||||||
|
|
||||||
: Definition 2
|
: Definition 2
|
||||||
|
|
||||||
|
@ -57,13 +53,9 @@ Term 2 with *inline markup*
|
||||||
|
|
||||||
_Compact style:_
|
_Compact style:_
|
||||||
|
|
||||||
Term 1
|
Term 1 ~ Definition 1
|
||||||
~ Definition 1
|
|
||||||
|
|
||||||
Term 2
|
|
||||||
~ Definition 2a
|
|
||||||
~ Definition 2b
|
|
||||||
|
|
||||||
|
Term 2 ~ Definition 2a ~ Definition 2b
|
||||||
|
|
||||||
## Abbreviations
|
## Abbreviations
|
||||||
|
|
||||||
|
@ -71,4 +63,4 @@ This is HTML abbreviation example.
|
||||||
|
|
||||||
It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.
|
It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.
|
||||||
|
|
||||||
*[HTML]: Hyper Text Markup Language
|
\*[HTML]: Hyper Text Markup Language
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
---
|
---
|
||||||
id: hello
|
id: hello
|
||||||
title: Hello, World !
|
title: Hello, World!
|
||||||
---
|
---
|
||||||
|
|
||||||
## Relative links
|
## Relative links
|
||||||
|
|
||||||
Replace this
|
Replace this [highlight](highlight.md) [docusaurus](docusaurus.md)
|
||||||
[highlight](highlight.md) [docusaurus](docusaurus.md)
|
|
||||||
|
|
||||||
Can't replace this
|
Can't replace this [file](file.md)
|
||||||
[file](file.md)
|
|
||||||
|
|
||||||
Do not replace below
|
Do not replace below
|
||||||
|
|
||||||
|
@ -20,21 +18,22 @@ Do not replace below
|
||||||
## Blockquotes
|
## Blockquotes
|
||||||
|
|
||||||
> Blockquotes can also be nested...
|
> Blockquotes can also be nested...
|
||||||
>> ...by using additional greater-than signs right next to each other...
|
>
|
||||||
|
> > ...by using additional greater-than signs right next to each other...
|
||||||
|
> >
|
||||||
> > > ...or with spaces between arrows.
|
> > > ...or with spaces between arrows.
|
||||||
|
|
||||||
|
|
||||||
## Lists
|
## Lists
|
||||||
|
|
||||||
Unordered
|
Unordered
|
||||||
|
|
||||||
+ Create a list by starting a line with `+`, `-`, or `*`
|
- Create a list by starting a line with `+`, `-`, or `*`
|
||||||
+ Sub-lists are made by indenting 2 spaces:
|
- Sub-lists are made by indenting 2 spaces:
|
||||||
- Marker character change forces new list start:
|
- Marker character change forces new list start:
|
||||||
* Ac tristique libero volutpat at
|
- Ac tristique libero volutpat at
|
||||||
+ Facilisis in pretium nisl aliquet
|
* Facilisis in pretium nisl aliquet
|
||||||
- Nulla volutpat aliquam velit
|
- Nulla volutpat aliquam velit
|
||||||
+ Very easy!
|
- Very easy!
|
||||||
|
|
||||||
Ordered
|
Ordered
|
||||||
|
|
||||||
|
@ -42,9 +41,8 @@ Ordered
|
||||||
2. Consectetur adipiscing elit
|
2. Consectetur adipiscing elit
|
||||||
3. Integer molestie lorem at massa
|
3. Integer molestie lorem at massa
|
||||||
|
|
||||||
|
1) You can use sequential numbers...
|
||||||
1. You can use sequential numbers...
|
1) ...or keep all the numbers as `1.`
|
||||||
1. ...or keep all the numbers as `1.`
|
|
||||||
|
|
||||||
Start numbering with offset:
|
Start numbering with offset:
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
id: highlight
|
id: code
|
||||||
title: Syntax highlighting demo
|
title: Code
|
||||||
---
|
---
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -11,7 +11,6 @@ int main() {
|
||||||
cout << "Hello world\n";
|
cout << "Hello world\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
id: docusaurus
|
id: intro
|
||||||
title: docusaurus
|
title: Introduction
|
||||||
---
|
---
|
||||||
|
|
||||||
<h1 align="center">
|
<h1 align="center">
|
||||||
|
@ -21,6 +21,6 @@ title: docusaurus
|
||||||
|
|
||||||
Docusaurus is a project for easily building, deploying, and maintaining open source project websites.
|
Docusaurus is a project for easily building, deploying, and maintaining open source project websites.
|
||||||
|
|
||||||
* **Simple to Start** Docusaurus is built to be easy to [get up and running](https://docusaurus.io/docs/en/installation.html) in as little time possible. We've built Docusaurus to handle the website build process so you can focus on your project.
|
- **Simple to Start** Docusaurus is built to be easy to [get up and running](https://docusaurus.io/docs/en/installation.html) in as little time possible. We've built Docusaurus to handle the website build process so you can focus on your project.
|
||||||
* **Localizable** Docusaurus ships with [localization support](https://docusaurus.io/docs/en/translation.html) via CrowdIn. Empower and grow your international community by translating your documentation.
|
- **Localizable** Docusaurus ships with [localization support](https://docusaurus.io/docs/en/translation.html) via CrowdIn. Empower and grow your international community by translating your documentation.
|
||||||
* **Customizable** While Docusaurus ships with the key pages and sections you need to get started, including a home page, a docs section, a [blog](https://docusaurus.io/docs/en/blog.html), and additional support pages, it is also [customizable](https://docusaurus.io/docs/en/custom-pages.html) as well to ensure you have a site that is [uniquely yours](https://docusaurus.io/docs/en/api-pages.html).
|
- **Customizable** While Docusaurus ships with the key pages and sections you need to get started, including a home page, a docs section, a [blog](https://docusaurus.io/docs/en/blog.html), and additional support pages, it is also [customizable](https://docusaurus.io/docs/en/custom-pages.html) as well to ensure you have a site that is [uniquely yours](https://docusaurus.io/docs/en/api-pages.html).
|
|
@ -5,6 +5,7 @@ import Helmet from 'react-helmet';
|
||||||
|
|
||||||
import DocsPaginator from '@theme/DocsPaginator'; // eslint-disable-line
|
import DocsPaginator from '@theme/DocsPaginator'; // eslint-disable-line
|
||||||
import Footer from '@theme/Footer'; // eslint-disable-line
|
import Footer from '@theme/Footer'; // eslint-disable-line
|
||||||
|
import Navbar from '@theme/Navbar'; // eslint-disable-line
|
||||||
import Sidebar from '@theme/Sidebar'; // eslint-disable-line
|
import Sidebar from '@theme/Sidebar'; // eslint-disable-line
|
||||||
|
|
||||||
import styles from './styles.css';
|
import styles from './styles.css';
|
||||||
|
@ -29,6 +30,7 @@ class Doc extends React.Component {
|
||||||
{language && <meta name="docsearch:language" content={language} />}
|
{language && <meta name="docsearch:language" content={language} />}
|
||||||
{version && <meta name="docsearch:version" content={version} />}
|
{version && <meta name="docsearch:version" content={version} />}
|
||||||
</Helmet>
|
</Helmet>
|
||||||
|
<Navbar docsMetadatas={docsMetadatas} />
|
||||||
<Sidebar
|
<Sidebar
|
||||||
docsMetadatas={docsMetadatas}
|
docsMetadatas={docsMetadatas}
|
||||||
docsSidebars={docsSidebars}
|
docsSidebars={docsSidebars}
|
||||||
|
|
|
@ -86,7 +86,7 @@ function Footer(props) {
|
||||||
{Object.values(props.docsMetadatas).map(metadata => (
|
{Object.values(props.docsMetadatas).map(metadata => (
|
||||||
<li key={metadata.permalink} className={styles.footerListItem}>
|
<li key={metadata.permalink} className={styles.footerListItem}>
|
||||||
<Link className={styles.footerLink} to={metadata.permalink}>
|
<Link className={styles.footerLink} to={metadata.permalink}>
|
||||||
{metadata.permalink}
|
{metadata.title}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Footer from '@theme/Footer'; // eslint-disable-line
|
import Footer from '@theme/Footer'; // eslint-disable-line
|
||||||
|
import Navbar from '@theme/Navbar'; // eslint-disable-line
|
||||||
|
|
||||||
import './styles.css';
|
import './styles.css';
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ export default class Layout extends React.Component {
|
||||||
} = this.props;
|
} = this.props;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
<Navbar docsMetadatas={docsMetadatas} />
|
||||||
{children}
|
{children}
|
||||||
<Footer
|
<Footer
|
||||||
docsMetadatas={docsMetadatas}
|
docsMetadatas={docsMetadatas}
|
||||||
|
|
37
v2/lib/theme/Navbar/index.js
Normal file
37
v2/lib/theme/Navbar/index.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import React from 'react';
|
||||||
|
import {NavLink} from 'react-router-dom';
|
||||||
|
|
||||||
|
import styles from './styles.css';
|
||||||
|
|
||||||
|
function Navbar(props) {
|
||||||
|
return (
|
||||||
|
<nav className={styles.navbar}>
|
||||||
|
<div className={styles.navbarInner}>
|
||||||
|
<ul className={styles.navList}>
|
||||||
|
<li className={styles.navListItem}>
|
||||||
|
<NavLink className={styles.navBrand} to="/">
|
||||||
|
<img
|
||||||
|
alt="Docusaurus Logo"
|
||||||
|
className={styles.navLogo}
|
||||||
|
src="/img/docusaurus-logo.svg"
|
||||||
|
/>
|
||||||
|
<strong>Docusaurus</strong>
|
||||||
|
</NavLink>
|
||||||
|
</li>
|
||||||
|
{Object.values(props.docsMetadatas).map(metadata => (
|
||||||
|
<li key={metadata.permalink} className={styles.navListItem}>
|
||||||
|
<NavLink
|
||||||
|
activeClassName={styles.navLinkActive}
|
||||||
|
className={styles.navLink}
|
||||||
|
to={metadata.permalink}>
|
||||||
|
{metadata.title}
|
||||||
|
</NavLink>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Navbar;
|
64
v2/lib/theme/Navbar/styles.css
Normal file
64
v2/lib/theme/Navbar/styles.css
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
.navbar {
|
||||||
|
height: 60px;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbarInner {
|
||||||
|
align-items: center;
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
display: flex;
|
||||||
|
height: inherit;
|
||||||
|
justify-content: flex-start;
|
||||||
|
position: fixed;
|
||||||
|
width: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navBrand {
|
||||||
|
color: #1c1e21;
|
||||||
|
font-size: 1.2em;
|
||||||
|
padding: 1em;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navLogo {
|
||||||
|
height: 40px;
|
||||||
|
margin-right: 12px;
|
||||||
|
vertical-align: middle;
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navList {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navListItem {
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navLink {
|
||||||
|
border-radius: 6px;
|
||||||
|
color: #1c1e21;
|
||||||
|
display: block;
|
||||||
|
padding: 1em 1.2em;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: background-color 200ms cubic-bezier(0.08, 0.52, 0.52, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navLink:hover {
|
||||||
|
background-color: #f5f6f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navLinkActive {
|
||||||
|
border-bottom: 4px solid #00a388;
|
||||||
|
border-radius: 0;
|
||||||
|
color: #00a388;
|
||||||
|
margin-bottom: -4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navLinkActive:hover {
|
||||||
|
background-color: inherit;
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Link} from 'react-router-dom';
|
import {NavLink} from 'react-router-dom';
|
||||||
|
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import styles from './styles.css';
|
||||||
|
|
||||||
function Sidebar(props) {
|
function Sidebar(props) {
|
||||||
const {metadata, docsSidebars, docsMetadatas} = props;
|
const {metadata, docsSidebars, docsMetadatas} = props;
|
||||||
const {sidebar, language, id: thisID} = metadata;
|
const {sidebar, language} = metadata;
|
||||||
if (!sidebar || !docsSidebars) {
|
if (!sidebar || !docsSidebars) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,15 @@ function Sidebar(props) {
|
||||||
`Improper sidebars.json file, document with id '${linkID}' not found.`,
|
`Improper sidebars.json file, document with id '${linkID}' not found.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const activeItem = linkID === thisID;
|
|
||||||
return (
|
return (
|
||||||
<li key={linkID}>
|
<li key={linkID}>
|
||||||
<Link
|
<NavLink
|
||||||
className={classnames(styles.sidebarLink, styles.sidebarItem, {
|
activeClassName={styles.sidebarLinkActive}
|
||||||
[styles.sidebarLinkActive]: activeItem,
|
className={classnames(styles.sidebarLink, styles.sidebarItem)}
|
||||||
})}
|
|
||||||
to={linkMetadata.permalink}>
|
to={linkMetadata.permalink}>
|
||||||
{linkMetadata.sidebar_label || linkMetadata.title}
|
{linkMetadata.sidebar_label || linkMetadata.title}
|
||||||
</Link>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -40,7 +39,11 @@ function Sidebar(props) {
|
||||||
return (
|
return (
|
||||||
<div className={styles.sidebarGroup} key={categoryName}>
|
<div className={styles.sidebarGroup} key={categoryName}>
|
||||||
<h3
|
<h3
|
||||||
className={classnames(styles.sidebarGroupTitle, styles.sidebarItem)}>
|
className={classnames(
|
||||||
|
styles.sidebarItem,
|
||||||
|
styles.sidebarGroupTitle,
|
||||||
|
styles.sidebarGroupCategoryTitle,
|
||||||
|
)}>
|
||||||
{categoryName}
|
{categoryName}
|
||||||
</h3>
|
</h3>
|
||||||
<ul className={styles.sidebarList}>
|
<ul className={styles.sidebarList}>
|
||||||
|
@ -50,9 +53,9 @@ function Sidebar(props) {
|
||||||
<div className={styles.sidebarSubGroup} key={subCategoryName}>
|
<div className={styles.sidebarSubGroup} key={subCategoryName}>
|
||||||
<h4
|
<h4
|
||||||
className={classnames(
|
className={classnames(
|
||||||
styles.sidebarGroupTitle,
|
|
||||||
styles.sidebarGroupSubtitle,
|
|
||||||
styles.sidebarItem,
|
styles.sidebarItem,
|
||||||
|
styles.sidebarGroupTitle,
|
||||||
|
styles.sidebarGroupSubcategorytitle,
|
||||||
)}>
|
)}>
|
||||||
{subCategoryName}
|
{subCategoryName}
|
||||||
</h4>
|
</h4>
|
||||||
|
|
|
@ -7,33 +7,38 @@
|
||||||
position: fixed;
|
position: fixed;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
top: 0;
|
top: 60px;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebarGroupTitle {
|
|
||||||
font-size: 1em;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebarGroupSubtitle {
|
|
||||||
color: rgb(96, 103, 112);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebarList {
|
|
||||||
margin: 0;
|
|
||||||
list-style-type: none;
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebarItem {
|
.sidebarItem {
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebarGroupTitle {
|
||||||
|
font-size: 1em;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebarGroupCategoryTitle {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebarGroupSubcategorytitle {
|
||||||
|
color: rgb(96, 103, 112);
|
||||||
|
font-size: 0.875em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebarList {
|
||||||
|
margin: 0;
|
||||||
|
list-style-type: none;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebarLink {
|
.sidebarLink {
|
||||||
border-radius: 4px;
|
border-radius: 6px;
|
||||||
color: #717171;
|
color: #717171;
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 0.875em;
|
font-size: 0.875em;
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
{
|
{
|
||||||
"docs": {
|
"docs": {
|
||||||
"Foo": {
|
"Category 1": {
|
||||||
"bar": ["foo/bar"],
|
"Subcategory 1": ["foo/bar", "foo/baz"],
|
||||||
"baz": ["foo/baz"]
|
"Subcategory 2": ["hello"]
|
||||||
},
|
},
|
||||||
"Endi": [
|
"Category 2": ["intro", "code"]
|
||||||
"docusaurus",
|
|
||||||
"highlight",
|
|
||||||
"hello"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
v2/website/static/img/docusaurus-logo.svg
Normal file
1
v2/website/static/img/docusaurus-logo.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 6.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue