From bf9e87d5bf93eadc4d27688a847b35f567278979 Mon Sep 17 00:00:00 2001 From: Nathan Cummins Date: Fri, 8 Aug 2025 18:56:30 +0930 Subject: [PATCH] SEO images, remove services section (for the time being) --- .../projects/dungeons-and-dining-tables.mdx | 2 -- src/layouts/MainHead.astro | 11 ++++++++-- src/layouts/MainLayout.astro | 11 ++++++++-- src/lib/utils.ts | 15 +++++++++++-- src/pages/index.astro | 22 ++++++++++++------- src/pages/projects/[...slug].astro | 19 ++++++++++++++-- 6 files changed, 62 insertions(+), 18 deletions(-) diff --git a/src/assets/projects/dungeons-and-dining-tables.mdx b/src/assets/projects/dungeons-and-dining-tables.mdx index 1755296..1ecca0a 100644 --- a/src/assets/projects/dungeons-and-dining-tables.mdx +++ b/src/assets/projects/dungeons-and-dining-tables.mdx @@ -24,5 +24,3 @@ externalLinks: } ] --- - -I have been enjoying working with Catalyst Games on Dungeons and Dining Tables. diff --git a/src/layouts/MainHead.astro b/src/layouts/MainHead.astro index 779d9db..dcb023b 100644 --- a/src/layouts/MainHead.astro +++ b/src/layouts/MainHead.astro @@ -7,7 +7,14 @@ import Analytics from "@components/Analytics.astro"; import SEO from "@components/SEO.astro"; import ThemeManager from "@components/ThemeManager.astro"; -const { title, subtitle, description } = Astro.props; +interface Props { + title?: string; + subtitle?: string; + description?: string; + image?: SiteImage; +} + +const { title, subtitle, description, image } = Astro.props; // if a title is provided, use it as follows "title | site.title - site.suffix". If no title is provided, instead do "site.title - site.suffix" const headTitle: string = @@ -26,7 +33,7 @@ const headDescription: string = description || site.description; - + diff --git a/src/layouts/MainLayout.astro b/src/layouts/MainLayout.astro index c74f1c2..82cc4f7 100644 --- a/src/layouts/MainLayout.astro +++ b/src/layouts/MainLayout.astro @@ -4,6 +4,7 @@ interface Props { subtitle?: string; description?: string; navbarDisplay?: "normal" | "transparent"; + image?: SiteImage; } import "@/styles/global.css"; @@ -14,7 +15,13 @@ import Navbar from "@components/Navbar.astro"; import Player from "@components/Player.astro"; import MainHead from "@layouts/MainHead.astro"; -const { title, subtitle, description, navbarDisplay = "normal" } = Astro.props; +const { + title, + subtitle, + description, + navbarDisplay = "normal", + image +} = Astro.props; const autoQueuedTracks = ( await getCollection("tracks", ({ data }) => data.autoQueue) @@ -25,7 +32,7 @@ const autoQueuedTracks = ( - +
diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 1c4fc30..a2aa969 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,4 +1,5 @@ import type { ImageMetadata } from "astro"; +import { getImage } from "astro:assets"; import type { CollectionEntry } from "astro:content"; type Project = CollectionEntry<"projects">; @@ -13,12 +14,15 @@ const allProjectHeros = import.meta.glob<{ default: ImageMetadata }>( { eager: true } ); -export function getProjectHero(project: Project): ImageMetadata | undefined { +export function getProjectHero(project: Project): ImageMetadata { + let image: ImageMetadata = Object.values(allProjectHeros)[0].default; for (const [path, mod] of Object.entries(allProjectHeros)) { if (path.includes(project.data.images.hero.src)) { - return mod.default; + image = mod.default; } } + + return image; } export function getProjectOtherImages(project: Project): ImageMetadata[] { @@ -99,3 +103,10 @@ export async function convertImagesImportGlobToArray( return returnedImages; } + +export async function getFullExternalURLOfImage( + image: ImageMetadata +): Promise { + return new URL((await getImage({ src: image })).src, import.meta.env.SITE) + .href; +} diff --git a/src/pages/index.astro b/src/pages/index.astro index b094036..9b2a665 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -203,14 +203,20 @@ const tracks = ( -
-
- Services - - This is where I will put a list of services I offer, such as web - development, music composition, etc. Each service can link to a more - detailed page. - +
+
+
diff --git a/src/pages/projects/[...slug].astro b/src/pages/projects/[...slug].astro index 3bc5259..69e90dd 100644 --- a/src/pages/projects/[...slug].astro +++ b/src/pages/projects/[...slug].astro @@ -5,7 +5,11 @@ import MainLayout from "@layouts/MainLayout.astro"; import { getCollection, render } from "astro:content"; -import { getAllProjectImages } from "@/lib/utils"; +import { + getAllProjectImages, + getFullExternalURLOfImage, + getProjectHero +} from "@/lib/utils"; export async function getStaticPaths() { const projects = await getCollection("projects"); @@ -19,9 +23,20 @@ const { project } = Astro.props; const { Content } = await render(project); const images = getAllProjectImages(project); +const hero = getProjectHero(project); + +const seoImage: SiteImage = { + externalURL: await getFullExternalURLOfImage(hero), + src: hero.src, + alt: project.data.images.hero.alt +}; --- - +