mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 19:03:38 +02:00
Add comments
This commit is contained in:
parent
df0f95e36f
commit
43ef3c8142
22 changed files with 114 additions and 62 deletions
|
@ -14,6 +14,7 @@ const MetadataBlog = require("./MetadataBlog.js");
|
|||
const React = require("react");
|
||||
const Site = require("./Site.js");
|
||||
|
||||
// used to generate entire blog pages, i.e. collection of truncated blog posts
|
||||
const BlogPageLayout = React.createClass({
|
||||
getPageURL(page) {
|
||||
let url = this.props.config.baseUrl + "blog/";
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
const Marked = require("./Marked.js");
|
||||
const React = require("react");
|
||||
|
||||
// inner blog component for the article itself, without sidebar/header/footer
|
||||
class BlogPost extends React.Component {
|
||||
renderContent() {
|
||||
let content = this.props.content;
|
||||
|
|
|
@ -13,6 +13,7 @@ const BlogSidebar = require("./BlogSidebar.js");
|
|||
const Container = require("./Container.js");
|
||||
const Site = require("./Site.js");
|
||||
|
||||
// used for entire blog posts, i.e., each written blog article with sidebar with site header/footer
|
||||
class BlogPostLayout extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
|
|
|
@ -11,6 +11,7 @@ const Marked = require("./Marked.js");
|
|||
const Container = require("./Container.js");
|
||||
const GridBlock = require("./GridBlock.js");
|
||||
|
||||
// collection of other components to provide to users
|
||||
module.exports = {
|
||||
Marked: Marked,
|
||||
Container: Container,
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
const React = require("react");
|
||||
const Marked = require("./Marked.js");
|
||||
|
||||
// inner doc component for article itself
|
||||
class Doc extends React.Component {
|
||||
render() {
|
||||
let editLink =
|
||||
|
|
|
@ -14,6 +14,7 @@ const DocsSidebar = require("./DocsSidebar.js");
|
|||
const Site = require("./Site.js");
|
||||
const translation = require("../server/translation.js");
|
||||
|
||||
// component used to generate whole webpage for docs, including sidebar/header/footer
|
||||
class DocsLayout extends React.Component {
|
||||
render() {
|
||||
const metadata = this.props.metadata;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
const React = require("react");
|
||||
|
||||
// html head for each page
|
||||
class Head extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/* Marked component is used to parse markdown to html */
|
||||
|
||||
const React = require("react");
|
||||
const Prism = require("./Prism.js");
|
||||
const Header = require("./Header.js");
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/* Prism is used by Marked to do code syntas highlighting */
|
||||
|
||||
const React = require("react");
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,23 +16,8 @@ const translation = require("../server/translation.js");
|
|||
|
||||
const CWD = process.cwd();
|
||||
|
||||
// Component used to provide same head, header, footer, other scripts to all pages
|
||||
class Site extends React.Component {
|
||||
/*
|
||||
goes in body after navPusher
|
||||
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
|
||||
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)
|
||||
){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";
|
||||
fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
|
||||
*/
|
||||
|
||||
render() {
|
||||
const tagline = translation[this.props.language]
|
||||
? translation[this.props.language]["localized-strings"].tagline
|
||||
|
|
|
@ -23,11 +23,12 @@ if (ENABLE_VERSIONING) {
|
|||
require("../../server/readMetadata.js").generateDocsMetadata();
|
||||
const Metadata = require("../metadata.js");
|
||||
|
||||
// language dropdown nav item for when translations are enabled
|
||||
class LanguageDropDown extends React.Component {
|
||||
render() {
|
||||
const enabledLanguages = [];
|
||||
let currentLanguage = "English";
|
||||
|
||||
// add all enabled languages to dropdown
|
||||
translation["languages"].map(lang => {
|
||||
if (lang.tag == this.props.language) {
|
||||
currentLanguage = lang.name;
|
||||
|
@ -43,11 +44,11 @@ class LanguageDropDown extends React.Component {
|
|||
</li>
|
||||
);
|
||||
});
|
||||
|
||||
// if no languages are enabled besides English, return null
|
||||
if (enabledLanguages.length < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// add Crowdin project recruiting link
|
||||
if (siteConfig.recruitingLink) {
|
||||
enabledLanguages.push(
|
||||
<li key="recruiting">
|
||||
|
@ -94,6 +95,7 @@ class LanguageDropDown extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
// header navbar used by all pages generated with docusaurus
|
||||
class HeaderNav extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -101,10 +103,11 @@ class HeaderNav extends React.Component {
|
|||
slideoutActive: false
|
||||
};
|
||||
}
|
||||
|
||||
// function to generate each header link, used with each object in siteConfig.headerLinks
|
||||
makeLinks(link) {
|
||||
let href;
|
||||
if (link.search && this.props.config.algolia) {
|
||||
// return algolia search bar
|
||||
return (
|
||||
<li className="navSearchWrapper reactNavSearchWrapper">
|
||||
<input id="search_input_react" type="text" placeholder="Search" />
|
||||
|
@ -112,12 +115,14 @@ class HeaderNav extends React.Component {
|
|||
);
|
||||
} else if (link.languages) {
|
||||
return (
|
||||
// return language dropdown
|
||||
<LanguageDropDown
|
||||
baseUrl={this.props.baseUrl}
|
||||
language={this.props.language}
|
||||
/>
|
||||
);
|
||||
} else if (link.doc) {
|
||||
// set link to document with current page's language/version
|
||||
let id;
|
||||
if (!ENABLE_VERSIONING || this.props.version === "next") {
|
||||
id = this.props.language + "-" + link.doc;
|
||||
|
@ -137,6 +142,7 @@ class HeaderNav extends React.Component {
|
|||
}
|
||||
href = this.props.config.baseUrl + Metadata[id].permalink;
|
||||
} else if (link.page) {
|
||||
// set link to page with current page's language if appropriate
|
||||
if (fs.existsSync(CWD + "/pages/en/" + link.page + ".js")) {
|
||||
href =
|
||||
siteConfig.baseUrl + this.props.language + "/" + link.page + ".html";
|
||||
|
@ -144,8 +150,10 @@ class HeaderNav extends React.Component {
|
|||
href = siteConfig.baseUrl + link.page + ".html";
|
||||
}
|
||||
} else if (link.href) {
|
||||
// set link to specified href
|
||||
href = link.href;
|
||||
} else if (link.blog) {
|
||||
// set link to blog url
|
||||
href = this.props.baseUrl + "blog";
|
||||
}
|
||||
return (
|
||||
|
|
|
@ -61,6 +61,7 @@ class SideNav extends React.Component {
|
|||
</div>
|
||||
);
|
||||
}
|
||||
// return appropriately translated category string
|
||||
getLocalizedCategoryString(category) {
|
||||
let categoryString = translation[this.props.language]
|
||||
? translation[this.props.language]["localized-strings"][category] ||
|
||||
|
@ -68,6 +69,7 @@ class SideNav extends React.Component {
|
|||
: category;
|
||||
return categoryString;
|
||||
}
|
||||
// return appropriately translated label to use for doc/blog in sidebar
|
||||
getLocalizedString(metadata) {
|
||||
let localizedString;
|
||||
const i18n = translation[this.props.language];
|
||||
|
@ -85,6 +87,7 @@ class SideNav extends React.Component {
|
|||
}
|
||||
return localizedString;
|
||||
}
|
||||
// return link to doc in sidebar
|
||||
getLink(metadata) {
|
||||
if (metadata.permalink) {
|
||||
if (metadata.permalink.match(/^https?:/)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue