From e2be6c23140d7ed4258a143825a444682f618f1f Mon Sep 17 00:00:00 2001 From: Magnus Madsen Date: Mon, 3 Aug 2026 14:53:15 +0200 Subject: [PATCH] chore: tighten types, enable prefetch, and stop indexing stub pages Six small cleanups: - tsconfig extends astro/tsconfigs/strict rather than base, which is the baseline Astro recommends. Costs nothing here: check stays at 0 errors. - Add interface Props to InlineEditor and Principle, the last two components whose props were implicitly any. - Enable prefetch. `prefetch: true` alone leaves prefetchAll false, so only links carrying data-astro-prefetch would benefit; the object form covers the nine-page nav. Adds a 2.5 KB script to each page. - Ignore .idea/, which has been showing up untracked in every status. - Give Layout a noindex prop that emits a robots meta and drops the canonical link, since a page that should not be indexed has no business claiming one. 404 self-canonicalised to /404/ before this. - Apply noindex to /blog, a 1.7 KB stub whose only content is a link to blog.flix.dev, and filter it out of the sitemap so we are not asking Google to crawl a page we then tell it to drop. Preferred over a redirect because the nav links there and the page explains the move. Co-Authored-By: Claude Opus 5 (1M context) --- .gitignore | 1 + astro.config.mjs | 13 ++++++++++++- src/components/InlineEditor.astro | 4 ++++ src/components/Principle.astro | 4 ++++ src/layouts/Layout.astro | 13 +++++++++++-- src/pages/404.astro | 1 + src/pages/blog.astro | 1 + tsconfig.json | 2 +- 8 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5e1be22..194e522 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ # misc .DS_Store +.idea/ # generated .astro/ diff --git a/astro.config.mjs b/astro.config.mjs index a181bd4..077fe04 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -5,5 +5,16 @@ import sitemap from '@astrojs/sitemap'; export default defineConfig({ site: 'https://flix.dev', - integrations: [icon(), sitemap()] + // Prefetch every internal link on hover; the nav links to nine pages. + prefetch: { + prefetchAll: true + }, + integrations: [ + icon(), + // /blog is a stub pointing at blog.flix.dev and is marked noindex, so it + // does not belong in the sitemap either. + sitemap({ + filter: (page) => !page.endsWith('/blog/') + }) + ] }); diff --git a/src/components/InlineEditor.astro b/src/components/InlineEditor.astro index c4f760b..906072f 100644 --- a/src/components/InlineEditor.astro +++ b/src/components/InlineEditor.astro @@ -1,6 +1,10 @@ --- import { Code } from "astro:components"; import lightPlus from "@shikijs/themes/light-plus"; +interface Props { + code: string; +} + const { code } = Astro.props; import flixGrammar from "../grammars/flix.tmLanguage.json"; diff --git a/src/components/Principle.astro b/src/components/Principle.astro index d0bb9de..10bdd6d 100644 --- a/src/components/Principle.astro +++ b/src/components/Principle.astro @@ -1,4 +1,8 @@ --- +interface Props { + name: string; +} + const { name } = Astro.props; --- diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index b3cd156..596c09d 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -5,9 +5,12 @@ import '@fontsource/open-sans/400.css'; interface Props { title: string; description: string; + /** Keep the page out of the index. Also drops the canonical link, which a + non-indexable page should not claim. */ + noindex?: boolean; } -const { title, description } = Astro.props; +const { title, description, noindex = false } = Astro.props; const currentPath = Astro.url.pathname; const canonicalURL = new URL(currentPath, Astro.site); @@ -32,7 +35,13 @@ import '../styles/global.css'; {title} - + { + noindex ? ( + + ) : ( + + ) + } diff --git a/src/pages/404.astro b/src/pages/404.astro index 981c861..fde6d59 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -4,6 +4,7 @@ import Layout from '../layouts/Layout.astro';
diff --git a/src/pages/blog.astro b/src/pages/blog.astro index c2dda60..c1f0fe2 100644 --- a/src/pages/blog.astro +++ b/src/pages/blog.astro @@ -4,6 +4,7 @@ import Layout from '../layouts/Layout.astro';
diff --git a/tsconfig.json b/tsconfig.json index f11a46c..8bf91d3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "astro/tsconfigs/base", + "extends": "astro/tsconfigs/strict", "include": [".astro/types.d.ts", "**/*"], "exclude": ["dist"] }