diff --git a/docs/README.md b/docs/README.md index f1e24f2..dee323e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,8 +13,10 @@ pnpm --dir docs build # writes docs/dist fails if a page is missing there or listed but missing. - **Case studies** are Markdown in `src/content/case-studies/`, one per converted project, served at `/case-studies//`. A study with `draft: true` is built by the dev server only, so `pnpm --dir docs build` never - publishes it. `bootstrap.md` is the first, and the template for the rest: what the project's CI runs, the whole - config, the replay estimate with its method and assumptions, what the conversion found, and what modules would change. + publishes it. The `/case-studies/` index is built only once a study is published, and each study gets an article card + and JSON-LD like the other pages. `bootstrap.md` is the first, and the template for the rest: what the project's CI + runs, the whole config, the replay estimate with its method and assumptions, what the conversion found, and what + modules would change. - **Every page is also served as Markdown** at `/docs/.md`, and `/llms.txt`, `/llms-full.txt` and `/install.md` are generated from the same files (`src/pages/`). - **`/install.sh`** is the repository's root `install.sh`, copied at build time (`src/lib/install-script.mjs`). Never add diff --git a/docs/src/content.config.ts b/docs/src/content.config.ts index f6b80a2..549bbbb 100644 --- a/docs/src/content.config.ts +++ b/docs/src/content.config.ts @@ -18,7 +18,7 @@ const caseStudies = defineCollection({ description: z.string(), /** The project, as `owner/name`. */ project: z.string(), - repository: z.string().url(), + repository: z.url(), /** The full commit the conversion was written against. */ commit: z.string().regex(/^[0-9a-f]{40}$/), studied: z.coerce.date(), diff --git a/docs/src/lib/case-studies.ts b/docs/src/lib/case-studies.ts new file mode 100644 index 0000000..787c959 --- /dev/null +++ b/docs/src/lib/case-studies.ts @@ -0,0 +1,24 @@ +import { type CollectionEntry, getCollection } from "astro:content"; + +export type CaseStudy = CollectionEntry<"caseStudies">; + +export const CASE_STUDIES_INDEX = { + title: "cigen case studies", + description: + "Real open source projects converted to cigen in our own forks, with an estimate of how many CI job runs cigen would have skipped, how it was measured, and what the conversion found.", +}; + +/** Published case studies (drafts too under the dev server), newest first. */ +export async function caseStudies(): Promise { + const entries = await getCollection( + "caseStudies", + (study) => import.meta.env.DEV || !study.data.draft + ); + return entries.sort( + (a, b) => b.data.studied.getTime() - a.data.studied.getTime() + ); +} + +export function caseStudyPath(study: CaseStudy): string { + return `/case-studies/${study.id}/`; +} diff --git a/docs/src/lib/seo.ts b/docs/src/lib/seo.ts index 16f1262..ef24dbf 100644 --- a/docs/src/lib/seo.ts +++ b/docs/src/lib/seo.ts @@ -1,3 +1,4 @@ +import { CASE_STUDIES_INDEX, caseStudies, caseStudyPath } from "./case-studies"; import { COMPARE_INDEX, comparePath, comparisons } from "./compare"; import { BASE_PATH, docPath, orderedDocs } from "./docs"; @@ -37,6 +38,7 @@ export function cardKey(pathname: string): string { export async function cardPages(): Promise { const docs = await orderedDocs(); const compared = await comparisons(); + const studies = await caseStudies(); return [ { key: "index", section: "", ...HOME }, ...docs.map((doc) => ({ @@ -52,6 +54,21 @@ export async function cardPages(): Promise { title: entry.data.title, description: entry.data.description, })), + ...(studies.length > 0 + ? [ + { + key: "case-studies", + section: "Case studies", + ...CASE_STUDIES_INDEX, + }, + ] + : []), + ...studies.map((study) => ({ + key: cardKey(caseStudyPath(study)), + section: "Case study", + title: study.data.title, + description: study.data.description, + })), ]; } diff --git a/docs/src/pages/case-studies/[...index].astro b/docs/src/pages/case-studies/[...index].astro new file mode 100644 index 0000000..6ca3761 --- /dev/null +++ b/docs/src/pages/case-studies/[...index].astro @@ -0,0 +1,57 @@ +--- +import Base from '../../layouts/Base.astro'; +import { CASE_STUDIES_INDEX, type CaseStudy, caseStudies, caseStudyPath } from '../../lib/case-studies'; +import { href } from '../../lib/docs'; +import { breadcrumbs } from '../../lib/seo'; +import '../../styles/docs.css'; + +// The index is built only once a study is published, so there's never an empty page to index. +export async function getStaticPaths() { + const studies = await caseStudies(); + return studies.length > 0 ? [{ params: { index: undefined }, props: { studies } }] : []; +} + +interface Props { + studies: CaseStudy[]; +} + +const { studies } = Astro.props; +const trail = [ + { name: 'cigen', path: '/' }, + { name: 'Case studies', path: '/case-studies/' }, +]; +--- + + +
+
+
+

Case studies

+

+ Open source projects converted to cigen in our own forks, without changing the projects. Each study shows the + whole config, estimates how many job runs cigen would have skipped over the project's recent history, says + exactly how, and lists what the conversion found missing in cigen. +

+
+ +
+
+ diff --git a/docs/src/pages/case-studies/[slug].astro b/docs/src/pages/case-studies/[slug].astro index 92ef68a..cc0e9b4 100644 --- a/docs/src/pages/case-studies/[slug].astro +++ b/docs/src/pages/case-studies/[slug].astro @@ -1,24 +1,39 @@ --- -import { getCollection, render } from 'astro:content'; +import { render } from 'astro:content'; import Base from '../../layouts/Base.astro'; +import { caseStudies, caseStudyPath } from '../../lib/case-studies'; +import { href } from '../../lib/docs'; +import { article, breadcrumbs } from '../../lib/seo'; import '../../styles/docs.css'; // Drafts are built by the dev server only, so `astro build` never publishes one. export async function getStaticPaths() { - const studies = await getCollection('caseStudies', (study) => import.meta.env.DEV || !study.data.draft); + const studies = await caseStudies(); return studies.map((study) => ({ params: { slug: study.id }, props: { study } })); } const { study } = Astro.props; const { Content } = await render(study); const { title, description, project, repository, commit, studied, draft } = study.data; +const path = caseStudyPath(study); +const trail = [ + { name: 'cigen', path: '/' }, + { name: 'Case studies', path: '/case-studies/' }, + { name: title, path }, +]; --- - +
{draft &&

Draft: built by the dev server only

} +

Case studies

{title}

{description}