mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-10 23:02:56 +02:00
feat: allow custom docsUrl & custom permalink
This commit is contained in:
parent
185f7b1ed1
commit
b99605f725
12 changed files with 270 additions and 177 deletions
|
@ -1,30 +1,12 @@
|
|||
const {idx} = require('./utils');
|
||||
|
||||
async function genRoutesConfig({
|
||||
docsData = {},
|
||||
pagesData = [],
|
||||
env,
|
||||
siteConfig
|
||||
}) {
|
||||
async function genRoutesConfig({docsData = {}, pagesData = []}) {
|
||||
function genDocsRoute(metadata) {
|
||||
const {permalink, source, version, language} = metadata;
|
||||
const defaultLanguage = idx(env, ['translation', 'defaultLanguage']);
|
||||
let importPath = `@docs/${source}`;
|
||||
if (language && language !== defaultLanguage.tag) {
|
||||
importPath = `@translated_docs/${source}`;
|
||||
} else if (version && version !== 'next') {
|
||||
importPath = `@versioned_docs/${source}`;
|
||||
}
|
||||
|
||||
const {baseUrl} = siteConfig;
|
||||
const docsPath = `${baseUrl}${permalink}`;
|
||||
|
||||
const {permalink, source} = metadata;
|
||||
return `
|
||||
{
|
||||
path: ${JSON.stringify(docsPath)},
|
||||
path: ${JSON.stringify(permalink)},
|
||||
exact: true,
|
||||
component: Loadable({
|
||||
loader: () => import(${JSON.stringify(importPath)}),
|
||||
loader: () => import(${JSON.stringify(source)}),
|
||||
loading: Loading,
|
||||
render(loaded, props) {
|
||||
let Content = loaded.default;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue