@@ -4,13 +4,38 @@ import { getStyles } from '@enhance/arc-plugin-styles'
4
4
/** @type {import('@enhance/types').EnhanceHeadFn } */
5
5
export default function Head ( state ) {
6
6
const { req, store } = state
7
- const { doc = { } } = store
7
+ const {
8
+ doc = { } ,
9
+ pageTitle = '' ,
10
+ pageDescription = '' ,
11
+ pageImage = '' ,
12
+ activeRoute = ''
13
+ } = store
8
14
const { title : docTitle } = doc
9
15
10
- const title = docTitle ? `${ docTitle } — Enhance` : 'Enhance'
16
+ const title = ( docTitle || pageTitle ) ? `${ docTitle || pageTitle } — Enhance` : 'Enhance'
17
+ const description = pageDescription ? pageDescription : 'rhe HTML first full stack web framework'
18
+ const ogImage = pageImage ? pageImage : '/_public/img/enhance-open-graph.png'
11
19
12
20
store . path = req . path || ''
13
21
22
+ let extraBlogMeta = [ ]
23
+
24
+ if ( activeRoute === 'blog' ) {
25
+ if ( store . post ?. frontmatter ?. author ) {
26
+ extraBlogMeta . push ( `<meta property="article:author" content="${ store . post . frontmatter . author } " />` )
27
+ }
28
+ if ( store . post ?. frontmatter ?. published ) {
29
+ let pubDate = new Date ( store . post . frontmatter . published )
30
+ pubDate . setHours ( 13 )
31
+ let dateString = pubDate . toISOString ( ) . replace ( 'Z' , '-0:00' )
32
+ extraBlogMeta . push ( `<meta property="article:published_time" content="${ dateString } " />` )
33
+ }
34
+ if ( store . post ?. frontmatter ?. category ) {
35
+ store . post . frontmatter . category . split ( ',' ) . forEach ( item => extraBlogMeta . push ( `<meta property="article:tag" content="${ item . trim ( ) } ">` ) )
36
+ }
37
+ }
38
+
14
39
return /* html */ `
15
40
<!DOCTYPE html>
16
41
<html lang='en'>
@@ -31,16 +56,39 @@ export default function Head (state) {
31
56
<link rel="stylesheet" href="${ arc . static ( '/css/docs-highlight.css' ) } " />
32
57
<link rel="stylesheet" href="${ arc . static ( '/bundles/docsearch-css.css' ) } " />
33
58
34
- <meta name="image" content="/_public/img/enhance-open-graph.png" />
35
- <meta name="og:image" content="/_public/img/enhance-open-graph.png" />
36
59
<meta name="og:type" content="website" />
37
60
38
61
<link rel="manifest" href="${ arc . static ( '/img/favicon/site.webmanifest' ) } ">
62
+
39
63
<meta http-equiv="X-UA-Compatible" content="IE=edge">
40
64
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
65
+
41
66
${ getStyles . styleTag ( ) }
67
+
42
68
<title>${ title } </title>
43
- <meta name='description' content='The HTML first full stack web framework.' />
69
+ <meta name='description' content="${ description } "/>
70
+
71
+ <!-- Open Graph -->
72
+ <meta name="og:title" content="${ title } " />
73
+ <meta name="og:description" content="${ description } " />
74
+ <meta name="og:image" content="${ ogImage } " />
75
+ <meta name="og:site_name" content="Enhance" />
76
+ <meta name="og:type" content="website" />
77
+
78
+ <meta property="og:title" content="${ title } " />
79
+ <meta property="og:description" content="${ description } " />
80
+ <meta property="og:image" content="${ ogImage } " />
81
+ <meta property="og:site_name" content="Enhance" />
82
+ <meta property="og:type" content="website" />
83
+
84
+ <!-- Twitter -->
85
+ <meta name="twitter:title" content="${ title } " />
86
+ <meta name="twitter:description" content="${ description } " />
87
+ <meta name="twitter:card" content="summary_large_image" />
88
+ <meta name="twitter:image:src" content="${ ogImage } " />
89
+
90
+ ${ extraBlogMeta . join ( '\n' ) }
91
+
44
92
<style>
45
93
@font-face {
46
94
font-family: "Montserrat";
0 commit comments