1
+ import Head from "next/head" ;
1
2
import React from "react" ;
2
3
import styles from "../../public/styles/content.module.css" ;
4
+ import Author from "../components/Author" ;
5
+ import Copyright from "../components/Copyright" ;
3
6
import Date from "../components/Date" ;
4
7
import Layout from "../components/Layout" ;
5
- import TagButton from "../components/TagButton" ;
6
- import { getTag } from "../lib/tags" ;
8
+ import BasicMeta from "../components/meta/BasicMeta" ;
9
+ import JsonLdMeta from "../components/meta/JsonLdMeta" ;
10
+ import OpenGraphMeta from "../components/meta/OpenGraphMeta" ;
11
+ import TwitterCardMeta from "../components/meta/TwitterCardMeta" ;
7
12
import { SocialList } from "../components/SocialList" ;
8
- import Copyright from "../components/Copyright" ;
9
- import Author from "../components/Author" ;
13
+ import TagButton from "../components/TagButton" ;
10
14
import { getAuthor } from "../lib/authors" ;
11
- import { BlogPosting } from "schema-dts" ;
12
- import { jsonLdScriptProps } from "react-schemaorg" ;
13
- import BasicMeta from "../components/meta/BasicMeta" ;
14
- import Head from "next/head" ;
15
+ import { getTag } from "../lib/tags" ;
15
16
16
17
type Props = {
17
18
title : string ;
18
19
date : string ;
19
20
slug : string ;
20
- tags ?: string [ ] ;
21
- author ?: string ;
21
+ description : string ;
22
+ tags : string [ ] ;
23
+ author : string ;
22
24
} ;
23
- export default function Index ( { title, date, slug, author, tags } : Props ) {
25
+ export default function Index ( {
26
+ title,
27
+ date,
28
+ slug,
29
+ author,
30
+ tags,
31
+ description,
32
+ } : Props ) {
33
+ const keywords = tags . map ( ( it ) => getTag ( it ) . name ) ;
34
+ const authorName = getAuthor ( author ) . name ;
24
35
return ( { children : content } ) => {
25
36
return (
26
37
< Layout >
27
38
< Head >
28
- < BasicMeta url = { `/posts/${ slug } ` } />
29
- < script
30
- { ...jsonLdScriptProps < BlogPosting > ( {
31
- "@context" : "https://schema.org" ,
32
- "@type" : "BlogPosting" ,
33
- mainEntityOfPage : "" ,
34
- headline : "" ,
35
- keywords : "" ,
36
- datePublished : "" ,
37
- dateModified : "" ,
38
- author : "" ,
39
- image : "" ,
40
- description : "" ,
41
- } ) }
39
+ < BasicMeta
40
+ url = { `/posts/${ slug } ` }
41
+ title = { title }
42
+ keywords = { keywords }
43
+ description = { description }
44
+ />
45
+ < TwitterCardMeta
46
+ url = { `/posts/${ slug } ` }
47
+ title = { title }
48
+ description = { description }
49
+ />
50
+ < OpenGraphMeta
51
+ url = { `/posts/${ slug } ` }
52
+ title = { title }
53
+ description = { description }
54
+ />
55
+ < JsonLdMeta
56
+ url = { `/posts/${ slug } ` }
57
+ title = { title }
58
+ keywords = { keywords }
59
+ dateString = { date }
60
+ author = { authorName }
61
+ description = { description }
42
62
/>
43
63
</ Head >
44
64
< div className = { "container" } >
@@ -50,18 +70,17 @@ export default function Index({ title, date, slug, author, tags }: Props) {
50
70
< Date dateString = { date } />
51
71
</ div >
52
72
< div >
53
- { author ? < Author author = { getAuthor ( author ) } /> : null }
73
+ < Author author = { getAuthor ( author ) } />
54
74
</ div >
55
75
</ div >
56
76
</ header >
57
77
< div className = { styles . content } > { content } </ div >
58
78
< ul className = { "tag-list" } >
59
- { tags &&
60
- tags . map ( ( it , i ) => (
61
- < li key = { i } >
62
- < TagButton tag = { getTag ( it ) } />
63
- </ li >
64
- ) ) }
79
+ { tags . map ( ( it , i ) => (
80
+ < li key = { i } >
81
+ < TagButton tag = { getTag ( it ) } />
82
+ </ li >
83
+ ) ) }
65
84
</ ul >
66
85
</ article >
67
86
< footer >
0 commit comments