Skip to content

Commit

Permalink
Set a default meta image when one is not provided, when using opengra…
Browse files Browse the repository at this point in the history
…ph/twitter meta definitions
  • Loading branch information
dannon committed Aug 28, 2023
1 parent fcb490a commit 4b0a35e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"copyFileExts": ["png", "jpg", "jpeg", "gif", "svg", "pdf", "mp4"]
},
"defaultSocialImage": "/images/galaxy-logos/galaxy_project_logo.png",
"taggedEventsPages": [
{ "tag": "webinar", "path": "/events/webinars/" },
{ "tag": "devroundtable", "path": "/community/devroundtable/" },
Expand Down
6 changes: 6 additions & 0 deletions src/components/ArticleHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ export default {
if (info.meta !== undefined) {
info.meta.push({ property: "og:type", content: "article" });
info.meta.push({ property: "twitter:card", content: "summary_large_image" });
// Set a backup summary image if none is provided.
if (!info.meta.some((tag) => tag.property in ["og:image", "twitter:image"])) {
const defaultSocialImageURL = ensureDomain(CONFIG.defaultSocialImage);
info.meta.push({ property: "og:image", content: defaultSocialImageURL });
info.meta.push({ property: "twitter:image", content: defaultSocialImageURL });
}
return info;
}
},
Expand Down

0 comments on commit 4b0a35e

Please sign in to comment.