Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<name>/`. 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/<page>.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
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
24 changes: 24 additions & 0 deletions docs/src/lib/case-studies.ts
Original file line number Diff line number Diff line change
@@ -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<CaseStudy[]> {
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}/`;
}
17 changes: 17 additions & 0 deletions docs/src/lib/seo.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -37,6 +38,7 @@ export function cardKey(pathname: string): string {
export async function cardPages(): Promise<CardPage[]> {
const docs = await orderedDocs();
const compared = await comparisons();
const studies = await caseStudies();
return [
{ key: "index", section: "", ...HOME },
...docs.map((doc) => ({
Expand All @@ -52,6 +54,21 @@ export async function cardPages(): Promise<CardPage[]> {
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,
})),
];
}

Expand Down
57 changes: 57 additions & 0 deletions docs/src/pages/case-studies/[...index].astro
Original file line number Diff line number Diff line change
@@ -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/' },
];
---

<Base
title={CASE_STUDIES_INDEX.title}
description={CASE_STUDIES_INDEX.description}
jsonLd={[breadcrumbs(Astro.site, trail)]}
>
<div class="wrap docs docs--single">
<article class="docs__main">
<header class="docs__head">
<h1>Case studies</h1>
<p class="docs__lede">
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.
</p>
</header>
<ul class="cards">
{
studies.map((study) => (
<li>
<a href={href(caseStudyPath(study))}>
<strong>
{study.data.title}
{study.data.draft && ' (draft)'}
</strong>
<span>{study.data.description}</span>
</a>
</li>
))
}
</ul>
</article>
</div>
</Base>
21 changes: 18 additions & 3 deletions docs/src/pages/case-studies/[slug].astro
Original file line number Diff line number Diff line change
@@ -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 },
];
---

<Base title={`${title} · cigen case study`} description={description}>
<Base
title={`${title} · cigen case study`}
description={description}
type="article"
jsonLd={[article(Astro.site, { title: `${title}: a cigen case study`, description, path, published: studied }), breadcrumbs(Astro.site, trail)]}
>
<div class="wrap docs docs--single">
<article class="docs__main">
<header class="docs__head">
{draft && <p class="label">Draft: built by the dev server only</p>}
<p class="label"><a href={href('/case-studies/')}>Case studies</a></p>
<h1>{title}</h1>
<p class="docs__lede">{description}</p>
<p class="docs__meta">
Expand Down
Loading