feat(structured_data): add alternateNames for backup

This commit is contained in:
DeepChirp
2025-07-31 19:37:25 +08:00
parent 0e9b8f5b69
commit 1b5bc97431
3 changed files with 21 additions and 2 deletions

View File

@@ -40,10 +40,22 @@ if theme.structured_data
const isRootOrSubdomain = currentPath.split('/').filter(Boolean).length === 0;
if (isRootOrSubdomain) {
const domain = new URL(config.url).hostname;
const alternateNames = theme.structured_data.alternate_name || [];
if (config.subtitle) {
alternateNames.push(config.subtitle);
}
if (domain) {
alternateNames.push(domain);
}
const jsonLd = {
"@context": "https://schema.org",
"@type": "WebSite",
"name": config.title,
"alternateName": alternateNames,
"url": full_url_for('/'),
}