mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-30 18:58:36 +02:00
* Allow other routes than /docs in the URL siteConfig.js has a new mandatory field named *docsRoute* which default value is 'docs' and that can be customized by the user. This change will allow users who uses the library to host guides and tutorials to customize their websites by assign 'docsRoute' values like 'tutorials' or 'guides'. Fixes #879 * Make "docsRoute" field optional * Isolate docsRoute login in getDocsRoute function * Rename docsRoute to docsUrl * Run prettier * Remove old folders * fix: Restore docusaurus reference link * fix: Add `docsUrl` param fallback. Refactor multiple function calls * Fix linting errors * Update description for docsUrl field * Reduce redundant calls to getDocsUrl * Replace a missed use case for `docsUrl` instead of the function call * Move `getDocsUrl` out from `server/routing.js` to `server/utils.js` **Why?** Because `routing.js` is exporting all router RegEx's, and the `getDocsUrl` suffices more as a util * WiP: Align leading slashes and fix routing around `docsUrl` Checklist: - [x] Added `removeDuplicateLeadingSlashes` util to make sure there is only one leading slash - [-] Fix edge cases for routing: - [x] `docsUrl: ''` - [ ] `docsUrl: '/'` - [ ] make it work with languages - [ ] make it work with versioning * Make leading slashes canonical cross routing and generated links This ensures correct routing for customized `baseUrl` and `docsUrl`. - Changed all routing functions to take `siteConfig` instead of `siteConfig.baseUrl` - Updated tests accordingly * Alternative fallback for `docsUrl` * rework/ fix implementation * cleanup * refactor and add docs for config props * fix typo * fix broken url
104 lines
3.2 KiB
JavaScript
104 lines
3.2 KiB
JavaScript
/**
|
|
* Copyright (c) 2017-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
const React = require('react');
|
|
|
|
class Footer extends React.Component {
|
|
docUrl(doc, language) {
|
|
const baseUrl = this.props.config.baseUrl;
|
|
const docsUrl = this.props.config.docsUrl;
|
|
const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`;
|
|
const langPart = `${language ? `${language}/` : ''}`;
|
|
return `${baseUrl}${docsPart}${langPart}${doc}`;
|
|
}
|
|
|
|
pageUrl(doc, language) {
|
|
const baseUrl = this.props.config.baseUrl;
|
|
return baseUrl + (language ? `${language}/` : '') + doc;
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<footer className="nav-footer" id="footer">
|
|
<section className="sitemap">
|
|
<a href={this.props.config.baseUrl} className="nav-home">
|
|
{this.props.config.footerIcon && (
|
|
<img
|
|
src={this.props.config.baseUrl + this.props.config.footerIcon}
|
|
alt={this.props.config.title}
|
|
width="66"
|
|
height="58"
|
|
/>
|
|
)}
|
|
</a>
|
|
<div>
|
|
<h5>Docs</h5>
|
|
<a href={this.docUrl('doc1.html', this.props.language)}>
|
|
Getting Started (or other categories)
|
|
</a>
|
|
<a href={this.docUrl('doc2.html', this.props.language)}>
|
|
Guides (or other categories)
|
|
</a>
|
|
<a href={this.docUrl('doc3.html', this.props.language)}>
|
|
API Reference (or other categories)
|
|
</a>
|
|
</div>
|
|
<div>
|
|
<h5>Community</h5>
|
|
<a href={this.pageUrl('users.html', this.props.language)}>
|
|
User Showcase
|
|
</a>
|
|
<a
|
|
href="http://stackoverflow.com/questions/tagged/"
|
|
target="_blank"
|
|
rel="noreferrer noopener">
|
|
Stack Overflow
|
|
</a>
|
|
<a href="https://discordapp.com/">Project Chat</a>
|
|
<a
|
|
href="https://twitter.com/"
|
|
target="_blank"
|
|
rel="noreferrer noopener">
|
|
Twitter
|
|
</a>
|
|
</div>
|
|
<div>
|
|
<h5>More</h5>
|
|
<a href={`${this.props.config.baseUrl}blog`}>Blog</a>
|
|
<a href="https://github.com/">GitHub</a>
|
|
<a
|
|
className="github-button"
|
|
href={this.props.config.repoUrl}
|
|
data-icon="octicon-star"
|
|
data-count-href="/facebook/docusaurus/stargazers"
|
|
data-show-count="true"
|
|
data-count-aria-label="# stargazers on GitHub"
|
|
aria-label="Star this project on GitHub">
|
|
Star
|
|
</a>
|
|
</div>
|
|
</section>
|
|
|
|
<a
|
|
href="https://code.facebook.com/projects/"
|
|
target="_blank"
|
|
rel="noreferrer noopener"
|
|
className="fbOpenSource">
|
|
<img
|
|
src={`${this.props.config.baseUrl}img/oss_logo.png`}
|
|
alt="Facebook Open Source"
|
|
width="170"
|
|
height="45"
|
|
/>
|
|
</a>
|
|
<section className="copyright">{this.props.config.copyright}</section>
|
|
</footer>
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = Footer;
|