Skip to content

Commit 06907f1

Browse files
committed
sponsors and redirects
Assisted-by: Claude Code
1 parent 2c4eb4b commit 06907f1

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎.github/workflows/deploy-documents.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ jobs:
5050
https://raw.githubusercontent.com/phalcon/assets/master/phalcon/fanart-fragment.html \
5151
|| echo "Download failed, the committed fan art is used"
5252
53+
- name: Get the sponsors
54+
# Generated into phalcon/assets by its own scheduled workflow. The
55+
# committed src/sponsors.json is the fallback when the download fails.
56+
run: |
57+
curl -fsSL -o src/sponsors.json \
58+
https://raw.githubusercontent.com/phalcon/assets/master/phalcon/sponsors.json \
59+
|| echo "Download failed, the committed roster is used"
60+
5361
- name: Build
5462
run: pnpm build
5563

‎astro.config.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { writeFile } from "node:fs/promises";
12
import { defineConfig } from "astro/config";
23
import tailwindcss from "@tailwindcss/vite";
34
import nimbus, { defineConfig as defineNimbusConfig } from "@cloudflare/nimbus-docs";
@@ -39,6 +40,31 @@ const nimbusConfig = defineNimbusConfig({
3940
},
4041
});
4142

43+
/**
44+
* Cloudflare Pages reads `_redirects` from the build root and serves real
45+
* 301s from it at the edge. Written here rather than committed to public/
46+
* so the stable version comes from src/lib/site.mjs and cannot go stale.
47+
*
48+
* These two routes were Cloudflare zone rules, which intercept before Pages
49+
* ever sees the request. Zone rules therefore win over this file: the rules
50+
* have to be deactivated for these lines to take effect, and this file has
51+
* to be deployed before they are, or /latest/* has nothing to fall back on.
52+
*/
53+
const cloudflareRedirects = {
54+
name: "cloudflare-redirects",
55+
hooks: {
56+
"astro:build:done": async ({ dir, logger }: { dir: URL; logger: { info: (message: string) => void } }) => {
57+
const body = [
58+
`/ /${STABLE_VERSION}/introduction 301`,
59+
`/latest/* /${STABLE_VERSION}/:splat 301`,
60+
].join("\n");
61+
62+
await writeFile(new URL("_redirects", dir), `${body}\n`, "utf8");
63+
logger.info(`_redirects written, /latest -> /${STABLE_VERSION}`);
64+
},
65+
},
66+
};
67+
4268
export default defineConfig({
4369
output: "static",
4470
// Slashless URLs. Pages still emit as `x/index.html` (the `directory`
@@ -72,6 +98,7 @@ export default defineConfig({
7298
defaultStrategy: "hover",
7399
},
74100
integrations: [
101+
cloudflareRedirects,
75102
nimbus(nimbusConfig, {
76103
// Authoring rules are opt-in by design — your repo, your taste. The
77104
// two below are the load-bearing pair: frontmatter has to validate

‎src/components.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Card } from "./components/ui/card";
2020
import { CardGrid } from "./components/ui/card-grid";
2121
import { PackageManagers } from "./components/ui/package-managers";
2222
import { ReleaseHistory } from "./components/ui/release-history";
23+
import { Sponsors } from "./components/ui/sponsors";
2324
import { Step, Steps } from "./components/ui/steps";
2425
import { Tabs, TabItem } from "./components/ui/tabs";
2526

@@ -38,6 +39,7 @@ export const components = {
3839
ReleaseHistory,
3940
Render,
4041
SourceLink,
42+
Sponsors,
4143
Step,
4244
Steps,
4345
TabItem,

0 commit comments

Comments
 (0)