Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v2): blog + docs multi-instance plugins #3204

Merged
merged 17 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions packages/docusaurus-plugin-content-blog/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import kebabCase from 'lodash.kebabcase';
import path from 'path';
import admonitions from 'remark-admonitions';
import {normalizeUrl, docuHash, aliasedSitePath} from '@docusaurus/utils';
import {STATIC_DIR_NAME} from '@docusaurus/core/lib/constants';
import {
STATIC_DIR_NAME,
DEFAULT_PLUGIN_ID,
} from '@docusaurus/core/lib/constants';
import {ValidationError} from '@hapi/joi';

import {
Expand Down Expand Up @@ -48,11 +51,15 @@ export default function pluginContentBlog(

const {siteDir, generatedFilesDir} = context;
const contentPath = path.resolve(siteDir, options.path);
const dataDir = path.join(

const pluginDataDirRoot = path.join(
generatedFilesDir,
'docusaurus-plugin-content-blog',
// options.id ?? 'default', // TODO support multi-instance
);
const dataDir = path.join(pluginDataDirRoot, options.id ?? DEFAULT_PLUGIN_ID);
const aliasedSource = (source: string) =>
`~blog/${path.relative(pluginDataDirRoot, source)}`;

let blogPosts: BlogPost[] = [];

return {
Expand Down Expand Up @@ -206,8 +213,6 @@ export default function pluginContentBlog(
blogTagsPostsComponent,
} = options;

const aliasedSource = (source: string) =>
`~blog/${path.relative(dataDir, source)}`;
const {addRoute, createData} = actions;
const {
blogPosts: loadedBlogPosts,
Expand Down Expand Up @@ -349,7 +354,7 @@ export default function pluginContentBlog(
return {
resolve: {
alias: {
'~blog': dataDir,
'~blog': pluginDataDirRoot,
},
},
module: {
Expand All @@ -369,10 +374,10 @@ export default function pluginContentBlog(
// 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`,
);
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Team current version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"community": ["team"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Team 1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version-1.0.0/community": ["version-1.0.0/team"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["1.0.0"]
Loading