Skip to content

Getting started

Every SILARHI package documents itself from a docs/ folder, published on GitHub Pages at https://<package>.silarhi.dev. The look, the footer, the favicon and the llms.txt come from @silarhi/docs-kit.

docs/
├── astro.config.mjs
├── package.json
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
├── tsconfig.json
└── src/
├── content.config.ts
└── content/docs/
├── index.mdx
└── *.md
docs/src/content.config.ts
export { collections } from '@silarhi/docs-kit/content'

The folder has its own package.json: the documentation tooling never mixes with the package one, and /docs export-ignore in .gitattributes keeps it out of the Composer archive. It is managed with pnpm: "packageManager": "pnpm@<version>" in package.json pins the version, and its own pnpm-workspace.yaml keeps pnpm from looking for a workspace higher up (and lists, under allowBuilds, the dependencies allowed to run install scripts).

Terminal window
cd docs
pnpm add @silarhi/docs-kit @astrojs/starlight astro
pnpm dev
docs/astro.config.mjs
import { defineSilarhiDocs } from '@silarhi/docs-kit'
export default defineSilarhiDocs({
slug: 'llms-txt-bundle', // GitHub repository and subdomain
title: 'LLMs.txt Bundle',
description: 'Build, dump and serve an llms.txt file from your Symfony application.',
sidebar: [
{
label: 'Getting started',
items: [{ autogenerate: { directory: 'getting-started' } }],
},
],
})

defineSilarhiDocs() sets the site URL, adds Starlight with the SILARHI plugin and starlight-llms-txt. Dark mode is Starlight’s: dark by default, with a light / dark / auto picker in the header. Any Starlight option can be passed through starlight: {}, any Astro one through astro: {}: they win over the preset. “Edit page” links point to the main branch of github.com/silarhi/<slug>: set branch for a repository whose default branch is another one (branch: '6.x'), and repo for one outside the silarhi organization.

On top of Starlight’s tags, every page gets:

  • a social image at /og/<page>.png (1200×630, drawn with satori and resvg), in the layout of sainthillier.fr’s: the page title and description, the site’s link, and a card with the package and its composer require, referenced by og:image;
  • JSON-LD: WebSite and SoftwareSourceCode on the home page, TechArticle and BreadcrumbList on the others, all published by the SILARHI organization of silarhi.fr;
  • on the home page, the title <name> – <headline> (the headline of the package in packages.js) instead of the name twice. A head title in the frontmatter still wins;
  • a robots.txt pointing to the sitemap, unless the site has one in public/.

Visits are tracked by Umami, one website per documentation site: its ID comes from the umami field of the package in packages.js, or the umami option. The tracker only runs on the <slug>.silarhi.dev host, so astro dev and astro preview never count. The script loads from analytics.silarhi.dev, which serves only the tracker and the endpoint it posts to.

The search is tracked too, as two Umami events with their properties under Events:

  • search — query and results, once the reader stops typing (3 characters minimum). The queries with 0 results are the pages the documentation is missing.
  • search-click — query and the page opened from the results.

A site that keeps its own Astro config can use the plugin alone:

import starlight from '@astrojs/starlight'
import { silarhiTheme } from '@silarhi/docs-kit'
starlight({
title: 'My package',
plugins: [silarhiTheme({ repo: 'silarhi/my-package' })],
})