@@ -166,23 +166,31 @@ gtag('config', 'G-VYGDN3X0PR');`],
166166 }
167167 } ,
168168
169- transformHead ( { pageData } ) {
169+ transformHead ( { pageData, siteData } ) {
170170 const head : HeadConfig [ ] = [ ]
171171
172- if ( pageData . frontmatter . image ) {
173- head . push ( [ 'meta' , { property : 'og:image' , content : baseUrl + pageData . frontmatter . image } ] )
174- head . push ( [ 'meta' , { name : 'twitter:image' , content : baseUrl + pageData . frontmatter . image } ] )
175- head . push ( [ 'meta' , { name : 'twitter:card' , content : 'summary_large_image' } ] )
172+ const title = pageData . frontmatter . title || siteData . title
173+ const description = pageData . frontmatter . description || siteData . description
174+ const image = pageData . frontmatter . image
175+ const pageUrl = baseUrl + '/' + pageData . relativePath . replace ( / i n d e x \. m d $ / , '' ) . replace ( / \. m d $ / , '' )
176+
177+ head . push ( [ 'meta' , { property : 'og:type' , content : 'website' } ] )
178+ head . push ( [ 'meta' , { property : 'og:url' , content : pageUrl } ] )
179+
180+ if ( title ) {
181+ head . push ( [ 'meta' , { property : 'og:title' , content : title } ] )
182+ head . push ( [ 'meta' , { name : 'twitter:title' , content : title } ] )
176183 }
177184
178- if ( pageData . frontmatter . description ) {
179- head . push ( [ 'meta' , { property : 'og:description' , content : pageData . frontmatter . description } ] )
180- head . push ( [ 'meta' , { name : 'twitter:description' , content : pageData . frontmatter . description } ] )
185+ if ( description ) {
186+ head . push ( [ 'meta' , { property : 'og:description' , content : description } ] )
187+ head . push ( [ 'meta' , { name : 'twitter:description' , content : description } ] )
181188 }
182189
183- if ( pageData . frontmatter . title ) {
184- head . push ( [ 'meta' , { property : 'og:title' , content : pageData . frontmatter . title } ] )
185- head . push ( [ 'meta' , { name : 'twitter:title' , content : pageData . frontmatter . title } ] )
190+ if ( image ) {
191+ head . push ( [ 'meta' , { property : 'og:image' , content : baseUrl + image } ] )
192+ head . push ( [ 'meta' , { name : 'twitter:image' , content : baseUrl + image } ] )
193+ head . push ( [ 'meta' , { name : 'twitter:card' , content : 'summary_large_image' } ] )
186194 }
187195
188196 return head
0 commit comments