mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-18 11:36:53 +02:00
feat(v2): blog + docs multi-instance plugins (#3204)
* stable createData namespacing + second-blog dogfooding * Docs: support multi-instance + make community docs a separate instance * tests: add 2nd docs instance to versioned site * fix docs version cli tests * fix docs versioning cli * typo * team: add link to my site * better extendCli integration * fix metadata tests * tests for versioned site with second docs instance * move some validation code to utils-validation * fix missing dependency * fix bad compiled output due to importing constants in ./client folder * make docs tests easier to maintain * refactors * prevent lodash imports in client bundle * redirect old community docs to new urls
This commit is contained in:
parent
e944f35640
commit
59f705ee66
67 changed files with 2025 additions and 2059 deletions
|
@ -25,6 +25,7 @@ import {Configuration, Loader} from 'webpack';
|
|||
import admonitions from 'remark-admonitions';
|
||||
import {PluginOptionSchema} from './pluginOptionSchema';
|
||||
import {ValidationError} from '@hapi/joi';
|
||||
import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
|
||||
|
||||
import {PluginOptions, LoadedContent, Metadata} from './types';
|
||||
|
||||
|
@ -44,10 +45,11 @@ export default function pluginContentPages(
|
|||
|
||||
const contentPath = path.resolve(siteDir, options.path);
|
||||
|
||||
const dataDir = path.join(
|
||||
const pluginDataDirRoot = path.join(
|
||||
generatedFilesDir,
|
||||
'docusaurus-plugin-content-pages',
|
||||
);
|
||||
const dataDir = path.join(pluginDataDirRoot, options.id ?? DEFAULT_PLUGIN_ID);
|
||||
|
||||
return {
|
||||
name: 'docusaurus-plugin-content-pages',
|
||||
|
@ -83,20 +85,20 @@ export default function pluginContentPages(
|
|||
|
||||
function toMetadata(relativeSource: string): Metadata {
|
||||
const source = path.join(pagesDir, relativeSource);
|
||||
const aliasedSource = aliasedSitePath(source, siteDir);
|
||||
const aliasedSourcePath = aliasedSitePath(source, siteDir);
|
||||
const pathName = encodePath(fileToPath(relativeSource));
|
||||
const permalink = pathName.replace(/^\//, baseUrl || '');
|
||||
if (isMarkdownSource(relativeSource)) {
|
||||
return {
|
||||
type: 'mdx',
|
||||
permalink,
|
||||
source: aliasedSource,
|
||||
source: aliasedSourcePath,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
type: 'jsx',
|
||||
permalink,
|
||||
source: aliasedSource,
|
||||
source: aliasedSourcePath,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +154,7 @@ export default function pluginContentPages(
|
|||
return {
|
||||
resolve: {
|
||||
alias: {
|
||||
'~pages': dataDir,
|
||||
'~pages': pluginDataDirRoot,
|
||||
},
|
||||
},
|
||||
module: {
|
||||
|
@ -171,10 +173,10 @@ export default function pluginContentPages(
|
|||
// Note that metadataPath must be the same/in-sync as
|
||||
// the path from createData for each MDX.
|
||||
metadataPath: (mdxPath: string) => {
|
||||
const aliasedSource = aliasedSitePath(mdxPath, siteDir);
|
||||
const aliasedPath = aliasedSitePath(mdxPath, siteDir);
|
||||
return path.join(
|
||||
dataDir,
|
||||
`${docuHash(aliasedSource)}.json`,
|
||||
`${docuHash(aliasedPath)}.json`,
|
||||
);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
export interface PluginOptions {
|
||||
id?: string;
|
||||
path: string;
|
||||
routeBasePath: string;
|
||||
include: string[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue