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 AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ developers, not for us. Every comment ships: keep it short, plain and true.
or description too long for its image, or with a character its fonts
can't draw, such as an arrow or an emoji. In dev, open an image's URL to
see it.
- `pageHead` also gives each page its canonical URL, with the trailing slash
the host serves pages at, and its structured data. `robots.txt` and
- Pages prerender to flat files (`docs/installation.html`), which
Cloudflare Pages serves at `/docs/installation`, the URL every link uses;
the URL with a trailing slash redirects there. `pageHead` also gives each
page its canonical URL and its structured data. `robots.txt` and
`sitemap.xml` are routes too, and the sitemap lists the home page and the
current line's pages. Full URLs use `SITE_URL`: the live site, or a
Cloudflare preview's own address (`site/src/lib/site.ts`).
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- The docs site has a `sitemap.xml` and a `robots.txt`, and each page
describes itself to search engines with structured data: the home page as
the site, and each docs page as an article with its place in the docs.
- Docs pages are served at the URLs the site links to, without a trailing
slash, so following a link no longer redirects. A URL with a trailing
slash still works: it redirects to the one without.

## 0.1.0-rc.3

Expand Down
8 changes: 4 additions & 4 deletions site/src/lib/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export const SITE_URL =
typeof __SITE_URL__ === "string" ? __SITE_URL__ : PRODUCTION_URL;

/**
* A page's full URL, as the host serves it. Every page is prerendered to a
* folder's `index.html`, so its URL ends in a slash, and the URL without one
* redirects there.
* A page's full URL, as the host serves it: `/docs/installation`, the URL
* every link uses. The same URL with a trailing slash redirects there (see
* `vite.config.ts`).
*/
export function pageUrl(path: string): string {
return SITE_URL + (path.endsWith("/") ? path : `${path}/`);
return SITE_URL + path;
}

/**
Expand Down
16 changes: 13 additions & 3 deletions site/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,18 @@ export default defineConfig({
fumadocsMdx(),
tailwindcss(),
tanstackStart({
// Static files only: every page is prerendered to HTML at build time.
prerender: { enabled: true, crawlLinks: true },
// Static files only: every page is prerendered to HTML at build time,
// as `docs/installation.html` rather than `docs/installation/index.html`.
// Cloudflare Pages serves the file at `/docs/installation`, the URL
// every link uses; a folder's `index.html` would redirect it to a URL
// with a trailing slash.
prerender: {
enabled: true,
crawlLinks: true,
autoSubfolderIndex: false,
// A link to a heading on another page is that page again.
filter: ({ path }) => !path.includes("#"),
},
// Routes no page links to, so the crawler doesn't find them.
pages: [
...docsPages,
Expand All @@ -91,7 +101,7 @@ export default defineConfig({
{ path: "/robots.txt" },
{ path: "/sitemap.xml" },
// Written to `404.html` at the output's root.
{ path: "/404", prerender: { autoSubfolderIndex: false } },
{ path: "/404" },
{ path: HOME_IMAGE_PATH, prerender: imagePrerender },
{ path: TOUCH_ICON_PATH, prerender: imagePrerender },
],
Expand Down
Loading