diff --git a/.github/workflows/www.yaml b/.github/workflows/www.yaml index d4abfddaf..7ac6a9d86 100644 --- a/.github/workflows/www.yaml +++ b/.github/workflows/www.yaml @@ -70,7 +70,7 @@ jobs: - name: Download Staticalize run: | - wget https://github.com/thefrontside/staticalize/releases/download/v0.3.0/staticalize-linux.tar.gz \ + wget https://github.com/thefrontside/staticalize/releases/download/v0.3.1/staticalize-linux.tar.gz \ -O /tmp/staticalize-linux.tar.gz tar -xzf /tmp/staticalize-linux.tar.gz -C /usr/local/bin chmod +x /usr/local/bin/staticalize-linux @@ -81,8 +81,8 @@ jobs: --site=http://127.0.0.1:8000 \ --output=www/built \ --base=${{ steps.site.outputs.url }} \ - --concurrency=75 \ - --retries=3 + --canonical=https://frontside.com/effection \ + --concurrency=75 - name: Deploy Preview to Netlify id: netlify @@ -173,7 +173,7 @@ jobs: - name: Download Staticalize run: | - wget https://github.com/thefrontside/staticalize/releases/download/v0.3.0/staticalize-linux.tar.gz \ + wget https://github.com/thefrontside/staticalize/releases/download/v0.3.1/staticalize-linux.tar.gz \ -O /tmp/staticalize-linux.tar.gz tar -xzf /tmp/staticalize-linux.tar.gz -C /usr/local/bin chmod +x /usr/local/bin/staticalize-linux @@ -183,9 +183,9 @@ jobs: staticalize-linux \ --site=http://127.0.0.1:8000 \ --output=www/built \ - --base=https://frontside.com/effection \ - --concurrency=75 \ - --retries=3 + --base=https://effection.netlify.app \ + --canonical=https://frontside.com/effection \ + --concurrency=75 - name: Deploy to Production run: | diff --git a/www/README.md b/www/README.md index 7ef6986b0..47fb0562e 100644 --- a/www/README.md +++ b/www/README.md @@ -15,20 +15,19 @@ Run `deno run -A main.tsx --help` for the current list. Each parameter is addressable two ways — as a `--kebab-case` flag or as a `SCREAMING_SNAKE_CASE` environment variable — and the command line wins when both are supplied. -| Flag | Environment | Default | Purpose | -| ---------------------- | -------------------- | --------------------------------- | ----------------------------------------------------- | -| `--port` | `PORT` | `8000` | Port the HTTP server listens on. `0` picks a free one | -| `--github-token` | `GITHUB_TOKEN` | _unauthenticated_ | GitHub access token for the API | -| `--jsr-api` | `JSR_API` | _none_ | JSR API token; the score card is skipped without it | -| `--deno-deployment-id` | `DENO_DEPLOYMENT_ID` | fresh id per boot | Deployment identity behind the `ETag` | -| `--effectionx-dir` | `EFFECTIONX_DIR` | _none_ | Local effectionx checkout to read instead of cloning | -| `--base` | `BASE` | `https://frontside.com/effection` | Origin every page names as the original | -| `--clones-dir` | `CLONES_DIR` | `build/clones` | Git clones of the documented repositories | -| `--worktrees-dir` | `WORKTREES_DIR` | `build/worktrees` | A git worktree per documented series | -| `--pagefind-dir` | `PAGEFIND_DIR` | `pagefind` | Generated Pagefind search bundle | -| `--tailwind-input` | `TAILWIND_INPUT` | `main.css` | Tailwind entry stylesheet | -| `--tailwind-outdir` | `TAILWIND_OUTDIR` | `tailwind` | Where the compiled stylesheet is written | -| `--verbose` | `VERBOSE` | `false` | Emit debug and warning logs, not just info and error | +| Flag | Environment | Default | Purpose | +| ---------------------- | -------------------- | ----------------- | ----------------------------------------------------- | +| `--port` | `PORT` | `8000` | Port the HTTP server listens on. `0` picks a free one | +| `--github-token` | `GITHUB_TOKEN` | _unauthenticated_ | GitHub access token for the API | +| `--jsr-api` | `JSR_API` | _none_ | JSR API token; the score card is skipped without it | +| `--deno-deployment-id` | `DENO_DEPLOYMENT_ID` | fresh id per boot | Deployment identity behind the `ETag` | +| `--effectionx-dir` | `EFFECTIONX_DIR` | _none_ | Local effectionx checkout to read instead of cloning | +| `--clones-dir` | `CLONES_DIR` | `build/clones` | Git clones of the documented repositories | +| `--worktrees-dir` | `WORKTREES_DIR` | `build/worktrees` | A git worktree per documented series | +| `--pagefind-dir` | `PAGEFIND_DIR` | `pagefind` | Generated Pagefind search bundle | +| `--tailwind-input` | `TAILWIND_INPUT` | `main.css` | Tailwind entry stylesheet | +| `--tailwind-outdir` | `TAILWIND_OUTDIR` | `tailwind` | Where the compiled stylesheet is written | +| `--verbose` | `VERBOSE` | `false` | Emit debug and warning logs, not just info and error | The defaults reproduce what used to be hardcoded, so `deno task dev` and the deployment workflow need no flags. diff --git a/www/cli.ts b/www/cli.ts index 51834da54..15e0f14e9 100644 --- a/www/cli.ts +++ b/www/cli.ts @@ -72,13 +72,6 @@ export const www = command( ), schema(fallback("")), ), - option( - name("base"), - description( - "Origin every page names as the original, whatever origin served it.", - ), - schema(fallback("https://frontside.com/effection")), - ), option( name("clonesDir"), description("Directory holding git clones of the documented repositories."), diff --git a/www/context/url.ts b/www/context/url.ts index a86ca3b4e..5f83bf1dc 100644 --- a/www/context/url.ts +++ b/www/context/url.ts @@ -1,16 +1,9 @@ import { type Operation } from "effection"; import { posixNormalize } from "_posixNormalize"; -import { type Api, createApi } from "@effectionx/context-api"; +import { createApi } from "@effectionx/context-api"; import { CurrentRequest } from "./request.ts"; export interface UrlApi { - /** - * Where the site says it lives: the origin every page names as the - * original, whatever origin actually served it. `main` supplies it from - * configuration; `urlApi.around` can rebase it for a narrower scope. - */ - base: string; - /** * Fully qualify a path against the origin that served the current request, * so that a document advertises the site a reader is actually on. @@ -19,20 +12,9 @@ export interface UrlApi { * can rebase some paths and leave others alone. */ url(path: string): Operation; - - /** - * The canonical url for the current path, under `base`. - * - * A preview and the dev server serve the same page from their own origin, - * but every copy names the same original. - */ - canonical(): Operation; } -// annotated, because `canonical` reads `base` back through the api -export const urlApi: Api = createApi("url", { - base: "https://frontside.com/effection", - +export const urlApi = createApi("url", { *url(path) { let request = yield* CurrentRequest.expect(); let absolute = new URL(path, new URL(request.url).origin); @@ -41,22 +23,19 @@ export const urlApi: Api = createApi("url", { return absolute.toString(); }, +}); - *canonical() { - let request = yield* CurrentRequest.expect(); - // through the api, so that an override of `base` reaches here too - let base = yield* urlApi.operations.base; - - let requested = new URL(request.url); - let original = new URL(base); +export const { url } = urlApi.operations; - // normalized, because a base without a path contributes its own "/" - original.pathname = posixNormalize( - `${original.pathname}${requested.pathname}`, - ); +/** + * The url of the page being served. + * + * What makes it canonical is the crawl: staticalize rewrites it onto + * `--canonical`, so the Netlify copy and a preview both name the site the + * content is published at while staying readable where they are served. + */ +export function* currentUrl(): Operation { + let request = yield* CurrentRequest.expect(); - return String(original); - }, -}); - -export const { base, canonical, url } = urlApi.operations; + return yield* url(new URL(request.url).pathname); +} diff --git a/www/deno.json b/www/deno.json index a31e4c3cf..173d8dd02 100644 --- a/www/deno.json +++ b/www/deno.json @@ -1,7 +1,7 @@ { "tasks": { "dev": "deno run -A @effectionx/watch deno run -A main.tsx", - "staticalize": "deno run -A jsr:@frontside/staticalize@0.3.0/cli --site http://localhost:8000 --output=built --base=http://localhost:8000 --concurrency=75 --retries=3", + "staticalize": "deno run -A npm:staticalize@0.3.1 --site http://localhost:8000 --output=built --base=http://localhost:8000", "test": "deno test --allow-run --allow-write --allow-read --allow-env" }, "lint": { diff --git a/www/main.tsx b/www/main.tsx index 89f5683f4..b1f846a0f 100644 --- a/www/main.tsx +++ b/www/main.tsx @@ -39,7 +39,6 @@ import { initClones } from "./lib/clones.ts"; import { initOctokitContext } from "./lib/octokit.ts"; import { currentRequestPlugin } from "./plugins/current-request.ts"; import { verboseLogging } from "./context/logging.ts"; -import { urlApi } from "./context/url.ts"; // Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts if (import.meta.main) { @@ -62,11 +61,6 @@ if (import.meta.main) { function* serve(options: Options) { yield* verboseLogging(options.verbose); - // the origin pages name as the original, wherever this copy is served - yield* urlApi.around({ - base: () => options.base, - }); - let { current, series } = yield* useConfig(); // Get stable series (no prereleases) for guides diff --git a/www/routes/app.html.tsx b/www/routes/app.html.tsx index ddf8fb921..34dbbfcca 100644 --- a/www/routes/app.html.tsx +++ b/www/routes/app.html.tsx @@ -3,7 +3,7 @@ import type { JSXChild } from "revolution"; import { Footer } from "../components/footer.tsx"; import { Header, type HeaderProps } from "../components/header.tsx"; -import { canonical, url } from "../context/url.ts"; +import { currentUrl, url } from "../context/url.ts"; import { JSXElement } from "revolution/jsx-runtime"; export type Options = { @@ -27,7 +27,7 @@ export function* useAppHtml({ }: Options): Operation<({ children, search }: AppHtmlProps) => JSX.Element> { let ogImageURL = yield* url(image); - let canonicalURL = yield* canonical(); + let canonicalURL = yield* currentUrl(); let header = yield* Header({ hasLeftSidebar }); diff --git a/www/routes/pagefind-route.ts b/www/routes/pagefind-route.ts index 5b2540b59..bd64330f9 100644 --- a/www/routes/pagefind-route.ts +++ b/www/routes/pagefind-route.ts @@ -6,7 +6,7 @@ import { assetsRoute } from "./assets-route.ts"; import { exists } from "../lib/fs.ts"; import type { RoutePath, SitemapRoute } from "../plugins/sitemap.ts"; -const STATICALIZE = "jsr:@frontside/staticalize@0.2.7/cli"; +const STATICALIZE = "npm:staticalize@0.3.1"; const PAGEFIND = "npm:pagefind@1.5.2"; /**