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
77 changes: 69 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,71 @@
# docusaurus

[Vercel's Docusaurus template](https://github.com/vercel/examples/tree/main/framework-boilerplates/docusaurus-2) on
**Cloudflare Workers**, deployed by [Orun](https://github.com/sourceplane/orun) to stage
and prod on every merge, and then packaged as an Orun baseline.

This commit is the repository's frame: `intent.yaml` (with the placeholder
workspace `ws_CHANGE_ME`, so CI plans nothing until it is linked), the Orun
CI workflow, the shared TypeScript and ESLint configuration, and the spec
index. The work is tracked as an epic under [`specs/epics`](specs/epics/README.md).
Vercel's [Docusaurus](https://github.com/vercel/examples/tree/main/framework-boilerplates/docusaurus-2)
template — a documentation site and blog: a tutorial of Markdown and MDX docs
with a sidebar generated from its folders, a blog with tags, authors, an
archive and RSS and Atom feeds, a React home page, dark mode and code
highlighting — moved from Docusaurus 2 to Docusaurus 3, running on
**Cloudflare Workers + Static Assets**, deployed by
[Orun](https://github.com/sourceplane/orun) to stage and prod on every merge.
Packaging it as an Orun baseline is the next milestone (DS2).

Docusaurus builds fully static: `docusaurus build` writes every docs page,
blog post, tag page and archive, the feeds, the sitemap and the 404 page to
`build/`. That folder is uploaded as Workers Static Assets with one small
Worker in front for what matches no file; no adapter and no server code. The
docs, the blog, the home page and the theme do not change; the site's name
and repository move into one module, the docs and the blog move under
`content/`, and each deploy builds for its own origin. See
[`specs/epics/docusaurus`](specs/epics/docusaurus/README.md) for the design,
the milestones and the as-built status.

## What is here (the site)

| Surface | Where |
|---|---|
| The site's name and the repository its GitHub and "Edit this page" links point at | `apps/web/site.js` |
| The config: title, tagline, navbar, footer, the docs and blog plugins, the origin | `apps/web/docusaurus.config.js` |
| The docs and the blog (Markdown and MDX) | `apps/web/content/docs`, `apps/web/content/blog` |
| The home page, a Markdown page and their components, the styles | `apps/web/src` |
| The Worker in front of the assets, its config, deploy contract | `apps/web/worker/index.ts`, `apps/web/wrangler.jsonc`, `apps/web/component.yaml` |
| Tests (the name seam, the config, the Worker's assets, the content) | `tests/web` (vitest) |

## Getting started

```bash
pnpm install
pnpm typecheck # tsc: the config and sidebars (`// @ts-check`) and the Worker
pnpm lint # eslint
pnpm test # vitest
pnpm build # docusaurus build → apps/web/build
```

```bash
pnpm --filter @app/web dev # docusaurus start on http://localhost:3000
pnpm --filter @app/web preview # wrangler dev over the built site and its Worker
```

## How it maps to Vercel

| Vercel | Here |
|---|---|
| Static output (`build/`) on Vercel's CDN, from its Docusaurus framework preset | Workers Static Assets: `build/` uploaded with the Worker `<repo>-web-<env>` (`apps/web/wrangler.jsonc`) |
| The template's build (`docusaurus build`) | Unchanged: `docusaurus build` (Docusaurus 3.10.2), through turbo |
| Clean URLs (`/docs/intro` for `docs/intro/index.html`) | `assets.html_handling: drop-trailing-slash` — `/docs/intro` serves `docs/intro/index.html`, `/docs/intro/` redirects to it — the links Docusaurus renders (its default `trailingSlash`) are answered directly |
| The host's 404 for an unknown path | the Worker hands it to the assets, which answer `build/404.html` with a 404 (`not_found_handling: 404-page`) |
| `url: https://your-docusaurus-test-site.com` | Each deploy builds for its own origin — the environment's `SITE_URL`, else its workers.dev URL — through `PUBLIC_SITE_URL`, so canonical links, the sitemap and the feeds name the site where it is served |
| Deploy on push | Orun deploys `<repo>-web-{stage,prod}` on merge to `main` (`apps/web/component.yaml`) |
| "Deploy with Vercel" (clone the template) | `orun new --blueprint repo-blueprint.yaml` — a new repository, branded, deployed |

## CI

| Workflow | What it runs | Ships to a site |
|---|---|---|
| `ci.yml` | the Orun pipeline, and the only workflow a site carries: `orun plan --changed`, then one job per lane. A pull request runs the verify lanes (the site built and dry-deployed per environment; the tests' `quick-check` lane installs and checks the package, it does not run them), except the bootstrap's own landings (`orun/BASE-*`), where `plan` alone is the check; a merge deploys stage → prod. It plans nothing while `intent.yaml` names the placeholder workspace `ws_CHANGE_ME`, as this repository does. A manual run (Orunbase's Deploy button, or Run workflow on `main`) plans the environment and components it names under the push-to-main trigger, so they deploy as a merge deploys them | yes |

## Credits

The site is Vercel's Docusaurus example
([vercel/examples](https://github.com/vercel/examples),
`framework-boilerplates/docusaurus-2`, © Vercel, MIT — `apps/web/LICENSE.md`),
itself Docusaurus's classic template, at vercel/examples `de86723`.
21 changes: 21 additions & 0 deletions apps/web/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2023 Vercel, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions apps/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# apps/web — the docs site

A documentation site and blog on [Docusaurus](https://docusaurus.io) 3 — the
classic template, as Vercel's Docusaurus example
(MIT, `LICENSE.md`) ships it — built fully static and served as Cloudflare
Workers + Static Assets:

- a tutorial of Markdown and MDX docs in `content/docs`, its sidebar
generated from the folders (`sidebars.js`, each folder's
`_category_.json`)
- a blog in `content/blog` — posts with tags, authors (`authors.yml`), an
archive and RSS and Atom feeds
- a React home page and a Markdown page in `src/pages`
- dark mode, code highlighting (Prism) and "Edit this page" links

The docs and the blog live under `content/` rather than Docusaurus's default
`docs/` and `blog/`: `docs/` beside this file is the component's own catalog
pages (overview, architecture, runbook), which are not pages of the site.

The site's name and the repository its GitHub and "Edit this page" links
point at are in `site.js`; `docusaurus.config.js` reads them, and the
site's public origin from `PUBLIC_SITE_URL` (the deploy sets it per
environment).

```bash
pnpm dev # docusaurus start on http://localhost:3000
pnpm build # docusaurus build → build/
pnpm preview # wrangler dev over the built site, behind worker/index.ts
```

How it is deployed — per environment, on merge to `main` — is the
repository's README and `component.yaml` beside this file.
3 changes: 3 additions & 0 deletions apps/web/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
92 changes: 92 additions & 0 deletions apps/web/component.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: sourceplane.io/v1
kind: Component
metadata:
name: web
description: The docs site (Docusaurus 3, built fully static and served as Cloudflare Workers + Static Assets behind one Worker, per environment)
spec:
type: cloudflare-workers-assets-turbo
lifecycle: production
owner: platform
# Its pages, attached to it in the workspace's catalog: what the Docs
# library shows for it, and what the catalog's docs and runbook checks read.
# Generated from what this manifest and its sources declare.
docs:
overview: docs/overview.md
pages:
- { path: docs/architecture.md, role: architecture, title: Architecture }
- { path: docs/runbook.md, role: runbook, title: Runbook }
# `app`, not `web`: a domain and a component share one name space in the
# catalog, and a domain called `web` hid this component from it.
domain: app
path: apps/web
# Its own lane per environment: the site's build is the longest job in the
# plan, and a shared lane would wait on it.
lane: isolated
subscribe:
environments:
- name: dev
profile: verify
- name: stage
profile: verify
profileRules:
- profile: deploy
when:
triggerRef: github-push-main
- name: prod
profile: verify
profileRules:
- profile: deploy
when:
triggerRef: github-push-main
parameters:
nodeVersion: "22"
pnpmVersion: "10.12.1"

workspaceDir: ../..
appDir: .

turboFilter: "@app/web"
# The config the dry run and the deploy hand to wrangler: the Worker
# (worker/index.ts) and the static build in build/ as its assets.
# The site builds fully static, so there is no adapter and no generated
# config — this committed file is the one wrangler deploys.
wranglerConfig: wrangler.jsonc

# `docusaurus build` writes every docs page, blog post, tag page, the
# feeds, the sitemap and the 404 page to build/. The Worker is a source
# file wrangler bundles at deploy; the lane checks it exists after the
# build like any entry.
workerEntrypoint: worker/index.ts
assetsDir: build

# Per-env worker name: docusaurus-web-{dev,stage,prod}.
workerName: docusaurus-web
environmentAwareWorkerName: true

# The account's workers.dev subdomain; exported to the smoke step as
# ${WORKERS_DEV_SUBDOMAIN} and used to build ${DEPLOYED_URL}.
workersDevSubdomain: your-workers-subdomain

installCommand: pnpm install --frozen-lockfile
# The site's public origin (canonical links, the sitemap and the blog's
# RSS and Atom feeds are absolute): the environment's SITE_URL when
# intent.yaml sets one (a custom domain), else its workers.dev URL. The
# subdomain is written out rather than read from ${WORKERS_DEV_SUBDOMAIN},
# which the composition exports to the smoke step only.
# ${ORUN_ENVIRONMENT} the runner sets for every step. docusaurus.config.js
# reads PUBLIC_SITE_URL as the config's `url`.
buildCommand: PUBLIC_SITE_URL="${SITE_URL:-https://docusaurus-web-${ORUN_ENVIRONMENT}.your-workers-subdomain.workers.dev}" pnpm exec turbo run build --filter=@app/web

# Smoke: the home page is the template's (its "Docusaurus Tutorial - 5min"
# call to action — not the site's name, which is the owner's to change and
# HTML-escaped when it carries an `&` or `'`), the tutorial's first page
# answers, the blog's RSS feed is served, and an unknown path answers the
# site's own 404 page with a 404 status (served by the assets through the
# Worker). Each response is buffered before grep so an early match cannot
# SIGPIPE curl.
smokeCommand: "html=$(curl -sfL \"${DEPLOYED_URL}/\") && echo \"${html}\" | grep -q 'Docusaurus Tutorial - 5min' && doc=$(curl -sfL \"${DEPLOYED_URL}/docs/intro\") && echo \"${doc}\" | grep -q 'Tutorial Intro' && feed=$(curl -sfL \"${DEPLOYED_URL}/blog/rss.xml\") && echo \"${feed}\" | grep -q '<rss' && test \"$(curl -s -o /dev/null -w '%{http_code}' \"${DEPLOYED_URL}/no-such-page\")\" = 404"
labels:
team: platform
layer: delivery
surface: web
runtime: cloudflare
12 changes: 12 additions & 0 deletions apps/web/content/blog/2019-05-28-first-blog-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
slug: first-blog-post
title: First Blog Post
authors:
name: Gao Wei
title: Docusaurus Core Team
url: https://github.com/wgao19
image_url: https://github.com/wgao19.png
tags: [hola, docusaurus]
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
44 changes: 44 additions & 0 deletions apps/web/content/blog/2019-05-29-long-blog-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
slug: long-blog-post
title: Long Blog Post
authors: endi
tags: [hello, docusaurus]
---

This is the summary of a very long blog post,

Use a `<!--` `truncate` `-->` comment to limit blog post size in the list view.

<!--truncate-->

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
20 changes: 20 additions & 0 deletions apps/web/content/blog/2021-08-01-mdx-blog-post.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
slug: mdx-blog-post
title: MDX Blog Post
authors: [slorber]
tags: [docusaurus]
---

Blog posts support [Docusaurus Markdown features](https://docusaurus.io/docs/markdown-features), such as [MDX](https://mdxjs.com/).

:::tip

Use the power of React to create interactive blog posts.

```js
<button onClick={() => alert('button clicked!')}>Click me!</button>
```

<button onClick={() => alert('button clicked!')}>Click me!</button>

:::
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions apps/web/content/blog/2021-08-26-welcome/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
slug: welcome
title: Welcome
authors: [slorber, yangshun]
tags: [facebook, hello, docusaurus]
---

[Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog).

Simply add Markdown files (or folders) to the `blog` directory.

Regular blog authors can be added to `authors.yml`.

The blog post date can be extracted from filenames, such as:

- `2019-05-30-welcome.md`
- `2019-05-30-welcome/index.md`

A blog post folder can be convenient to co-locate blog post images:

![Docusaurus Plushie](./docusaurus-plushie-banner.jpeg)

The blog supports tags as well!

**And if you don't want a blog**: just delete this directory, and use `blog: false` in your Docusaurus config.
17 changes: 17 additions & 0 deletions apps/web/content/blog/authors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
endi:
name: Endilie Yacop Sucipto
title: Maintainer of Docusaurus
url: https://github.com/endiliey
image_url: https://github.com/endiliey.png

yangshun:
name: Yangshun Tay
title: Front End Engineer @ Facebook
url: https://github.com/yangshun
image_url: https://github.com/yangshun.png

slorber:
name: Sébastien Lorber
title: Docusaurus maintainer
url: https://sebastienlorber.com
image_url: https://github.com/slorber.png
Loading
Loading