mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
fix(v2): refactor routes.ts + add route hash for chunkNames key (#3001)
* add simpleHash util * refactor/split the routes generation logic + add route hash to avoid chunk conflicts * minor fixes + fix tests * fix comment typo
This commit is contained in:
parent
984e2d4598
commit
cf97662eef
6 changed files with 161 additions and 149 deletions
|
@ -381,23 +381,18 @@ Available document ids=
|
|||
// (/docs, /docs/next, /docs/1.0 etc...)
|
||||
// The component applies the layout and renders the appropriate doc
|
||||
const addBaseRoute = async (
|
||||
docsBaseRoute: string,
|
||||
docsBasePath: string,
|
||||
docsBaseMetadata: DocsBaseMetadata,
|
||||
routes: RouteConfig[],
|
||||
priority?: number,
|
||||
) => {
|
||||
const docsBaseMetadataPath = await createData(
|
||||
`${docuHash(normalizeUrl([docsBaseRoute, ':route']))}.json`,
|
||||
`${docuHash(normalizeUrl([docsBasePath, ':route']))}.json`,
|
||||
JSON.stringify(docsBaseMetadata, null, 2),
|
||||
);
|
||||
|
||||
// Important: the layout component should not end with /,
|
||||
// as it conflicts with the home doc
|
||||
// Workaround fix for https://github.com/facebook/docusaurus/issues/2917
|
||||
const docsPath = docsBaseRoute === '/' ? '' : docsBaseRoute;
|
||||
|
||||
addRoute({
|
||||
path: docsPath,
|
||||
path: docsBasePath,
|
||||
exact: false, // allow matching /docs/* as well
|
||||
component: docLayoutComponent, // main docs component (DocPage)
|
||||
routes, // subroute for each doc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue