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
2 changes: 1 addition & 1 deletion frontend/content/blog/laravel-rust-rewrite.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: How we rewrote VisualCI in Laravel Rust
description: VisualCI's server moved from Loco to Laravel Rust two days after Laravel Rust's first beta. How the port went, what fought us (Postgres arrays, composite keys, MCP and the request context), what the reviews and a screenshot run caught, and the fixes we sent upstream.
date: 2026-12-03
date: 2026-12-03T21:51:22+13:00
author: Nathan Broadbent
draft: false
---
Expand Down
2 changes: 1 addition & 1 deletion frontend/content/blog/laravel-rust-starter-kit.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: A Laravel Rust starter kit for a production SaaS
description: VisualCI is open source, and its server is a Laravel Rust app that runs in production. Clone it, delete the visual testing, and you start with sign-in, organizations, invitations, credit billing on Stripe, transactional email, an MCP server with OAuth, background jobs with heartbeats, and the tests and CI around them.
date: 2026-12-04
date: 2026-12-04T03:49:04+13:00
author: Nathan Broadbent
draft: false
---
Expand Down
2 changes: 1 addition & 1 deletion frontend/content/blog/weasyprint-case-study.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Case study: a WeasyPrint crash that shipped in four releases"
description: For nine months and four releases, WeasyPrint crashed on documents with positioned content in a running header or footer. We replayed the commit that caused it with VisualCI and 17 realistic business documents, and the build flagged it on that commit. WeasyPrint's own sample documents never showed it.
date: 2026-12-04
date: 2026-12-04T18:18:16+13:00
author: Nathan Broadbent
image: linebreak-p23.png
draft: false
Expand Down
19 changes: 19 additions & 0 deletions frontend/scripts/blog.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Types for src/__tests__/blog.test.ts.
export type Post = {
slug: string
title: string
description: string
date: string
day: string
time: number
author: string
image: string | null
draft: boolean
body: string
}
export function parsePost(slug: string, source: string): Post
export function loadPosts(options?: { drafts?: boolean }): Promise<Post[]>
export function sortPosts(posts: Post[]): Post[]
export function postMetaHtml(post: Post): string
export function postJsonLd(post: Post): string
export function atomFeed(posts: Post[], htmlBySlug: Map<string, string>): string
60 changes: 46 additions & 14 deletions frontend/scripts/blog.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Markdown copy at /blog/<slug>.md, and the files in content/blog/<slug>/ (its images) served next to it. /blog/ lists
// the posts, newest first, and /blog/feed.xml is their Atom feed.
//
// Front matter: title, description, date (YYYY-MM-DD) and author, all required; `image`, a PNG or JPG in the post's
// Front matter: title, description, date and author, all required. `date` is when the post was published, with its
// time and timezone (2026-12-04T18:18:16+13:00): posts are sorted by it, and the page shows its date as written; `image`, a PNG or JPG in the post's
// folder for its link preview; `draft: true` keeps a post out of the build unless VISUALCI_BLOG_DRAFTS=1 (a dev server).
// A published post with a `[TODO` placeholder left in it fails the build.
// With no published posts there's no /blog/ at all, so the site never links an empty blog.
Expand All @@ -12,6 +13,8 @@ import { SITE, root } from './docs-source.mjs'

export const blogDir = join(root, 'content/blog')

/** A publish time: date, time and a timezone (Z or an offset). */
const DATETIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?(?:Z|[+-]\d{2}:\d{2})$/
const SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
/** Paths under /blog/ that can't be posts. */
const RESERVED = new Set(['feed', 'index'])
Expand All @@ -25,7 +28,7 @@ async function exists(path) {
}
}

function parsePost(slug, source) {
export function parsePost(slug, source) {
const file = `content/blog/${slug}.md`
const match = source.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/)
if (!match) throw new Error(`${file} has no front matter`)
Expand All @@ -37,8 +40,9 @@ function parsePost(slug, source) {
for (const key of ['title', 'description', 'date', 'author']) {
if (!meta[key]) throw new Error(`${file} has no ${key}`)
}
if (!/^\d{4}-\d{2}-\d{2}$/.test(meta.date) || Number.isNaN(Date.parse(`${meta.date}T00:00:00Z`))) {
throw new Error(`${file}: date must be YYYY-MM-DD, not ${meta.date}`)
// Two posts on one day are ordered by their times, so a date alone isn't enough.
if (!DATETIME.test(meta.date) || Number.isNaN(Date.parse(meta.date))) {
throw new Error(`${file}: date must be when the post was published, with its time and timezone (2026-12-04T18:18:16+13:00), not ${meta.date}`)
}
if (meta.image && !/\.(png|jpe?g)$/i.test(meta.image)) throw new Error(`${file}: image must be a PNG or JPG`)
// A link or image by relative path (`chart.png`, `img/chart.png`) is a file in the post's folder.
Expand All @@ -47,7 +51,11 @@ function parsePost(slug, source) {
slug,
title: meta.title,
description: meta.description,
/** The publish time as written, with its timezone. */
date: meta.date,
/** The day it was published, in the timezone it was written in: what the page shows. */
day: meta.date.slice(0, 10),
time: Date.parse(meta.date),
author: meta.author,
image: meta.image || null,
draft: meta.draft === 'true',
Expand All @@ -72,7 +80,12 @@ export async function loadPosts({ drafts = false } = {}) {
if (!post.draft && post.body.includes('[TODO')) throw new Error(`content/blog/${slug}.md still has a [TODO]: fill it in or keep the post a draft`)
if (!post.draft || drafts) posts.push(post)
}
return posts.sort((a, b) => b.date.localeCompare(a.date) || a.slug.localeCompare(b.slug))
return sortPosts(posts)
}

/** Newest first by publish time; posts published at the same moment by slug, so the order never depends on the file system. */
export function sortPosts(posts) {
return posts.sort((a, b) => b.time - a.time || a.slug.localeCompare(b.slug))
}

/** Copy each post's folder (its images) to /blog/<slug>/, next to its page. */
Expand All @@ -90,42 +103,61 @@ export const postImage = (post) => (post.image ? `${SITE}/blog/${post.slug}/${po
const escapeHtml = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')

/** "3 December 2026", from YYYY-MM-DD. */
export function formatDate(date) {
return new Date(`${date}T00:00:00Z`).toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC' })
export function formatDate(day) {
return new Date(`${day}T00:00:00Z`).toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC' })
}

/** The line under a post's title: its date and author. */
const dateHtml = (post) => `<time datetime="${post.date}">${formatDate(post.day)}</time>`

/** The line under a post's title, beside View as Markdown and Copy page: its date and author (inner HTML). */
export function postMetaHtml(post) {
return `<p class="blog-meta"><time datetime="${post.date}">${formatDate(post.date)}</time> · ${escapeHtml(post.author)}${post.draft ? ' · <strong>Draft</strong>' : ''}</p>\n`
return `${dateHtml(post)} · ${escapeHtml(post.author)}${post.draft ? ' · <strong>Draft</strong>' : ''}`
}

/** The post's schema.org BlogPosting, for its page's <head>. */
export function postJsonLd(post) {
const data = {
'@context': 'https://schema.org',
'@type': 'BlogPosting',
headline: post.title,
description: post.description,
datePublished: post.date,
author: { '@type': 'Person', name: post.author },
publisher: { '@type': 'Organization', name: 'VisualCI', url: SITE },
url: `${SITE}${postPath(post)}`,
mainEntityOfPage: `${SITE}${postPath(post)}`,
...(post.image ? { image: postImage(post) } : {}),
}
return `<script type="application/ld+json">${JSON.stringify(data).replace(/</g, '\\u003c')}</script>`
}

/** /blog/: every post, newest first. */
export function indexHtml(posts) {
const items = posts.map(
(p) =>
`<li class="blog-item"><a class="blog-item-title" href="${postPath(p)}">${escapeHtml(p.title)}</a><p class="blog-meta"><time datetime="${p.date}">${formatDate(p.date)}</time> · ${escapeHtml(p.author)}</p><p class="blog-item-description">${escapeHtml(p.description)}</p></li>`,
`<li class="blog-item"><a class="blog-item-title" href="${postPath(p)}">${escapeHtml(p.title)}</a><p class="blog-meta">${dateHtml(p)} · ${escapeHtml(p.author)}</p><p class="blog-item-description">${escapeHtml(p.description)}</p></li>`,
)
return `<p>Notes from the people building VisualCI. Follow along with the <a href="/blog/feed.xml">Atom feed</a>.</p>\n<ul class="blog-list">${items.join('')}</ul>\n`
}

export function indexMarkdown(posts) {
return [
`Notes from the people building VisualCI. Atom feed: ${SITE}/blog/feed.xml`,
posts.map((p) => `- [${p.title}](${SITE}${postMarkdown(p)}) (${p.date}, ${p.author}): ${p.description}`).join('\n'),
posts.map((p) => `- [${p.title}](${SITE}${postMarkdown(p)}) (${p.day}, ${p.author}): ${p.description}`).join('\n'),
].join('\n\n')
}

/** The Atom feed, with each post's full HTML and absolute URLs (feed readers resolve nothing). */
export function atomFeed(posts, htmlBySlug) {
const absolute = (html) => html.replace(/(href|src)="\/(?!\/)/g, `$1="${SITE}/`)
const updated = `${posts[0].date}T00:00:00Z`
const updated = posts[0].date
const entries = posts.map(
(p) => ` <entry>
<title>${escapeHtml(p.title)}</title>
<link rel="alternate" type="text/html" href="${SITE}${postPath(p)}"/>
<id>${SITE}${postPath(p)}</id>
<published>${p.date}T00:00:00Z</published>
<updated>${p.date}T00:00:00Z</updated>
<published>${p.date}</published>
<updated>${p.date}</updated>
<author><name>${escapeHtml(p.author)}</name></author>
<summary>${escapeHtml(p.description)}</summary>
<content type="html">${escapeHtml(absolute(htmlBySlug.get(p.slug)))}</content>
Expand Down
15 changes: 8 additions & 7 deletions frontend/scripts/prerender.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { pathToFileURL } from 'node:url'
import { Marked } from 'marked'
import { SITE, absoluteLinks, pageSlugs, parsePage, readPage, root } from './docs-source.mjs'
import { buildHosts, hostsMeta } from './hosts.mjs'
import { atomFeed, copyPostFiles, indexHtml, indexMarkdown, loadPosts, postImage, postMarkdown, postMetaHtml, postPath } from './blog.mjs'
import { atomFeed, copyPostFiles, indexHtml, indexMarkdown, loadPosts, postImage, postJsonLd, postMarkdown, postMetaHtml, postPath } from './blog.mjs'

const dist = join(root, 'dist')

Expand Down Expand Up @@ -131,10 +131,10 @@ for (const slug of await standaloneSlugs(join(root, 'content/pages'))) {
}
/** Write a page outside the docs: /<path>/index.html in the docs' design, and its Markdown copy. `ogImage` replaces
* the site's link-preview image, and `head` is added to the page's <head> (the blog's feed link). */
async function writeStandalone({ slug, title, description, html: body, copy, ogImage = null, head = '' }) {
async function writeStandalone({ slug, title, description, html: body, copy, ogImage = null, head = '', meta }) {
const markdown = standaloneMarkdown(slug)
const path = standalonePath(slug)
const data = { slug, title, description, html: body, nav: [], markdown }
const data = { slug, title, description, html: body, nav: [], markdown, ...(meta ? { meta } : {}) }
const json = JSON.stringify(data).replace(/</g, '\\u003c')
let html = template
html = fill(html, '<!--docs-->', renderDoc(data), 'docs.html')
Expand Down Expand Up @@ -314,10 +314,11 @@ if (posts.length) {
slug: `blog/${post.slug}`,
title: post.title,
description: post.description,
html: postMetaHtml(post) + body,
copy: `${post.date}, ${post.author}\n\n${absoluteLinks(post.body)}`,
html: body,
meta: postMetaHtml(post),
copy: `${post.day}, ${post.author}\n\n${absoluteLinks(post.body)}`,
ogImage: postImage(post),
head: feedLink,
head: `${feedLink}\n ${postJsonLd(post)}`,
})
}
await writeStandalone({
Expand Down Expand Up @@ -372,7 +373,7 @@ ${

Notes from the people building VisualCI, newest first. Markdown copies (all of them: ${SITE}/blog/index.md; Atom feed: ${SITE}/blog/feed.xml):

${posts.map((p) => `- [${p.title}](${SITE}${postMarkdown(p)}) (${p.date}): ${p.description}`).join('\n')}
${posts.map((p) => `- [${p.title}](${SITE}${postMarkdown(p)}) (${p.day}): ${p.description}`).join('\n')}

`
: ''
Expand Down
40 changes: 40 additions & 0 deletions frontend/src/__tests__/blog.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// @vitest-environment node
import { describe, expect, it } from 'vitest'
import { atomFeed, loadPosts, parsePost, postJsonLd, postMetaHtml, sortPosts } from '../../scripts/blog.mjs'

const post = (slug: string, date: string) =>
parsePost(slug, `---\ntitle: ${slug}\ndescription: A post.\ndate: ${date}\nauthor: Nathan Broadbent\n---\n\nBody.\n`)

describe('blog', () => {
it('needs a publish time with a timezone, not just a date', () => {
expect(() => post('a', '2026-12-04')).toThrow(/time and timezone/)
expect(() => post('a', '2026-12-04T18:18:16')).toThrow(/time and timezone/)
expect(post('a', '2026-12-04T18:18:16+13:00').time).toBe(Date.parse('2026-12-04T05:18:16Z'))
expect(post('a', '2026-12-04T05:18:16Z').day).toBe('2026-12-04')
})

it('sorts by publish time across timezones, then by slug', () => {
const posts = [
post('a-early', '2026-12-04T03:49:04+13:00'),
post('z-late', '2026-12-04T18:18:16+13:00'),
post('b-utc', '2026-12-04T05:00:00Z'), // 18:00 in New Zealand: between the two
post('a-same', '2026-12-04T05:00:00Z'),
]
expect(sortPosts(posts).map((p) => p.slug)).toEqual(['z-late', 'a-same', 'b-utc', 'a-early'])
})

it('shows the day as written and puts the full time in <time>, the feed and JSON-LD', () => {
const p = post('a', '2026-12-04T03:49:04+13:00')
expect(postMetaHtml(p)).toContain('<time datetime="2026-12-04T03:49:04+13:00">4 December 2026</time>')
expect(postJsonLd(p)).toContain('"datePublished":"2026-12-04T03:49:04+13:00"')
const feed = atomFeed([p], new Map([['a', '<p>Body.</p>']]))
expect(feed).toContain('<published>2026-12-04T03:49:04+13:00</published>')
expect(feed).toContain('<updated>2026-12-04T03:49:04+13:00</updated>')
})

it('lists the WeasyPrint case study before the starter kit published earlier that day', async () => {
const slugs = (await loadPosts()).map((p) => p.slug)
expect(slugs.indexOf('weasyprint-case-study')).toBeLessThan(slugs.indexOf('laravel-rust-starter-kit'))
expect(slugs.indexOf('laravel-rust-starter-kit')).toBeLessThan(slugs.indexOf('laravel-rust-rewrite'))
})
})
19 changes: 12 additions & 7 deletions frontend/src/pages/DocsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export type DocsPageData = {
nav: DocsNavSection[]
/** The page's Markdown copy, when it isn't the docs' `/docs/<slug>.md`. */
markdown?: string
/** A blog post's date and author (HTML from scripts/blog.mjs), on the row under the title beside the buttons. */
meta?: string
}

function Sidebar({ nav, slug }: { nav: DocsNavSection[]; slug: string }) {
Expand Down Expand Up @@ -108,15 +110,18 @@ export function DocsPage({ page }: { page: DocsPageData }) {
)}
<main className="docs-main">
<article className="docs-content">
<div className="docs-head">
<header className="docs-head">
<h1>{page.title}</h1>
<div className="docs-actions">
<a className="btn btn-sm" href={markdown}>
<FileTextIcon size={15} aria-hidden /> View as Markdown
</a>
<CopyPage href={markdown} />
<div className="docs-head-row">
{page.meta && <p className="blog-meta" dangerouslySetInnerHTML={{ __html: page.meta }} />}
<div className="docs-actions">
<a className="btn btn-sm" href={markdown}>
<FileTextIcon size={15} aria-hidden /> View as Markdown
</a>
<CopyPage href={markdown} />
</div>
</div>
</div>
</header>
<div dangerouslySetInnerHTML={{ __html: page.html }} />
</article>
</main>
Expand Down
26 changes: 19 additions & 7 deletions frontend/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4041,25 +4041,37 @@ svg.regions-dim {
max-width: 72ch;
}

/* The page title on the left, View as Markdown and Copy page on the right, on one row (stacked on phones). */
/* The page title on a row of its own; under it a blog post's date and author on the left, and View as Markdown and
Copy page on the right. On a phone the buttons wrap below the date and author. */
.docs-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-4);
flex-direction: column;
gap: var(--space-3);
margin-bottom: var(--space-8);
}

.docs-head-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-2) var(--space-4);
min-width: 0;
}

.docs-content .docs-head-row .blog-meta {
margin: 0;
}

.docs-actions {
display: flex;
flex: none;
gap: var(--space-2);
margin-left: auto;
}

@media (max-width: 640px) {
.docs-head {
flex-direction: column;
align-items: flex-start;
.docs-actions {
margin-left: 0;
}
}

Expand Down
3 changes: 3 additions & 0 deletions scripts/screenshots/pages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export function pages() {
return [
['landing', '/', false, ALL],
['docs/index', '/docs/', false, ALL],
// The blog's list (newest first: the order Nathan checks) and a post, whose header the docs pages share.
['blog/index', '/blog/', false, ALL],
['blog/post', '/blog/weasyprint-case-study/', false, ALL],
['app/orgs', '/', true, ALL],
['app/org', '/acme', true, ALL],
['app/project/builds', '/acme/web', true, ALL],
Expand Down
Loading