Skip to content

Commit 9ab62d3

Browse files
committed
docs: add twitter cards and application/ld+json to the blog, arhive and docs collection pages
1 parent 558eecf commit 9ab62d3

3 files changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React, {type ReactNode} from 'react';
2+
import BlogArchivePage from '@theme-original/BlogArchivePage';
3+
import type BlogArchivePageType from '@theme/BlogArchivePage';
4+
import type {WrapperProps} from '@docusaurus/types';
5+
import Head from '@docusaurus/Head';
6+
7+
type Props = WrapperProps<typeof BlogArchivePageType>;
8+
const BLOG_TITLE = 'AdminForth Blog Archive';
9+
const BLOG_DESCRIPTION = 'AdminForth blog archive page';
10+
11+
export default function BlogArchivePageWrapper(props: Props): ReactNode {
12+
const schema = {
13+
'@context': 'https://schema.org',
14+
'@type': 'CollectionPage',
15+
headline: BLOG_TITLE,
16+
description: BLOG_DESCRIPTION,
17+
url: `https://adminforth.dev/blog/archive/`,
18+
dateModified: new Date().toISOString(),
19+
};
20+
return (
21+
<>
22+
<Head>
23+
<script type="application/ld+json">{JSON.stringify(schema)}</script>
24+
<meta name="twitter:title" content={BLOG_TITLE} />
25+
<meta name="twitter:description" content={BLOG_DESCRIPTION} />
26+
</Head>
27+
<BlogArchivePage {...props} />
28+
</>
29+
);
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React, {type ReactNode} from 'react';
2+
import BlogLayout from '@theme-original/BlogLayout';
3+
import type BlogLayoutType from '@theme/BlogLayout';
4+
import type {WrapperProps} from '@docusaurus/types';
5+
import Head from '@docusaurus/Head';
6+
7+
type Props = WrapperProps<typeof BlogLayoutType>;
8+
const BLOG_TITLE = 'AdminForth Blog';
9+
const BLOG_DESCRIPTION = 'AdminForth blog posts';
10+
11+
export default function BlogLayoutWrapper(props: Props): ReactNode {
12+
const schema = {
13+
'@context': 'https://schema.org',
14+
'@type': 'CollectionPage',
15+
headline: BLOG_TITLE,
16+
description: BLOG_DESCRIPTION,
17+
url: `https://adminforth.dev/blog`,
18+
dateModified: new Date().toISOString(),
19+
};
20+
return (
21+
<>
22+
<Head>
23+
<script type="application/ld+json">{JSON.stringify(schema)}</script>
24+
<meta name="twitter:title" content={BLOG_TITLE} />
25+
<meta name="twitter:description" content={BLOG_DESCRIPTION} />
26+
</Head>
27+
<BlogLayout {...props} />
28+
</>
29+
);
30+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React, {type ReactNode} from 'react';
2+
import DocCategoryGeneratedIndexPage from '@theme-original/DocCategoryGeneratedIndexPage';
3+
import type DocCategoryGeneratedIndexPageType from '@theme/DocCategoryGeneratedIndexPage';
4+
import type {WrapperProps} from '@docusaurus/types';
5+
import Head from '@docusaurus/Head';
6+
7+
type Props = WrapperProps<typeof DocCategoryGeneratedIndexPageType>;
8+
9+
export default function DocCategoryGeneratedIndexPageWrapper(props: Props): ReactNode {
10+
const schema = {
11+
'@context': 'https://schema.org',
12+
'@type': 'CollectionPage',
13+
headline: props.categoryGeneratedIndex.title,
14+
description: props.categoryGeneratedIndex.description,
15+
url: `https://adminforth.dev${props.categoryGeneratedIndex.permalink}`,
16+
dateModified: new Date().toISOString(),
17+
};
18+
return (
19+
<>
20+
<Head>
21+
<script type="application/ld+json">{JSON.stringify(schema)}</script>
22+
<meta name="twitter:title" content={props.categoryGeneratedIndex.title} />
23+
<meta name="twitter:description" content={props.categoryGeneratedIndex.description} />
24+
</Head>
25+
<DocCategoryGeneratedIndexPage {...props} />
26+
</>
27+
);
28+
}

0 commit comments

Comments
 (0)