Enable frontmatter og-theme support

Also allows changing from large to small og image
This commit is contained in:
Soitora 2023-07-20 19:57:20 +02:00
parent 2969c46083
commit 58442aab3a
No known key found for this signature in database
GPG Key ID: 621BB8179664494A
5 changed files with 25 additions and 42 deletions

View File

@ -8,6 +8,8 @@ const generateMeta = (context: TransformContext, hostname: string) => {
head.push(["link", { rel: "canonical", href: url }]); head.push(["link", { rel: "canonical", href: url }]);
head.push(["meta", { name: "theme-color", content: pageData.frontmatter.theme }]);
head.push(["meta", { property: "og:url", content: url }]); head.push(["meta", { property: "og:url", content: url }]);
head.push(["meta", { property: "og:type", content: pageData.frontmatter.type }]); head.push(["meta", { property: "og:type", content: pageData.frontmatter.type }]);
head.push(["meta", { property: "og:title", content: pageData.frontmatter.title }]); head.push(["meta", { property: "og:title", content: pageData.frontmatter.title }]);
@ -18,8 +20,17 @@ const generateMeta = (context: TransformContext, hostname: string) => {
head.push(["meta", { name: "twitter:description", content: pageData.frontmatter.description }]); head.push(["meta", { name: "twitter:description", content: pageData.frontmatter.description }]);
if (pageData.frontmatter.image) { if (pageData.frontmatter.image) {
head.push(["meta", { property: "og:image", content: `${hostname}/${pageData.frontmatter.image}` }]); head.push(["meta", { property: "og:image", content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, "")}` }]);
head.push(["meta", { name: "twitter:image", content: `${hostname}/${pageData.frontmatter.image}` }]); head.push(["meta", { name: "twitter:image", content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, "")}` }]);
}
switch (pageData.frontmatter.imageSize) {
case "small":
head.push(["meta", { name: "twitter:card", content: "summary" }]);
break;
case "large":
head.push(["meta", { name: "twitter:card", content: "summary_large_image" }]);
break;
} }
if (pageData.frontmatter.tag) { if (pageData.frontmatter.tag) {

View File

@ -29,16 +29,9 @@ features:
details: Describe Feature here. details: Describe Feature here.
icon: <img src="https://mangadex.org/img/brand/mangadex-logo.svg"> icon: <img src="https://mangadex.org/img/brand/mangadex-logo.svg">
head: theme: "#FD6684"
- - meta image: /forks/forks_logo-neko.png
- property: og:image imageSize: small
content: /forks/forks_logo-neko.png
- - meta
- name: theme-color
content: "#FD6684"
- - meta
- name: msapplication-TileColor
content: "#FD6684"
--- ---
<br><VPTeamMembers size="small" :members="members" /> <br><VPTeamMembers size="small" :members="members" />

View File

@ -29,16 +29,9 @@ features:
details: Describe Feature here. details: Describe Feature here.
icon: <img src="https://tachiyomi-v3-gridsome.netlify.app/assets/forks_logo-az.png" height="32px" width="32px"> icon: <img src="https://tachiyomi-v3-gridsome.netlify.app/assets/forks_logo-az.png" height="32px" width="32px">
head: theme: "#FFCC4D"
- - meta image: /forks/forks_logo-az.png
- property: og:image imageSize: small
content: /forks/forks_logo-az.png
- - meta
- name: theme-color
content: "#FFCC4D"
- - meta
- name: msapplication-TileColor
content: "#FFCC4D"
--- ---
<br><VPTeamMembers size="small" :members="members" /> <br><VPTeamMembers size="small" :members="members" />

View File

@ -38,16 +38,9 @@ features:
details: Describe Feature here. details: Describe Feature here.
icon: 👑 icon: 👑
head: theme: "#0952AF"
- - meta image: /forks/forks_logo-j2k.png
- property: og:image imageSize: small
content: /forks/forks_logo-j2k.png
- - meta
- name: theme-color
content: "#0952AF"
- - meta
- name: msapplication-TileColor
content: "#0952AF"
--- ---
<br><VPTeamMembers size="small" :members="members" /> <br><VPTeamMembers size="small" :members="members" />

View File

@ -38,16 +38,9 @@ features:
details: Describe Feature here. details: Describe Feature here.
icon: 🐍 icon: 🐍
head: theme: "#CE2828"
- - meta image: /forks/forks_logo-sy.png
- property: og:image imageSize: small
content: /forks/forks_logo-sy.png
- - meta
- name: theme-color
content: "#CE2828"
- - meta
- name: msapplication-TileColor
content: "#CE2828"
--- ---
<br><VPTeamMembers size="small" :members="members" /> <br><VPTeamMembers size="small" :members="members" />