From 70d9cf9a29d95d5a1718c83338f00b6cc93e2bd7 Mon Sep 17 00:00:00 2001 From: Massimo Iacolare Date: Wed, 28 Oct 2026 13:10:05 +0100 Subject: [PATCH 1/5] README lists the rules absorbed from anti-slop in an Imported / Superseded table, matching the topic table above it --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a7ac496..e7d3ecf 100644 --- a/README.md +++ b/README.md @@ -125,8 +125,10 @@ What each rule reports and why is in [`RULES.md`](RULES.md). Report false positi Some rules come from the Effect rules of [`dmmulroy/anti-slop`](https://github.com/dmmulroy/anti-slop), MIT-licensed: see [`LICENSE.anti-slop`](LICENSE.anti-slop). -- Imported: [`anti-slop-no-manual-effect-error-tag`](RULES.md#anti-slop-no-manual-effect-error-tag), [`anti-slop-no-service-constructor-imports`](RULES.md#anti-slop-no-service-constructor-imports), [`anti-slop-prefer-effect-match`](RULES.md#anti-slop-prefer-effect-match). -- Superseded: `no-manual-tag-comparison` by [`no-manual-discriminant-comparison`](RULES.md#no-manual-discriminant-comparison), `no-manual-tagged-construction` by [`no-manual-discriminant-construction`](RULES.md#no-manual-discriminant-construction). +| Status | Rules | +| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Imported | [`anti-slop-no-manual-effect-error-tag`](RULES.md#anti-slop-no-manual-effect-error-tag), [`anti-slop-no-service-constructor-imports`](RULES.md#anti-slop-no-service-constructor-imports), [`anti-slop-prefer-effect-match`](RULES.md#anti-slop-prefer-effect-match) | +| Superseded | `no-manual-tag-comparison` → [`no-manual-discriminant-comparison`](RULES.md#no-manual-discriminant-comparison), `no-manual-tagged-construction` → [`no-manual-discriminant-construction`](RULES.md#no-manual-discriminant-construction) | ## Default configuration From e42cc05591a717e621102f88fe47b78d4cda8fc1 Mon Sep 17 00:00:00 2001 From: Massimo Iacolare Date: Wed, 28 Oct 2026 13:10:12 +0100 Subject: [PATCH 2/5] website drops the Rules index page: the Rules overview already lists every rule, so RULES.md and its #rules-index anchor link there and the landing action reads Rules overview --- website/astro.config.mjs | 8 ++++---- .../site-content/readmeMdAlignment.test.ts | 2 +- website/src/site-content/readmeMdSource.ts | 10 +++++----- website/src/site-content/realRulesMd.ts | 2 +- .../src/site-content/rulesMdAlignment.test.ts | 2 +- .../src/site-content/rulesMdSource.test.ts | 11 +++------- website/src/site-content/rulesMdSource.ts | 8 ++++++-- website/src/site-content/sitePages.test.ts | 20 +++++++++---------- 8 files changed, 31 insertions(+), 32 deletions(-) diff --git a/website/astro.config.mjs b/website/astro.config.mjs index 097acb8..b3685ca 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -3,14 +3,15 @@ import starlight from "@astrojs/starlight" import { defineConfig } from "astro/config" import { publishedSite } from "./src/site-content/publishedSite.ts" +import { rulesOverviewId } from "./src/site-content/readmeMdSource.ts" import { readSiteSources } from "./src/site-content/readSiteSources.ts" import { sitePages } from "./src/site-content/sitePages.ts" // Starlight's autogenerated sidebar needs entries backed by files, which loader pages are not const pages = sitePages(await readSiteSources(new URL(".", import.meta.url)), publishedSite) const rulePages = pages.filter((page) => page.kind === "rule") -const guidePages = pages.filter((page) => page.kind === "guide" && page.id !== "rules-overview") -const referencePages = pages.filter((page) => page.kind === "reference" && page.id !== "rules") +const guidePages = pages.filter((page) => page.kind === "guide" && page.id !== rulesOverviewId) +const referencePages = pages.filter((page) => page.kind === "reference") export default defineConfig({ site: "https://doubleloop-io.github.io", @@ -47,8 +48,7 @@ export default defineConfig({ { label: "Rules", items: [ - { slug: "rules-overview" }, - { slug: "rules" }, + { slug: rulesOverviewId }, ...Object.entries(Object.groupBy(rulePages, ({ group }) => group)).map( ([group, groupPages = []]) => ({ label: group, diff --git a/website/src/site-content/readmeMdAlignment.test.ts b/website/src/site-content/readmeMdAlignment.test.ts index a28c885..643ca0a 100644 --- a/website/src/site-content/readmeMdAlignment.test.ts +++ b/website/src/site-content/readmeMdAlignment.test.ts @@ -44,7 +44,7 @@ const expectedHref = (href: string) => { if (/^https?:/u.test(href)) return href const link = /^(?[\w.-]+)?(?:#(?[\w-]+))?$/u.exec(href)?.groups if (link?.file === "RULES.md") { - return `${base}/${link.anchor === undefined ? "rules/" : expectedRulesMdRoute(link.anchor)}` + return `${base}/${link.anchor === undefined ? "rules-overview/" : expectedRulesMdRoute(link.anchor)}` } if (link?.file !== undefined) return `${repositoryUrl}/blob/main/${href}` return `${base}/${sectionRoutes.get(link?.anchor ?? "") ?? "not-a-readme-section/"}` diff --git a/website/src/site-content/readmeMdSource.ts b/website/src/site-content/readmeMdSource.ts index 1de7cc5..defc0e4 100644 --- a/website/src/site-content/readmeMdSource.ts +++ b/website/src/site-content/readmeMdSource.ts @@ -12,17 +12,17 @@ const subsectionHeading = /^### (?.+)$/u // Addressed to the plugin maintainers, not to its users export const maintainerSections = new Set(["Development"]) -// `rules` is the rules index from RULES.md -export const renamedSections = new Map([ - ["Rules", { id: "rules-overview", title: "Rules overview" }], -]) +export const rulesOverviewId = "rules-overview" + +// `rules/` is the parent route of the rule pages +export const renamedSections = new Map([["Rules", { id: rulesOverviewId, title: "Rules overview" }]]) const guidePage = (heading: string) => renamedSections.get(heading) ?? { id: headingAnchor(heading), title: heading } const landingActions = [ { text: "Installation", link: "#installation" }, - { text: "Rules index", link: "RULES.md" }, + { text: "Rules overview", link: "RULES.md" }, ] export const readmeMdSource = (markdown: string) => { diff --git a/website/src/site-content/realRulesMd.ts b/website/src/site-content/realRulesMd.ts index 421b6f9..50b91d5 100644 --- a/website/src/site-content/realRulesMd.ts +++ b/website/src/site-content/realRulesMd.ts @@ -15,7 +15,7 @@ const firstRuleOfGroup = new Map( ) const referencePageRoutes = new Map([ - ["rules-index", "rules/"], + ["rules-index", "rules-overview/"], ["common-limits", "common-limits/"], ["shared-settings", "shared-settings/"], ]) diff --git a/website/src/site-content/rulesMdAlignment.test.ts b/website/src/site-content/rulesMdAlignment.test.ts index 452570a..46a3d40 100644 --- a/website/src/site-content/rulesMdAlignment.test.ts +++ b/website/src/site-content/rulesMdAlignment.test.ts @@ -79,7 +79,7 @@ test("every block of a real RULES.md rule section is on its page, links pointing } }) -for (const heading of ["Rules index", "Common limits", "Shared settings"]) { +for (const heading of ["Common limits", "Shared settings"]) { test(`${heading} is a page with the text of its real RULES.md section, links pointing to the page of their anchor`, () => { const source = sourceSection(`## ${heading}`).replace(`## ${heading}\n`, "").trim() diff --git a/website/src/site-content/rulesMdSource.test.ts b/website/src/site-content/rulesMdSource.test.ts index f63bfd0..796ed72 100644 --- a/website/src/site-content/rulesMdSource.test.ts +++ b/website/src/site-content/rulesMdSource.test.ts @@ -174,19 +174,14 @@ test("Shared settings and Common limits each become a page with the body of thei ]) }) -test("the rules index becomes the page at the root of the rules", () => { +test("the rules index has no page, as the rules overview lists every rule", () => { const markdown = [ "# Rules\n", "## Rules index\n\n| Group | Rule |\n| --- | --- |\n\nAll at `warn`.\n", group("Error channel", ruleSection("no-effect-promise")), ].join("\n") - const page = pageById(markdown, "rules") + const pages = rulesMdSource(markdown).sourcePages - assert.deepEqual(page, { - kind: "reference", - id: "rules", - title: "Rules index", - body: "| Group | Rule |\n| --- | --- |\n\nAll at `warn`.\n", - }) + assert.ok(pages.every(({ page }) => page.title !== "Rules index")) }) diff --git a/website/src/site-content/rulesMdSource.ts b/website/src/site-content/rulesMdSource.ts index 7184f63..1a1c0d4 100644 --- a/website/src/site-content/rulesMdSource.ts +++ b/website/src/site-content/rulesMdSource.ts @@ -1,5 +1,6 @@ import { headingAnchor } from "./internalLinks.ts" import { isCodeFence, markdownLines } from "./markdownLines.ts" +import { rulesOverviewId } from "./readmeMdSource.ts" import type { SitePage, SourcePage } from "./sitePages.ts" type Section = { @@ -13,7 +14,6 @@ type RuleSection = Section & { name: string } const file = "RULES.md" const referencePageIds = new Map([ - ["Rules index", "rules"], ["Common limits", "common-limits"], ["Shared settings", "shared-settings"], ]) @@ -50,10 +50,14 @@ const rulesMdPage = (section: Section): RulesMdPage[] => { return [{ page, file, heading, location: `section \`${heading}\`` }] } +// The README Rules section lists every rule, so it stands in for the rules index, which has no page +const rulesIndexRoute = `${rulesOverviewId}/` + // A group has no page: its anchor leads to its first rule, as its heading does in RULES.md const linkRoutes = (allSections: Section[], sourcePages: RulesMdPage[]) => new Map([ - [file, "rules/"], + [file, rulesIndexRoute], + [`${file}#rules-index`, rulesIndexRoute], ...allSections.flatMap(({ heading }): [string, string][] => { const target = sourcePages.find((source) => source.heading === heading)?.page ?? diff --git a/website/src/site-content/sitePages.test.ts b/website/src/site-content/sitePages.test.ts index ae9b37e..a9f95fe 100644 --- a/website/src/site-content/sitePages.test.ts +++ b/website/src/site-content/sitePages.test.ts @@ -49,15 +49,16 @@ test("a link to Shared settings or Common limits points to its page", () => { test("a link to a group points to the first rule of that group", () => { const markdown = rulesMarkdown( + "## Shared settings\n\nUsed by [Error channel](#error-channel).\n", group("Error channel", ruleSection("no-effect-promise"), ruleSection("try-object-form")), - ).replace("| --- | --- |\n", "| --- | --- |\n| [Error channel](#error-channel) | |\n") + ) - const page = pageById({ rulesMd: markdown }, "rules") + const page = pageById({ rulesMd: markdown }, "shared-settings") assert.ok(page?.body.includes("[Error channel](/site/rules/no-effect-promise/)")) }) -test("a link to the rules index points to the rules index page", () => { +test("a link to the rules index points to the rules overview", () => { const markdown = rulesMarkdown( "## Shared settings\n\nListed in the [rules index](#rules-index).\n", group("Error channel", ruleSection("no-effect-promise")), @@ -65,7 +66,7 @@ test("a link to the rules index points to the rules index page", () => { const page = pageById({ rulesMd: markdown }, "shared-settings") - assert.ok(page?.body.includes("[rules index](/site/rules/)")) + assert.ok(page?.body.includes("[rules index](/site/rules-overview/)")) }) test("a RULES.md link to a section that has no site page fails, naming the link and the rule", () => { @@ -82,7 +83,7 @@ test("a RULES.md link to a section that has no site page fails, naming the link }) }) -test("the landing page links to installation and to the rules index", () => { +test("the landing page links to installation and to the rules overview", () => { const readmeMd = [ "# @owner/the-plugin\n\nAn oxlint plugin.\n\nIt complements [tsgo](#alongside-effecttsgo).\n", "## Installation\n\n```bash\npnpm add -D the-plugin\n```\n", @@ -98,7 +99,7 @@ test("the landing page links to installation and to the rules index", () => { body: "An oxlint plugin.\n\nIt complements [tsgo](/site/configuration/#alongside-effecttsgo).\n", actions: [ { text: "Installation", link: "/site/installation/" }, - { text: "Rules index", link: "/site/rules/" }, + { text: "Rules overview", link: "/site/rules-overview/" }, ], }) }) @@ -117,7 +118,7 @@ test("a link to a README section points to its page, a link to a subsection to i ) }) -test("a link to the Rules section points to the rules overview, apart from the rules index page", () => { +test("a link to the Rules section points to the rules overview", () => { const readmeMd = readmeMarkdown( "## Rules\n\n| Topic | Rules |\n\n### Absorbed from anti-slop\n\nSome rules.\n", "## Versioning\n\nSee the [overview](#rules) and [provenance](#absorbed-from-anti-slop).\n", @@ -129,10 +130,9 @@ test("a link to the Rules section points to the rules overview, apart from the r pages.find(({ id }) => id === "versioning")?.body, "See the [overview](/site/rules-overview/) and [provenance](/site/rules-overview/#absorbed-from-anti-slop).\n", ) - assert.equal(pages.find(({ id }) => id === "rules")?.title, "Rules index") }) -test("a link from the README to RULES.md points to the rules index, a link to a rule in it to the rule page", () => { +test("a link from the README to RULES.md points to the rules overview, a link to a rule in it to the rule page", () => { const readmeMd = readmeMarkdown( "## Versioning\n\nIn [`RULES.md`](RULES.md), such as [this](RULES.md#no-effect-promise).\n", ) @@ -141,7 +141,7 @@ test("a link from the README to RULES.md points to the rules index, a link to a assert.equal( page?.body, - "In [`RULES.md`](/site/rules/), such as [this](/site/rules/no-effect-promise/).\n", + "In [`RULES.md`](/site/rules-overview/), such as [this](/site/rules/no-effect-promise/).\n", ) }) From 7b4f390c75aa860943b893ce83151ecdd64445a7 Mon Sep 17 00:00:00 2001 From: Massimo Iacolare <info@massimoiacolare.it> Date: Wed, 28 Oct 2026 13:10:12 +0100 Subject: [PATCH 3/5] website hides the right-hand table of contents on every page: pages are short and it was rarely used --- website/astro.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/website/astro.config.mjs b/website/astro.config.mjs index b3685ca..7a20bc6 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -19,6 +19,7 @@ export default defineConfig({ integrations: [ starlight({ title: "oxlint-plugin-effect", + tableOfContents: false, social: [ { icon: "github", From 9f1f2418a5f429f7e0cc58666e8de59250421db3 Mon Sep 17 00:00:00 2001 From: Massimo Iacolare <info@massimoiacolare.it> Date: Wed, 28 Oct 2026 13:10:12 +0100 Subject: [PATCH 4/5] website sidebar takes the Effect docs navigation tones: zinc-300 top-level entries, smaller zinc-400 semibold nested groups, zinc-400 rule links, zinc-800 current page; previous and next links shrink --- website/src/styles/theme.css | 51 +++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/website/src/styles/theme.css b/website/src/styles/theme.css index 62104d3..0115590 100644 --- a/website/src/styles/theme.css +++ b/website/src/styles/theme.css @@ -27,6 +27,11 @@ --sl-color-hairline-shade: var(--sl-color-gray-5); --theme-code-bg: var(--sl-color-gray-6); + + /* Effect docs navigation tones: zinc-300 headings, zinc-400 items, zinc-800 current page */ + --dl-sidebar-heading: #d4d4d8; + --dl-sidebar-item: #a1a1aa; + --dl-sidebar-current-bg: var(--sl-color-gray-5); } :root[data-theme="light"] { @@ -53,6 +58,10 @@ --sl-color-hairline-shade: var(--sl-color-gray-6); --theme-code-bg: var(--sl-color-gray-7); + + --dl-sidebar-heading: #27272a; + --dl-sidebar-item: #52525b; + --dl-sidebar-current-bg: var(--sl-color-gray-7); } /* Monochrome links need an underline to stay distinguishable from body text. */ @@ -77,13 +86,49 @@ h4, font-weight: 600; } +/* + Three sidebar levels, as in the Effect docs: top-level entries in the heading tone, + nested groups as smaller semibold labels, and their pages in the regular item tone. +*/ +.sidebar-content .top-level > li > a.large, +.sidebar-content .top-level > li > details > summary .large { + color: var(--dl-sidebar-heading); +} + +.sidebar-content ul ul summary .large { + font-size: var(--sl-text-sm); + font-weight: 600; + color: var(--dl-sidebar-item); +} + +.sidebar-content ul ul a { + color: var(--dl-sidebar-item); +} + +.sidebar-content a:hover, +.sidebar-content a:focus, +.sidebar-content summary:hover .large { + color: var(--sl-color-white); +} + /* The current sidebar page is a filled neutral pill, as in the Effect docs. */ .sidebar-content a[aria-current="page"] { - background-color: var(--sl-color-gray-6); + background-color: var(--dl-sidebar-current-bg); color: var(--sl-color-white); font-weight: 600; } -:root[data-theme="light"] .sidebar-content a[aria-current="page"] { - background-color: var(--sl-color-gray-7); +/* Previous and next links are a footer aid, so they stay smaller than the page headings. */ +.pagination-links a { + padding: 0.625rem 0.875rem; + font-size: var(--sl-text-sm); +} + +.pagination-links .link-title { + font-size: var(--sl-text-lg); +} + +.pagination-links svg { + width: 1.125rem; + height: 1.125rem; } From d0462715ac07669e91fb5b7e67e90df1d55353e3 Mon Sep 17 00:00:00 2001 From: Massimo Iacolare <info@massimoiacolare.it> Date: Wed, 28 Oct 2026 13:18:46 +0100 Subject: [PATCH 5/5] website landing shows the package scope above its name and the README's first paragraph as tagline, so the title fits one line --- .../site-content/readmeMdAlignment.test.ts | 8 ++++++-- .../src/site-content/readmeMdSource.test.ts | 10 ++++++++++ website/src/site-content/readmeMdSource.ts | 19 +++++++++++++------ website/src/site-content/sitePages.test.ts | 7 +++++-- website/src/site-content/sitePages.ts | 11 ++++++++++- website/src/site-content/sitePagesLoader.ts | 16 ++++++++++++++-- website/src/styles/theme.css | 19 +++++++++++++++++++ 7 files changed, 77 insertions(+), 13 deletions(-) diff --git a/website/src/site-content/readmeMdAlignment.test.ts b/website/src/site-content/readmeMdAlignment.test.ts index 643ca0a..94dc80c 100644 --- a/website/src/site-content/readmeMdAlignment.test.ts +++ b/website/src/site-content/readmeMdAlignment.test.ts @@ -62,8 +62,12 @@ test("the real README introduction is the landing page with its text, links poin const landing = pages.find(({ kind }) => kind === "landing") - assert.equal(landing?.title, title.replace(/^# /u, "")) - assert.equal(pageText(landing?.body ?? ""), sourceText(sourceSection(title))) + const [tagline, ...rest] = sourceText(sourceSection(title)).split("\n\n") + assert.ok(landing?.kind === "landing") + assert.equal(landing.title, title.replace(/^# /u, "")) + assert.equal(`${landing.scope ?? ""}${landing.name}`, landing.title) + assert.equal(landing.tagline, tagline) + assert.equal(pageText(landing.body), rest.join("\n\n")) }) for (const heading of publishedHeadings) { diff --git a/website/src/site-content/readmeMdSource.test.ts b/website/src/site-content/readmeMdSource.test.ts index 278305a..74a09d2 100644 --- a/website/src/site-content/readmeMdSource.test.ts +++ b/website/src/site-content/readmeMdSource.test.ts @@ -63,3 +63,13 @@ test("the Development section and its subsections are on no page", () => { assert.ok(!pages.some(({ id }) => id === "development")) assert.ok(!pages.some(({ body }) => body.includes("pnpm format") || body.includes("Releasing"))) }) + +test("an unscoped package name is the whole landing title, and an introduction of one paragraph leaves an empty body", () => { + const page = pageById(readmeMarkdown(), "index") + + assert.ok(page?.kind === "landing") + assert.equal(page.scope, undefined) + assert.equal(page.name, "the-plugin") + assert.equal(page.tagline, "A plugin.") + assert.equal(page.body, "") +}) diff --git a/website/src/site-content/readmeMdSource.ts b/website/src/site-content/readmeMdSource.ts index defc0e4..5594de9 100644 --- a/website/src/site-content/readmeMdSource.ts +++ b/website/src/site-content/readmeMdSource.ts @@ -1,6 +1,6 @@ import { headingAnchor } from "./internalLinks.ts" import { markdownLines } from "./markdownLines.ts" -import type { SourcePage } from "./sitePages.ts" +import type { SitePage, SourcePage } from "./sitePages.ts" type Section = { level: "#" | "##"; heading: string; subheadings: string[]; lines: string[] } @@ -33,14 +33,12 @@ export const readmeMdSource = (markdown: string) => { return { sourcePages, routes: linkRoutes(readmeSections) } } +const packageName = /^(?<scope>@[^/]+\/)?(?<name>.+)$/u + const readmeMdPage = ({ level, heading, lines }: Section): SourcePage => { const body = `${lines.join("\n").trim()}\n` return level === "#" - ? { - page: { kind: "landing", id: "index", title: heading, body, actions: landingActions }, - file, - location: "introduction", - } + ? { page: landingPage(heading, body), file, location: "introduction" } : { page: { kind: "guide", ...guidePage(heading), body }, file, @@ -48,6 +46,15 @@ const readmeMdPage = ({ level, heading, lines }: Section): SourcePage => { } } +// The heading is the package name, split so the scope can sit above the name; +// the first paragraph is the tagline under it, so the body starts after it +const landingPage = (heading: string, introduction: string): SitePage => { + const { scope, name = heading } = packageName.exec(heading)?.groups ?? {} + const [tagline = "", ...rest] = introduction.split("\n\n") + const body = rest.length === 0 ? "" : `${rest.join("\n\n").trim()}\n` + return { kind: "landing", id: "index", title: heading, scope, name, tagline: tagline.trim(), body, actions: landingActions } +} + const linkRoutes = (readmeSections: Section[]) => new Map( readmeSections diff --git a/website/src/site-content/sitePages.test.ts b/website/src/site-content/sitePages.test.ts index a9f95fe..d3ae615 100644 --- a/website/src/site-content/sitePages.test.ts +++ b/website/src/site-content/sitePages.test.ts @@ -83,7 +83,7 @@ test("a RULES.md link to a section that has no site page fails, naming the link }) }) -test("the landing page links to installation and to the rules overview", () => { +test("the landing page shows the package scope above its name, the first paragraph as tagline, and links to installation and the rules overview", () => { const readmeMd = [ "# @owner/the-plugin\n\nAn oxlint plugin.\n\nIt complements [tsgo](#alongside-effecttsgo).\n", "## Installation\n\n```bash\npnpm add -D the-plugin\n```\n", @@ -96,7 +96,10 @@ test("the landing page links to installation and to the rules overview", () => { kind: "landing", id: "index", title: "@owner/the-plugin", - body: "An oxlint plugin.\n\nIt complements [tsgo](/site/configuration/#alongside-effecttsgo).\n", + scope: "@owner/", + name: "the-plugin", + tagline: "An oxlint plugin.", + body: "It complements [tsgo](/site/configuration/#alongside-effecttsgo).\n", actions: [ { text: "Installation", link: "/site/installation/" }, { text: "Rules overview", link: "/site/rules-overview/" }, diff --git a/website/src/site-content/sitePages.ts b/website/src/site-content/sitePages.ts index 445d609..d79f236 100644 --- a/website/src/site-content/sitePages.ts +++ b/website/src/site-content/sitePages.ts @@ -6,7 +6,16 @@ export type SitePage = | { kind: "rule"; id: string; title: string; group: string; body: string } | { kind: "reference"; id: string; title: string; body: string } | { kind: "guide"; id: string; title: string; body: string } - | { kind: "landing"; id: string; title: string; body: string; actions: LandingAction[] } + | { + kind: "landing" + id: string + title: string + scope: string | undefined + name: string + tagline: string + body: string + actions: LandingAction[] + } type LandingAction = { text: string; link: string } diff --git a/website/src/site-content/sitePagesLoader.ts b/website/src/site-content/sitePagesLoader.ts index 9e29829..04aff43 100644 --- a/website/src/site-content/sitePagesLoader.ts +++ b/website/src/site-content/sitePagesLoader.ts @@ -2,7 +2,7 @@ import type { Loader } from "astro/loaders" import { publishedSite } from "./publishedSite.ts" import { readSiteSources } from "./readSiteSources.ts" -import { sitePages } from "./sitePages.ts" +import { type SitePage, sitePages } from "./sitePages.ts" export const sitePagesLoader = (): Loader => ({ name: "site-pages", @@ -10,7 +10,10 @@ export const sitePagesLoader = (): Loader => ({ const sources = await readSiteSources(config.root) store.clear() for (const page of sitePages(sources, { ...publishedSite, base: config.base })) { - const hero = page.kind === "landing" ? { actions: page.actions } : undefined + const hero = + page.kind === "landing" + ? { title: heroTitle(page), tagline: escapeHtml(page.tagline), actions: page.actions } + : undefined const data = await parseData({ id: page.id, data: { title: page.title, hero } }) store.set({ id: page.id, @@ -21,3 +24,12 @@ export const sitePagesLoader = (): Loader => ({ } }, }) + +type LandingPage = Extract<SitePage, { kind: "landing" }> + +// Starlight renders the hero title and tagline as HTML +const heroTitle = ({ scope, name }: LandingPage) => + [scope === undefined ? "" : `<span class="hero-scope">${escapeHtml(scope)}</span>`, escapeHtml(name)].join("") + +const escapeHtml = (text: string) => + text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """) diff --git a/website/src/styles/theme.css b/website/src/styles/theme.css index 0115590..21fa95b 100644 --- a/website/src/styles/theme.css +++ b/website/src/styles/theme.css @@ -132,3 +132,22 @@ h4, width: 1.125rem; height: 1.125rem; } + +/* The landing title is the package name: the scope sits above it, so the name fits one line. */ +.hero h1 { + font-size: clamp(var(--sl-text-3xl), calc(0.25rem + 4.5vw), var(--sl-text-5xl)); + overflow-wrap: normal; +} + +.hero-scope { + display: block; + margin-bottom: 0.25rem; + font-size: var(--sl-text-xl); + font-weight: 500; + letter-spacing: 0; + color: var(--sl-color-gray-3); +} + +.hero .tagline { + color: var(--sl-color-gray-2); +}