mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-06 04:42:40 +02:00
feat: make tags route path configurable (#5545)
This commit is contained in:
parent
ba402e9e63
commit
29e06d0677
11 changed files with 28 additions and 4 deletions
|
@ -40,6 +40,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
const userOptions = {
|
||||
path: 'my-docs', // Path to data on filesystem, relative to site dir.
|
||||
routeBasePath: 'my-docs', // URL Route.
|
||||
tagsBasePath: 'tags', // URL Tags Route.
|
||||
homePageId: 'home', // Document id for docs home page.
|
||||
include: ['**/*.{md,mdx}'], // Extensions to include.
|
||||
exclude: GlobExcludeDefault,
|
||||
|
|
|
@ -26,6 +26,7 @@ import {
|
|||
export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
||||
path: 'docs', // Path to data on filesystem, relative to site dir.
|
||||
routeBasePath: 'docs', // URL Route.
|
||||
tagsBasePath: 'tags', // URL Tags Route.
|
||||
homePageId: undefined, // TODO remove soon, deprecated
|
||||
include: ['**/*.{md,mdx}'], // Extensions to include.
|
||||
exclude: GlobExcludeDefault,
|
||||
|
@ -73,6 +74,7 @@ export const OptionsSchema = Joi.object({
|
|||
// '' not allowed, see https://github.com/facebook/docusaurus/issues/3374
|
||||
// .allow('') ""
|
||||
.default(DEFAULT_OPTIONS.routeBasePath),
|
||||
tagsBasePath: Joi.string().default(DEFAULT_OPTIONS.tagsBasePath),
|
||||
homePageId: Joi.string().optional(),
|
||||
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
||||
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),
|
||||
|
|
|
@ -101,6 +101,7 @@ export type PluginOptions = MetadataOptions &
|
|||
disableVersioning: boolean;
|
||||
includeCurrentVersion: boolean;
|
||||
sidebarItemsGenerator: SidebarItemsGeneratorOption;
|
||||
tagsBasePath: string;
|
||||
};
|
||||
|
||||
export type SidebarItemBase = {
|
||||
|
|
|
@ -349,6 +349,7 @@ function createVersionMetadata({
|
|||
| 'path'
|
||||
| 'sidebarPath'
|
||||
| 'routeBasePath'
|
||||
| 'tagsBasePath'
|
||||
| 'versions'
|
||||
| 'editUrl'
|
||||
| 'editCurrentVersion'
|
||||
|
@ -400,7 +401,7 @@ function createVersionMetadata({
|
|||
|
||||
// the path that will be used to refer the docs tags
|
||||
// example below will be using /docs/tags
|
||||
const tagsPath = normalizeUrl([versionPath, 'tags']);
|
||||
const tagsPath = normalizeUrl([versionPath, options.tagsBasePath]);
|
||||
|
||||
return {
|
||||
versionName,
|
||||
|
@ -561,6 +562,7 @@ export function readVersionsMetadata({
|
|||
| 'path'
|
||||
| 'sidebarPath'
|
||||
| 'routeBasePath'
|
||||
| 'tagsBasePath'
|
||||
| 'includeCurrentVersion'
|
||||
| 'disableVersioning'
|
||||
| 'lastVersion'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue