mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
Merge branch 'dev' of https://github.com/jerryc127/hexo-theme-butterfly into dev
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
if theme.structured_data && page.layout === 'post'
|
if theme.structured_data
|
||||||
|
if page.layout === 'post'
|
||||||
-
|
-
|
||||||
// use json-ld to add structured data
|
// https://developers.google.com/search/docs/appearance/structured-data/article
|
||||||
|
|
||||||
const title = page.title
|
const title = page.title
|
||||||
const url = page.permalink
|
const url = page.permalink
|
||||||
@@ -9,7 +10,7 @@ if theme.structured_data && page.layout === 'post'
|
|||||||
const datePublished = page.date.toISOString()
|
const datePublished = page.date.toISOString()
|
||||||
const dateModified = (page.updated || page.date).toISOString()
|
const dateModified = (page.updated || page.date).toISOString()
|
||||||
const author = page.copyright_author || config.author
|
const author = page.copyright_author || config.author
|
||||||
const authorHrefVal = page.copyright_author_href || theme.post_copyright.author_href || site.url
|
const authorHrefVal = page.copyright_author_href || theme.post_copyright.author_href || config.url
|
||||||
const authorHref = full_url_for(authorHrefVal)
|
const authorHref = full_url_for(authorHrefVal)
|
||||||
|
|
||||||
const jsonLd = {
|
const jsonLd = {
|
||||||
@@ -30,5 +31,25 @@ if theme.structured_data && page.layout === 'post'
|
|||||||
jsonLdScript = JSON.stringify(jsonLd, null, 2)
|
jsonLdScript = JSON.stringify(jsonLd, null, 2)
|
||||||
-
|
-
|
||||||
|
|
||||||
|
else if is_home() && (!page.current || page.current === 1)
|
||||||
|
-
|
||||||
|
// https://developers.google.com/search/docs/appearance/site-names#website
|
||||||
|
|
||||||
|
const baseUrl = config.url;
|
||||||
|
const currentPath = url_for('/');
|
||||||
|
const isRootOrSubdomain = currentPath.split('/').filter(Boolean).length === 0;
|
||||||
|
|
||||||
|
if (isRootOrSubdomain) {
|
||||||
|
const jsonLd = {
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "WebSite",
|
||||||
|
"name": config.title,
|
||||||
|
"url": full_url_for('/'),
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonLdScript = JSON.stringify(jsonLd, null, 2)
|
||||||
|
}
|
||||||
|
-
|
||||||
|
|
||||||
script(type="application/ld+json").
|
script(type="application/ld+json").
|
||||||
!{jsonLdScript}
|
!{jsonLdScript}
|
||||||
|
|||||||
Reference in New Issue
Block a user