| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,6 +55,12 @@ jobs: | |||
| 55 | 55 | env: | |
| 56 | 56 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| 57 | 57 | ||
| 58 | + - name: 🧪 Test site | ||
| 59 | + run: pnpm --filter unifont-site test | ||
| 60 | + | ||
| 61 | + - name: 🔍 Typecheck site | ||
| 62 | + run: pnpm --filter unifont-site test:types | ||
| 63 | + | ||
| 58 | 64 | a11y: | |
| 59 | 65 | runs-on: ubuntu-latest | |
| 60 | 66 | ||
@@ -70,10 +76,10 @@ jobs: | |||
| 70 | 76 | run: pnpm install | |
| 71 | 77 | ||
| 72 | 78 | - name: 🎭 Install Chromium | |
| 73 | - run: pnpm --filter docs exec playwright install --with-deps chromium | ||
| 79 | + run: pnpm --filter unifont-site exec playwright install --with-deps chromium | ||
| 74 | 80 | ||
| 75 | 81 | - name: ♿ Accessibility | |
| 76 | - run: pnpm --filter docs test:a11y | ||
| 82 | + run: pnpm --filter unifont-site test:a11y | ||
| 77 | 83 | ||
| 78 | 84 | - name: 📄 Upload report | |
| 79 | 85 | if: failure() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -229,9 +229,9 @@ export default defineNuxtConfig({ | |||
| 229 | 229 | // The content pages and the endpoints behind them, so no request has to read markdown from a | |
| 230 | 230 | // filesystem a serverless deployment does not have. | |
| 231 | 231 | 'prerender:routes': async ({ routes }) => { | |
| 232 | - const { content } = await import('./server/utils/content.ts') | ||
| 232 | + const { fsContent } = await import('./server/utils/content-fs.ts') | ||
| 233 | 233 | const pages = new Set(proseRoutes) | |
| 234 | - const paths = (await content.list()).map((file: { path: string }) => file.path) | ||
| 234 | + const paths = (await fsContent().list()).map((file: { path: string }) => file.path) | ||
| 235 | 235 | for (const path of paths) { | |
| 236 | 236 | routes.add(path) | |
| 237 | 237 | // Each endpoint is prerendered to a file, so `/docs`, which is also the parent of every | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ export default defineEventHandler(async (event) => { | |||
| 19 | 19 | return | |
| 20 | 20 | } | |
| 21 | 21 | ||
| 22 | - const origin = useRuntimeConfig(event).public.siteUrl || url.origin | ||
| 22 | + const origin = useRuntimeConfig().public.siteUrl || url.origin | ||
| 23 | 23 | const source = await markdownForPath(path, origin) | |
| 24 | 24 | if (!source) { | |
| 25 | 25 | return | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + import type { H3Event } from 'nitro/h3' | ||
| 1 | 2 | import { definePlugin } from 'nitro' | |
| 2 | 3 | import { markdownPath, prefersMarkdown } from '#server/utils/negotiation' | |
| 3 | 4 | ||
@@ -12,16 +13,20 @@ export default definePlugin((nitro) => { | |||
| 12 | 13 | return | |
| 13 | 14 | } | |
| 14 | 15 | ||
| 15 | - const twin = markdownPath(event.url.pathname) | ||
| 16 | + // Nitro types the hook with the minimal `HTTPEvent`, the request and nothing else. What it | ||
| 17 | + // dispatches is an `H3Event`, whose `url` is the one routing and the static handler read. | ||
| 18 | + const { url, res } = event as H3Event | ||
| 19 | + | ||
| 20 | + const twin = markdownPath(url.pathname) | ||
| 16 | 21 | if (!twin) { | |
| 17 | 22 | return | |
| 18 | 23 | } | |
| 19 | 24 | ||
| 20 | 25 | // On the HTML variant too: a shared cache must not serve it to a client asking for markdown. | |
| 21 | - event.res.headers.set('vary', 'Accept, Accept-Encoding') | ||
| 26 | + res.headers.set('vary', 'Accept, Accept-Encoding') | ||
| 22 | 27 | ||
| 23 | 28 | if (prefersMarkdown(event.req.headers.get('accept'))) { | |
| 24 | - event.url.pathname = twin | ||
| 29 | + url.pathname = twin | ||
| 25 | 30 | } | |
| 26 | 31 | }) | |
| 27 | 32 | }) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ import { listMarkdownSources, renderMarkdown } from '../utils/markdown' | |||
| 4 | 4 | ||
| 5 | 5 | /** Every prose page on the site, concatenated into one request. */ | |
| 6 | 6 | export default defineEventHandler(async (event) => { | |
| 7 | - const origin = (useRuntimeConfig(event).public.siteUrl || getRequestURL(event).origin).replace(/\/+$/, '') | ||
| 7 | + const origin = (useRuntimeConfig().public.siteUrl || getRequestURL(event).origin).replace(/\/+$/, '') | ||
| 8 | 8 | const sources = await listMarkdownSources(origin) | |
| 9 | 9 | ||
| 10 | 10 | const body = sources | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ import { listDocs, listPages } from '../utils/markdown' | |||
| 7 | 7 | * blockquote summary, prose, then H2 sections of annotated links. | |
| 8 | 8 | */ | |
| 9 | 9 | export default defineEventHandler(async (event) => { | |
| 10 | - const origin = (useRuntimeConfig(event).public.siteUrl || getRequestURL(event).origin).replace(/\/+$/, '') | ||
| 10 | + const origin = (useRuntimeConfig().public.siteUrl || getRequestURL(event).origin).replace(/\/+$/, '') | ||
| 11 | 11 | const url = (path: string) => `${origin}${path}` | |
| 12 | 12 | ||
| 13 | 13 | const docs = await listDocs() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ import { openApiDocument } from '../utils/openapi' | |||
| 4 | 4 | ||
| 5 | 5 | /** The OpenAPI description of the public API. Mirrored at `/api/openapi.json`. */ | |
| 6 | 6 | export default defineEventHandler((event) => { | |
| 7 | - const origin = useRuntimeConfig(event).public.siteUrl || getRequestURL(event).origin | ||
| 7 | + const origin = useRuntimeConfig().public.siteUrl || getRequestURL(event).origin | ||
| 8 | 8 | ||
| 9 | 9 | event.res.headers.set('content-type', 'application/json; charset=utf-8') | |
| 10 | 10 | event.res.headers.set('cache-control', 'public, max-age=3600, stale-while-revalidate=86400') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ import { useRuntimeConfig } from 'nitro/runtime-config' | |||
| 3 | 3 | ||
| 4 | 4 | /** Everything here is public; the file exists to point at the machine-readable indexes. */ | |
| 5 | 5 | export default defineEventHandler((event) => { | |
| 6 | - const origin = (useRuntimeConfig(event).public.siteUrl || getRequestURL(event).origin).replace(/\/+$/, '') | ||
| 6 | + const origin = (useRuntimeConfig().public.siteUrl || getRequestURL(event).origin).replace(/\/+$/, '') | ||
| 7 | 7 | ||
| 8 | 8 | event.res.headers.set('content-type', 'text/plain; charset=utf-8') | |
| 9 | 9 | event.res.headers.set('cache-control', 'public, max-age=86400') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ const escape = (value: string) => | |||
| 14 | 14 | ||
| 15 | 15 | /** Every indexable URL. A family page costs a provider lookup, so only the featured ones are listed. */ | |
| 16 | 16 | export default defineEventHandler(async (event) => { | |
| 17 | - const config = useRuntimeConfig(event) | ||
| 17 | + const config = useRuntimeConfig() | ||
| 18 | 18 | const origin = (config.public.siteUrl || getRequestURL(event).origin).replace(/\/+$/, '') | |
| 19 | 19 | const lastmod = config.buildTime || new Date().toISOString() | |
| 20 | 20 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + import { fileURLToPath } from 'node:url' | ||
| 2 | + import { comarkContent } from 'comark-content' | ||
| 3 | + import fsSource from 'comark-content/sources/fs' | ||
| 4 | + | ||
| 5 | + /** | ||
| 6 | + * `content/` is next to this module only when it is loaded from source. Anywhere the server has | ||
| 7 | + * been bundled the markdown is read back from a server asset instead, because a deployment has no | ||
| 8 | + * `content/` directory. | ||
| 9 | + */ | ||
| 10 | + export const contentDir = fileURLToPath(new URL('../../content', import.meta.url)) | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * The markdown as it sits on disk. Kept apart from `content.ts` so that `nuxt.config`, which reads | ||
| 14 | + * this to list the pages to prerender, does not have to load a nitro runtime import through it. | ||
| 15 | + */ | ||
| 16 | + export const fsContent = () => comarkContent({ source: fsSource(contentDir) }) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments