Skip to content

Commit

Permalink
Docusaurus: metadata compatible with our existing frontmatter (#5846)
Browse files Browse the repository at this point in the history
* make docusaurus metadata compatible with our existing frontmatter
  • Loading branch information
jharrell authored Apr 10, 2024
1 parent 6402622 commit 56456a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 0 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ const config: Config = {
} satisfies Preset.Options
],
],

themeConfig: {
image: '/docs/social/docs-social.png',
navbar: {
Expand Down
23 changes: 23 additions & 0 deletions src/theme/DocItem/Metadata/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { PageMetadata } from '@docusaurus/theme-common';
import { useDoc } from '@docusaurus/theme-common/internal';

import type { DocFrontMatter } from '@docusaurus/plugin-content-docs'

type PrismaDocFrontMatter = DocFrontMatter & {
metaTitle?: string,
metaDescription?: string,
}

export default function DocItemMetadata(): JSX.Element {
const { metadata, frontMatter, assets } = useDoc();
const prismaFrontMatter = frontMatter as PrismaDocFrontMatter;
return (
<PageMetadata
title={prismaFrontMatter.metaTitle ?? prismaFrontMatter.title ?? metadata.title}
description={prismaFrontMatter.metaDescription ?? metadata.description}
keywords={frontMatter.keywords}
image={assets.image ?? frontMatter.image}
/>
);
}

0 comments on commit 56456a0

Please sign in to comment.