mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 09:07:29 +02:00
feat(content-docs): allow SEO metadata for category index pages (#6239)
This commit is contained in:
parent
e1d1618039
commit
3cb99124de
8 changed files with 31 additions and 2 deletions
|
@ -28,6 +28,8 @@ function getCategoryGeneratedIndexMetadata({
|
||||||
return {
|
return {
|
||||||
title: category.link.title ?? category.label,
|
title: category.link.title ?? category.label,
|
||||||
description: category.link.description,
|
description: category.link.description,
|
||||||
|
image: category.link.image,
|
||||||
|
keywords: category.link.keywords,
|
||||||
slug: category.link.slug,
|
slug: category.link.slug,
|
||||||
permalink: category.link.permalink,
|
permalink: category.link.permalink,
|
||||||
sidebar: sidebarName,
|
sidebar: sidebarName,
|
||||||
|
|
|
@ -42,6 +42,8 @@ declare module '@docusaurus/plugin-content-docs' {
|
||||||
export type PropCategoryGeneratedIndex = {
|
export type PropCategoryGeneratedIndex = {
|
||||||
title: string;
|
title: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
image?: string;
|
||||||
|
keywords?: string | readonly string[];
|
||||||
slug: string;
|
slug: string;
|
||||||
permalink: string;
|
permalink: string;
|
||||||
navigation: PropNavigation;
|
navigation: PropNavigation;
|
||||||
|
|
|
@ -30,8 +30,17 @@ export async function createCategoryGeneratedIndexRoutes({
|
||||||
async function createCategoryGeneratedIndexRoute(
|
async function createCategoryGeneratedIndexRoute(
|
||||||
categoryGeneratedIndex: CategoryGeneratedIndexMetadata,
|
categoryGeneratedIndex: CategoryGeneratedIndexMetadata,
|
||||||
): Promise<RouteConfig> {
|
): Promise<RouteConfig> {
|
||||||
const {sidebar, title, description, slug, permalink, previous, next} =
|
const {
|
||||||
categoryGeneratedIndex;
|
sidebar,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
slug,
|
||||||
|
permalink,
|
||||||
|
previous,
|
||||||
|
next,
|
||||||
|
image,
|
||||||
|
keywords,
|
||||||
|
} = categoryGeneratedIndex;
|
||||||
|
|
||||||
const propFileName = slugs.slug(
|
const propFileName = slugs.slug(
|
||||||
`${version.versionPath}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`,
|
`${version.versionPath}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`,
|
||||||
|
@ -42,6 +51,8 @@ export async function createCategoryGeneratedIndexRoutes({
|
||||||
description,
|
description,
|
||||||
slug,
|
slug,
|
||||||
permalink,
|
permalink,
|
||||||
|
image,
|
||||||
|
keywords,
|
||||||
navigation: {
|
navigation: {
|
||||||
previous,
|
previous,
|
||||||
next,
|
next,
|
||||||
|
|
|
@ -52,6 +52,8 @@ export type SidebarItemCategoryLinkGeneratedIndexConfig = {
|
||||||
slug?: string;
|
slug?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
image?: string;
|
||||||
|
keywords?: string | readonly string[];
|
||||||
};
|
};
|
||||||
export type SidebarItemCategoryLinkGeneratedIndex = {
|
export type SidebarItemCategoryLinkGeneratedIndex = {
|
||||||
type: 'generated-index';
|
type: 'generated-index';
|
||||||
|
@ -59,6 +61,8 @@ export type SidebarItemCategoryLinkGeneratedIndex = {
|
||||||
permalink: string;
|
permalink: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
image?: string;
|
||||||
|
keywords?: string | readonly string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SidebarItemCategoryLinkConfig =
|
export type SidebarItemCategoryLinkConfig =
|
||||||
|
|
|
@ -70,6 +70,8 @@ const sidebarItemCategoryLinkSchema = Joi.object<SidebarItemCategoryLink>()
|
||||||
// permalink: Joi.string().optional(), // No, this one is not in the user config, only in the normalized version
|
// permalink: Joi.string().optional(), // No, this one is not in the user config, only in the normalized version
|
||||||
title: Joi.string().optional(),
|
title: Joi.string().optional(),
|
||||||
description: Joi.string().optional(),
|
description: Joi.string().optional(),
|
||||||
|
image: Joi.string().optional(),
|
||||||
|
keywords: [Joi.string(), Joi.array().items(Joi.string())],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -174,6 +174,8 @@ export type CategoryGeneratedIndexMetadata = {
|
||||||
sidebar: string;
|
sidebar: string;
|
||||||
previous?: DocNavLink;
|
previous?: DocNavLink;
|
||||||
next?: DocNavLink;
|
next?: DocNavLink;
|
||||||
|
image?: string;
|
||||||
|
keywords?: string | readonly string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SourceToPermalink = {
|
export type SourceToPermalink = {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import Seo from '@theme/Seo';
|
||||||
import DocVersionBanner from '@theme/DocVersionBanner';
|
import DocVersionBanner from '@theme/DocVersionBanner';
|
||||||
import DocVersionBadge from '@theme/DocVersionBadge';
|
import DocVersionBadge from '@theme/DocVersionBadge';
|
||||||
import {MainHeading} from '@theme/Heading';
|
import {MainHeading} from '@theme/Heading';
|
||||||
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
|
|
||||||
import styles from './styles.module.css';
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
|
@ -26,6 +27,9 @@ export default function DocCategoryGeneratedIndexPage({
|
||||||
<Seo
|
<Seo
|
||||||
title={categoryGeneratedIndex.title}
|
title={categoryGeneratedIndex.title}
|
||||||
description={categoryGeneratedIndex.description}
|
description={categoryGeneratedIndex.description}
|
||||||
|
keywords={categoryGeneratedIndex.keywords}
|
||||||
|
// TODO `require` this?
|
||||||
|
image={useBaseUrl(categoryGeneratedIndex.image)}
|
||||||
/>
|
/>
|
||||||
<div className={styles.generatedIndexPage}>
|
<div className={styles.generatedIndexPage}>
|
||||||
<DocVersionBanner />
|
<DocVersionBanner />
|
||||||
|
|
|
@ -33,6 +33,8 @@ const sidebars = {
|
||||||
title: 'Docusaurus Guides',
|
title: 'Docusaurus Guides',
|
||||||
description:
|
description:
|
||||||
"Let's learn about the most important Docusaurus concepts!",
|
"Let's learn about the most important Docusaurus concepts!",
|
||||||
|
keywords: ['guides'],
|
||||||
|
image: '/img/docusaurus.png',
|
||||||
},
|
},
|
||||||
items: [
|
items: [
|
||||||
'guides/creating-pages',
|
'guides/creating-pages',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue