From a823e2ff9bb32ed9c3d1bea2eff203cf2f228dbf Mon Sep 17 00:00:00 2001 From: Stefan Imhoff Date: Mon, 12 Jun 2023 17:41:22 +0200 Subject: [PATCH] feat: add meta tags, and links, and other SEO optimization to the head --- package.json | 1 + pnpm-lock.yaml | 7 ++ src/content/journal/2023/shokunin.mdx | 1 + src/layouts/BaseLayout.astro | 148 +++++++++++++++++++++----- src/layouts/GridLayout.astro | 11 +- src/pages/404.astro | 10 +- src/pages/[...slug].astro | 11 +- src/pages/cv.astro | 10 +- src/pages/imprint.mdx | 2 + src/schema/ai-art.ts | 2 + src/schema/haiku.ts | 2 + src/schema/journal.ts | 2 + src/schema/projects.ts | 2 + src/schema/sketchnotes.ts | 2 + 14 files changed, 179 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 595bd28..3493c6a 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "astro": "^2.5.5", "astro-icon": "^0.8.0", "astro-imagetools": "^0.8.1", + "astro-seo": "^0.7.4", "autoprefixer": "^10.4.14", "chart.js": "^4.3.0", "chartjs-plugin-autocolors": "^0.2.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d8b0ee..fab8d19 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,6 +33,9 @@ dependencies: astro-imagetools: specifier: ^0.8.1 version: 0.8.1(astro@2.5.5) + astro-seo: + specifier: ^0.7.4 + version: 0.7.4 autoprefixer: specifier: ^10.4.14 version: 10.4.14(postcss@8.4.24) @@ -3576,6 +3579,10 @@ packages: imagetools-core: 3.0.2 dev: false + /astro-seo@0.7.4: + resolution: {integrity: sha512-E+wJmxOnvBRjgzVctdGk/VdwoEqeQ6Q/KgVW2wRBXZWJVDgOweB32Da/UiH0/FpGncPzo2daOrc08DNn5wTanw==} + dev: false + /astro@2.5.5(@types/node@16.9.1)(sharp@0.32.1): resolution: {integrity: sha512-VRwnlfRtPALeOxfE4e7To5Vlu9pGwlTRWN1zkn1QTizwfg0rLirFTm6t2MCG/fUhlu/p3QO9tz8SpAIyDq53/Q==} engines: {node: '>=16.12.0', npm: '>=6.14.0'} diff --git a/src/content/journal/2023/shokunin.mdx b/src/content/journal/2023/shokunin.mdx index 7bb9159..8bb8132 100644 --- a/src/content/journal/2023/shokunin.mdx +++ b/src/content/journal/2023/shokunin.mdx @@ -1,5 +1,6 @@ --- title: Shokunin – The Spirit of an Artisan +slug: shokunin date: 2023-03-08 author: Stefan Imhoff description: The Japanese word “shokunin” describes an artisan or craftsman. In this essay, I investigate the meaning and history of the word and show a variety of examples. diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index f8fbc32..fc440ec 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -1,6 +1,8 @@ --- import '../styles/global.css'; import { Sprite } from 'astro-icon'; +import { SEO } from 'astro-seo'; +import { site } from '../data/site'; import ThemeProvider from '../components/ThemeProvider.astro'; import PageHeader from '../components/PageHeader.astro'; @@ -9,52 +11,142 @@ import Sal from '../components/Sal.astro'; export interface Props { backLink?: string; + cover?: string; description?: string; footer?: boolean; header?: boolean; + nofollow?: boolean; + noindex?: boolean; title: string; } -const { backLink, footer = true, header = true, title, description } = Astro.props; +const { + backLink, + description, + footer = true, + header = true, + nofollow, + noindex, + title, + cover = '/assets/images/branding/og/bonsai.jpg', +} = Astro.props; +const currentPath = new URL(Astro.request.url).pathname; +const fullTitle = `${title} · ${site.description}`; +const fullDescription = description || site.description; +const fullUrl = site.url + currentPath; +const fullImage = site.url + cover; --- - - - - - - {title} - - + - - - - - - - +
diff --git a/src/pages/404.astro b/src/pages/404.astro index c2b2f65..63800b1 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -13,7 +13,15 @@ const title = 'Error 404'; const description = 'Page not found.'; --- - + Not Found. + {entry.data.title} diff --git a/src/pages/cv.astro b/src/pages/cv.astro index 4221dfc..5080c60 100644 --- a/src/pages/cv.astro +++ b/src/pages/cv.astro @@ -27,7 +27,15 @@ const description = 'The curriculum vitae of Stefan Imhoff, Senior Software Engineer from Hamburg, Germany.'; --- - + Curriculum Vitae
diff --git a/src/pages/imprint.mdx b/src/pages/imprint.mdx index c12c707..919d8ff 100644 --- a/src/pages/imprint.mdx +++ b/src/pages/imprint.mdx @@ -2,6 +2,8 @@ layout: ../layouts/PageLayout.astro title: Imprint description: The imprint of this website. +noindex: true +nofollow: true --- import { mapping } from "../mdx-components.ts"; diff --git a/src/schema/ai-art.ts b/src/schema/ai-art.ts index faefaa1..38da93f 100644 --- a/src/schema/ai-art.ts +++ b/src/schema/ai-art.ts @@ -11,5 +11,7 @@ export const aiArt = defineCollection({ aspectRatio: z.number(), }) ), + noindex: z.boolean().optional(), + nofollow: z.boolean().optional(), }), }); diff --git a/src/schema/haiku.ts b/src/schema/haiku.ts index 37f814a..76cb712 100644 --- a/src/schema/haiku.ts +++ b/src/schema/haiku.ts @@ -5,5 +5,7 @@ export const haiku = defineCollection({ date: z.date(), de: z.string(), en: z.string(), + noindex: z.boolean().optional(), + nofollow: z.boolean().optional(), }), }); diff --git a/src/schema/journal.ts b/src/schema/journal.ts index 8f1d6d2..d34e3f5 100644 --- a/src/schema/journal.ts +++ b/src/schema/journal.ts @@ -29,5 +29,7 @@ export const journal = defineCollection({ ]) ), series: z.string().optional(), + noindex: z.boolean().optional(), + nofollow: z.boolean().optional(), }), }); diff --git a/src/schema/projects.ts b/src/schema/projects.ts index 678ded1..aa7405a 100644 --- a/src/schema/projects.ts +++ b/src/schema/projects.ts @@ -38,5 +38,7 @@ export const projects = defineCollection({ }) .optional(), class: z.string().optional(), + noindex: z.boolean().optional(), + nofollow: z.boolean().optional(), }), }); diff --git a/src/schema/sketchnotes.ts b/src/schema/sketchnotes.ts index 5fcc86e..9f19ece 100644 --- a/src/schema/sketchnotes.ts +++ b/src/schema/sketchnotes.ts @@ -11,5 +11,7 @@ export const sketchnotes = defineCollection({ aspectRatio: z.number(), }) ), + noindex: z.boolean().optional(), + nofollow: z.boolean().optional(), }), });