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
14 changes: 7 additions & 7 deletions .github/workflows/www.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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: |
Expand Down
27 changes: 13 additions & 14 deletions www/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 0 additions & 7 deletions www/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down
51 changes: 15 additions & 36 deletions www/context/url.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -19,20 +12,9 @@ export interface UrlApi {
* can rebase some paths and leave others alone.
*/
url(path: string): Operation<string>;

/**
* 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<string>;
}

// annotated, because `canonical` reads `base` back through the api
export const urlApi: Api<UrlApi> = createApi<UrlApi>("url", {
base: "https://frontside.com/effection",

export const urlApi = createApi<UrlApi>("url", {
*url(path) {
let request = yield* CurrentRequest.expect();
let absolute = new URL(path, new URL(request.url).origin);
Expand All @@ -41,22 +23,19 @@ export const urlApi: Api<UrlApi> = createApi<UrlApi>("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<string> {
let request = yield* CurrentRequest.expect();

return String(original);
},
});

export const { base, canonical, url } = urlApi.operations;
return yield* url(new URL(request.url).pathname);
}
2 changes: 1 addition & 1 deletion www/deno.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
6 changes: 0 additions & 6 deletions www/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions www/routes/app.html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 });

Expand Down
2 changes: 1 addition & 1 deletion www/routes/pagefind-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand Down
Loading