fix(metadata.js): corrects edge case where site name and page name could be duplicated on home page

This commit is contained in:
Cory Dransfeldt 2025-05-26 10:01:37 -07:00
parent 9420ceee4f
commit 0dd83a8d4e
No known key found for this signature in database
3 changed files with 5 additions and 5 deletions

View file

@ -1,11 +1,11 @@
export default { export default {
getMetadata: (data = {}, globals = {}, page = {}, title = "", description = "", schema = "") => { getMetadata: (data = {}, globals = {}, page = {}, title = "", description = "", schema = "") => {
const metadata = data?.metadata; const metadata = data?.metadata;
const baseUrl = globals.url || "" const baseUrl = globals.url || "";
const ogPath = "/og/w800"; const ogPath = "/og/w800";
const image = metadata?.open_graph_image || globals.metadata?.open_graph_image || globals.avatar; const image = metadata?.open_graph_image || globals.metadata?.open_graph_image || globals.avatar;
const rawTitle = title || page.title || metadata?.title || globals.site_name; const rawTitle = title || page.title || metadata?.title || globals.site_name;
const resolvedTitle = `${rawTitle}${globals.site_name}`; const resolvedTitle = rawTitle === globals.site_name ? globals.site_name : `${rawTitle}${globals.site_name}`;
const resolvedDescription = description || metadata?.description || page.description || globals.site_description; const resolvedDescription = description || metadata?.description || page.description || globals.site_description;
const url = metadata?.url || (page.url ? `${baseUrl}${page.url}` : "#"); const url = metadata?.url || (page.url ? `${baseUrl}${page.url}` : "#");

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "8.0.1", "version": "8.0.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "coryd.dev", "name": "coryd.dev",
"version": "8.0.1", "version": "8.0.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"minisearch": "^7.1.2", "minisearch": "^7.1.2",

View file

@ -1,6 +1,6 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "8.0.1", "version": "8.0.2",
"description": "The source for my personal site. Built using 11ty (and other tools).", "description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module", "type": "module",
"engines": { "engines": {