mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-14 15:28:08 +02:00
feat(content-blog): allow disabling generating archive (#6415)
This commit is contained in:
parent
2a5407f6bd
commit
d506bca12d
4 changed files with 25 additions and 22 deletions
|
@ -242,25 +242,26 @@ export default async function pluginContentBlog(
|
|||
? blogPosts
|
||||
: blogPosts.slice(0, options.blogSidebarCount);
|
||||
|
||||
const archiveUrl = normalizeUrl([
|
||||
baseUrl,
|
||||
routeBasePath,
|
||||
archiveBasePath,
|
||||
]);
|
||||
|
||||
// creates a blog archive route
|
||||
const archiveProp = await createData(
|
||||
`${docuHash(archiveUrl)}.json`,
|
||||
JSON.stringify({blogPosts}, null, 2),
|
||||
);
|
||||
addRoute({
|
||||
path: archiveUrl,
|
||||
component: '@theme/BlogArchivePage',
|
||||
exact: true,
|
||||
modules: {
|
||||
archive: aliasedSource(archiveProp),
|
||||
},
|
||||
});
|
||||
if (archiveBasePath) {
|
||||
const archiveUrl = normalizeUrl([
|
||||
baseUrl,
|
||||
routeBasePath,
|
||||
archiveBasePath,
|
||||
]);
|
||||
// creates a blog archive route
|
||||
const archiveProp = await createData(
|
||||
`${docuHash(archiveUrl)}.json`,
|
||||
JSON.stringify({blogPosts}, null, 2),
|
||||
);
|
||||
addRoute({
|
||||
path: archiveUrl,
|
||||
component: '@theme/BlogArchivePage',
|
||||
exact: true,
|
||||
modules: {
|
||||
archive: aliasedSource(archiveProp),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// This prop is useful to provide the blog list sidebar
|
||||
const sidebarProp = await createData(
|
||||
|
|
|
@ -112,7 +112,7 @@ declare module '@docusaurus/plugin-content-blog' {
|
|||
path: string;
|
||||
routeBasePath: string;
|
||||
tagsBasePath: string;
|
||||
archiveBasePath: string;
|
||||
archiveBasePath: string | null;
|
||||
include: string[];
|
||||
exclude: string[];
|
||||
postsPerPage: number | 'ALL';
|
||||
|
|
|
@ -47,7 +47,9 @@ export const DEFAULT_OPTIONS: PluginOptions = {
|
|||
|
||||
export const PluginOptionSchema = Joi.object<PluginOptions>({
|
||||
path: Joi.string().default(DEFAULT_OPTIONS.path),
|
||||
archiveBasePath: Joi.string().default(DEFAULT_OPTIONS.archiveBasePath),
|
||||
archiveBasePath: Joi.string()
|
||||
.default(DEFAULT_OPTIONS.archiveBasePath)
|
||||
.allow(null),
|
||||
routeBasePath: Joi.string()
|
||||
// '' not allowed, see https://github.com/facebook/docusaurus/issues/3374
|
||||
// .allow('')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue