Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
500f938179 | ||
|
|
178f836760 | ||
|
|
d37427aa3e | ||
| f6bed01377 | |||
| 3ec9f4b424 | |||
| 02bc0e0419 | |||
| 8bf428c6ef |
17 changed files with 1854 additions and 1466 deletions
6
.github/workflows/quartz-pages.yml
vendored
6
.github/workflows/quartz-pages.yml
vendored
|
|
@ -33,7 +33,11 @@ jobs:
|
||||||
repository: GameCult/GameCult-Quartz
|
repository: GameCult/GameCult-Quartz
|
||||||
path: GameCult-Quartz
|
path: GameCult-Quartz
|
||||||
|
|
||||||
|
# Pages actions exist only on GitHub: the forge runner resolves actions
|
||||||
|
# from data.forgejo.org, which has no actions/configure-pages, so the job
|
||||||
|
# failed there. Build always; touch Pages only on the GitHub mirror.
|
||||||
- name: Configure Pages
|
- name: Configure Pages
|
||||||
|
if: github.server_url == 'https://github.com'
|
||||||
uses: actions/configure-pages@v5
|
uses: actions/configure-pages@v5
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
|
|
@ -56,11 +60,13 @@ jobs:
|
||||||
--outputDir "${{ inputs.output-dir }}"
|
--outputDir "${{ inputs.output-dir }}"
|
||||||
|
|
||||||
- name: Upload Pages artifact
|
- name: Upload Pages artifact
|
||||||
|
if: github.server_url == 'https://github.com'
|
||||||
uses: actions/upload-pages-artifact@v3
|
uses: actions/upload-pages-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ inputs.output-dir }}
|
path: ${{ inputs.output-dir }}
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
if: github.server_url == 'https://github.com'
|
||||||
environment:
|
environment:
|
||||||
name: github-pages
|
name: github-pages
|
||||||
url: ${{ steps.deployment.outputs.page_url }}
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
|
|
|
||||||
37
README.md
37
README.md
|
|
@ -16,7 +16,7 @@ Site-specific content, mastheads, sidebars, render hooks, and custom chrome stay
|
||||||
|
|
||||||
- **Entry points:** `scripts/build-site.mjs` (stage a site repo against this engine), `scripts/build-graph-spa.mjs` (build the shared graph SPA into a consumer), `quartz/graph-spa` (the SPA source) and `.github/workflows/quartz-pages.yml` (the reusable Pages workflow).
|
- **Entry points:** `scripts/build-site.mjs` (stage a site repo against this engine), `scripts/build-graph-spa.mjs` (build the shared graph SPA into a consumer), `quartz/graph-spa` (the SPA source) and `.github/workflows/quartz-pages.yml` (the reusable Pages workflow).
|
||||||
- **Live:** the engine and workflow serve `gamecult-site` and `AetheriaLore`; the graph SPA serves the deployed Mimir and gamecult.org sites under its default `epiphany-graph` asset route.
|
- **Live:** the engine and workflow serve `gamecult-site` and `AetheriaLore`; the graph SPA serves the deployed Mimir and gamecult.org sites under its default `epiphany-graph` asset route.
|
||||||
- **Migrating:** that default route is a compatibility contract. New or migrated consumers pass the `norn-graph` asset paths and `gamecult-norn-graph-root` explicitly. Future sprite staging extends Sai rather than adding a site-local player.
|
- **Migrating:** that default route is a compatibility contract. New or migrated consumers pass the `norn-graph` asset paths and `gamecult-norn-graph-root` explicitly.
|
||||||
|
|
||||||
## Consumer Repo Shape
|
## Consumer Repo Shape
|
||||||
|
|
||||||
|
|
@ -74,41 +74,6 @@ and the fullscreen shell. Norn owns graph interaction and rendering. Consumer
|
||||||
sites provide taxonomy, filtering, placement, and presentation through
|
sites provide taxonomy, filtering, placement, and presentation through
|
||||||
`GameCultGraphSpaShell` configuration and overlay styles.
|
`GameCultGraphSpaShell` configuration and overlay styles.
|
||||||
|
|
||||||
## Shared Interactive Embeds
|
|
||||||
|
|
||||||
### `Plugin.InkEmbedder`
|
|
||||||
|
|
||||||
Use `Plugin.InkEmbedder()` in a consumer site's emitter list to enable reusable
|
|
||||||
Ink embeds. The plugin copies Sai's packaged browser assets from `@gamecult/sai`
|
|
||||||
into the built site's `/static/interactive/` directory and injects the player
|
|
||||||
CSS and script.
|
|
||||||
|
|
||||||
Authors embed stories with plain HTML:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div
|
|
||||||
class="sai-player"
|
|
||||||
data-ink-format="visual-novel"
|
|
||||||
data-ink-story="/static/interactive/example/story.ink.json"
|
|
||||||
data-visual-manifest="/static/interactive/example/visual-manifest.json"
|
|
||||||
data-scene-label="Scene Name"
|
|
||||||
></div>
|
|
||||||
```
|
|
||||||
|
|
||||||
Supported formats:
|
|
||||||
|
|
||||||
- `data-ink-format="raven"` or omitted: cheap interactive-fiction transcript
|
|
||||||
layout for Raven Collective-style Ink.
|
|
||||||
- `data-ink-format="visual-novel"`: fixed scene view with bottom dialogue bar,
|
|
||||||
speaker avatar, and choices/continue controls inside the dialogue surface.
|
|
||||||
- `data-ink-format="cinematic"`: slide/deck layout with background plates,
|
|
||||||
captions, and optional references.
|
|
||||||
|
|
||||||
The legacy `data-ink-mode` attribute still works. Future sprite staging should
|
|
||||||
extend Sai rather than inventing another site-local player. Existing
|
|
||||||
`.aetheria-ink-player` containers are still initialised by Sai as a migration
|
|
||||||
bridge, but new embeds should use `.sai-player`.
|
|
||||||
|
|
||||||
## Shared Components
|
## Shared Components
|
||||||
|
|
||||||
### `AutoIndexFolder`
|
### `AutoIndexFolder`
|
||||||
|
|
|
||||||
1252
package-lock.json
generated
1252
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -36,11 +36,9 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clack/prompts": "^0.11.0",
|
"@clack/prompts": "^0.11.0",
|
||||||
"@floating-ui/dom": "^1.7.4",
|
"@floating-ui/dom": "^1.7.4",
|
||||||
"@gamecult/sai": "github:GameCult/Sai#d070159ba575b2ee643f44222e89dcbb7ded7c49",
|
|
||||||
"@myriaddreamin/rehype-typst": "^0.6.0",
|
"@myriaddreamin/rehype-typst": "^0.6.0",
|
||||||
"@napi-rs/simple-git": "0.1.22",
|
"@napi-rs/simple-git": "0.1.22",
|
||||||
"@tweenjs/tween.js": "^25.0.0",
|
"@tweenjs/tween.js": "^25.0.0",
|
||||||
"@vitejs/plugin-react": "^5.2.0",
|
|
||||||
"ansi-truncate": "^1.4.0",
|
"ansi-truncate": "^1.4.0",
|
||||||
"async-mutex": "^0.5.0",
|
"async-mutex": "^0.5.0",
|
||||||
"chokidar": "^5.0.0",
|
"chokidar": "^5.0.0",
|
||||||
|
|
@ -66,8 +64,6 @@
|
||||||
"preact-render-to-string": "^6.6.5",
|
"preact-render-to-string": "^6.6.5",
|
||||||
"pretty-bytes": "^7.1.0",
|
"pretty-bytes": "^7.1.0",
|
||||||
"pretty-time": "^1.1.0",
|
"pretty-time": "^1.1.0",
|
||||||
"react": "^19.2.6",
|
|
||||||
"react-dom": "^19.2.6",
|
|
||||||
"reading-time": "^1.5.0",
|
"reading-time": "^1.5.0",
|
||||||
"rehype-autolink-headings": "^7.1.0",
|
"rehype-autolink-headings": "^7.1.0",
|
||||||
"rehype-citation": "^2.3.1",
|
"rehype-citation": "^2.3.1",
|
||||||
|
|
@ -95,7 +91,6 @@
|
||||||
"unified": "^11.0.5",
|
"unified": "^11.0.5",
|
||||||
"unist-util-visit": "^5.1.0",
|
"unist-util-visit": "^5.1.0",
|
||||||
"vfile": "^6.0.3",
|
"vfile": "^6.0.3",
|
||||||
"vite": "^7.3.3",
|
|
||||||
"workerpool": "^10.0.1",
|
"workerpool": "^10.0.1",
|
||||||
"ws": "^8.19.0",
|
"ws": "^8.19.0",
|
||||||
"yargs": "^18.0.0"
|
"yargs": "^18.0.0"
|
||||||
|
|
@ -106,8 +101,6 @@
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/node": "^25.0.10",
|
"@types/node": "^25.0.10",
|
||||||
"@types/pretty-time": "^1.1.5",
|
"@types/pretty-time": "^1.1.5",
|
||||||
"@types/react": "^19.2.2",
|
|
||||||
"@types/react-dom": "^19.2.2",
|
|
||||||
"@types/source-map-support": "^0.5.10",
|
"@types/source-map-support": "^0.5.10",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"@types/yargs": "^17.0.35",
|
"@types/yargs": "^17.0.35",
|
||||||
|
|
|
||||||
1764
quartz/graph-spa/package-lock.json
generated
Normal file
1764
quartz/graph-spa/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -7,11 +7,14 @@
|
||||||
"build": "vite build --base ./"
|
"build": "vite build --base ./"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vitejs/plugin-react": "^5.1.1",
|
"@vitejs/plugin-react": "^5.2.0",
|
||||||
"react": "^19.2.0",
|
"react": "^19.2.6",
|
||||||
"react-dom": "^19.2.0",
|
"react-dom": "^19.2.6",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vite": "^7.2.4"
|
"vite": "^7.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {
|
||||||
|
"@types/react": "^19.2.2",
|
||||||
|
"@types/react-dom": "^19.2.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -874,14 +874,9 @@ function mountGameCultGraph() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function scheduleGameCultGraphMount() {
|
if (document.readyState === "loading") {
|
||||||
|
document.addEventListener("DOMContentLoaded", () => mountGameCultGraph())
|
||||||
|
} else {
|
||||||
mountGameCultGraph()
|
mountGameCultGraph()
|
||||||
window.setTimeout(mountGameCultGraph, 50)
|
|
||||||
window.setTimeout(mountGameCultGraph, 300)
|
|
||||||
window.setTimeout(mountGameCultGraph, 1000)
|
|
||||||
window.setTimeout(mountGameCultGraph, 2000)
|
|
||||||
}
|
}
|
||||||
|
document.addEventListener("nav", () => mountGameCultGraph())
|
||||||
document.addEventListener("nav", scheduleGameCultGraphMount)
|
|
||||||
document.addEventListener("DOMContentLoaded", scheduleGameCultGraphMount)
|
|
||||||
scheduleGameCultGraphMount()
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ export { Assets } from "./assets"
|
||||||
export { Static } from "./static"
|
export { Static } from "./static"
|
||||||
export { Favicon } from "./favicon"
|
export { Favicon } from "./favicon"
|
||||||
export { ComponentResources } from "./componentResources"
|
export { ComponentResources } from "./componentResources"
|
||||||
export { InkEmbedder } from "./inkEmbedder"
|
|
||||||
export { NotFoundPage } from "./404"
|
export { NotFoundPage } from "./404"
|
||||||
export { CNAME } from "./cname"
|
export { CNAME } from "./cname"
|
||||||
export { CustomOgImages } from "./ogImage"
|
export { CustomOgImages } from "./ogImage"
|
||||||
|
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
import { QuartzEmitterPlugin } from "../types"
|
|
||||||
import { FilePath, joinSegments } from "../../util/path"
|
|
||||||
import { createRequire } from "module"
|
|
||||||
import fs from "fs"
|
|
||||||
import path from "path"
|
|
||||||
|
|
||||||
export interface InkEmbedderOptions {
|
|
||||||
scriptSrc?: string
|
|
||||||
styleSrc?: string
|
|
||||||
runtimeSrc?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultOptions: Required<InkEmbedderOptions> = {
|
|
||||||
scriptSrc: "/static/interactive/sai.js",
|
|
||||||
styleSrc: "/static/interactive/sai.css",
|
|
||||||
runtimeSrc: "/static/interactive/ink.js",
|
|
||||||
}
|
|
||||||
|
|
||||||
const require = createRequire(import.meta.url)
|
|
||||||
|
|
||||||
function resolveSaiDistPath(filename: string) {
|
|
||||||
return path.join(path.dirname(require.resolve("@gamecult/sai/sai.js")), filename)
|
|
||||||
}
|
|
||||||
|
|
||||||
function localStaticDest(outputRoot: string, resourcePath: string) {
|
|
||||||
if (!resourcePath.startsWith("/static/")) return null
|
|
||||||
return joinSegments(outputRoot, resourcePath.slice(1)) as FilePath
|
|
||||||
}
|
|
||||||
|
|
||||||
async function copySaiAsset(outputRoot: string, resourcePath: string, filename: string) {
|
|
||||||
const dest = localStaticDest(outputRoot, resourcePath)
|
|
||||||
if (!dest) return null
|
|
||||||
|
|
||||||
await fs.promises.mkdir(path.dirname(dest), { recursive: true })
|
|
||||||
await fs.promises.copyFile(resolveSaiDistPath(filename), dest)
|
|
||||||
return dest
|
|
||||||
}
|
|
||||||
|
|
||||||
export const InkEmbedder: QuartzEmitterPlugin<InkEmbedderOptions> = (opts) => {
|
|
||||||
const options = { ...defaultOptions, ...opts }
|
|
||||||
|
|
||||||
return {
|
|
||||||
name: "InkEmbedder",
|
|
||||||
async *emit({ argv }) {
|
|
||||||
const copied = await Promise.all([
|
|
||||||
copySaiAsset(argv.output, options.scriptSrc, "sai.js"),
|
|
||||||
copySaiAsset(argv.output, options.styleSrc, "sai.css"),
|
|
||||||
copySaiAsset(argv.output, options.runtimeSrc, "ink.js"),
|
|
||||||
])
|
|
||||||
|
|
||||||
for (const dest of copied) {
|
|
||||||
if (dest) yield dest
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async *partialEmit() {},
|
|
||||||
externalResources: () => ({
|
|
||||||
css: [
|
|
||||||
{
|
|
||||||
content: options.styleSrc,
|
|
||||||
spaPreserve: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
js: [
|
|
||||||
{
|
|
||||||
src: options.scriptSrc,
|
|
||||||
loadTime: "afterDOMReady",
|
|
||||||
contentType: "external",
|
|
||||||
spaPreserve: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { QuartzEmitterPlugin } from "../types"
|
import { QuartzEmitterPlugin } from "../types"
|
||||||
import { i18n } from "../../i18n"
|
import { i18n } from "../../i18n"
|
||||||
import { unescapeHTML } from "../../util/escape"
|
import { unescapeHTML } from "../../util/escape"
|
||||||
import { FullSlug, getFileExtension, isAbsoluteURL, joinSegments, QUARTZ } from "../../util/path"
|
import { FullSlug, getFileExtension, isAbsoluteURL } from "../../util/path"
|
||||||
import { ImageOptions, SocialImageOptions, defaultImage, getSatoriFonts } from "../../util/og"
|
import { ImageOptions, SocialImageOptions, defaultImage, getSatoriFonts } from "../../util/og"
|
||||||
import sharp from "sharp"
|
import sharp from "sharp"
|
||||||
import satori, { SatoriOptions } from "satori"
|
import satori, { SatoriOptions } from "satori"
|
||||||
|
|
@ -12,12 +12,12 @@ import { BuildCtx } from "../../util/ctx"
|
||||||
import { QuartzPluginData } from "../vfile"
|
import { QuartzPluginData } from "../vfile"
|
||||||
import fs from "node:fs/promises"
|
import fs from "node:fs/promises"
|
||||||
import { styleText } from "util"
|
import { styleText } from "util"
|
||||||
|
import { SiteSocialMetadata } from "../../util/siteOg"
|
||||||
import {
|
import {
|
||||||
resolveSocialDeck,
|
resolveSocialDeck,
|
||||||
resolveSocialDescription,
|
resolveSocialDescription,
|
||||||
resolveSocialImage,
|
resolveSocialImage,
|
||||||
resolveSocialMetadata,
|
resolveSocialMetadata,
|
||||||
resolveSocialSection,
|
|
||||||
socialImageLocalPath,
|
socialImageLocalPath,
|
||||||
socialImageUrl,
|
socialImageUrl,
|
||||||
} from "../../util/social"
|
} from "../../util/social"
|
||||||
|
|
@ -51,21 +51,13 @@ function imageMimeType(filePath: string) {
|
||||||
* @param opts options for generating image
|
* @param opts options for generating image
|
||||||
*/
|
*/
|
||||||
async function generateSocialImage(
|
async function generateSocialImage(
|
||||||
{ cfg, description, deck, section, fonts, title, fileData }: ImageOptions,
|
{ cfg, description, deck, fonts, title, fileData }: ImageOptions,
|
||||||
userOpts: SocialImageOptions,
|
userOpts: SocialImageOptions,
|
||||||
|
socialMetadata: SiteSocialMetadata = resolveSocialMetadata(fileData),
|
||||||
): Promise<Readable> {
|
): Promise<Readable> {
|
||||||
const { width, height } = userOpts
|
const { width, height } = userOpts
|
||||||
const iconPath = joinSegments(QUARTZ, "static", "icon.png")
|
|
||||||
let iconBase64: string | undefined = undefined
|
|
||||||
let imageBase64: string | undefined = undefined
|
let imageBase64: string | undefined = undefined
|
||||||
try {
|
|
||||||
const iconData = await fs.readFile(iconPath)
|
|
||||||
iconBase64 = `data:image/png;base64,${iconData.toString("base64")}`
|
|
||||||
} catch (err) {
|
|
||||||
console.warn(styleText("yellow", `Warning: Could not find icon at ${iconPath}`))
|
|
||||||
}
|
|
||||||
|
|
||||||
const socialMetadata = resolveSocialMetadata(fileData)
|
|
||||||
const socialImage = resolveSocialImage(fileData, socialMetadata)
|
const socialImage = resolveSocialImage(fileData, socialMetadata)
|
||||||
const localImagePath = socialImageLocalPath(fileData, socialImage)
|
const localImagePath = socialImageLocalPath(fileData, socialImage)
|
||||||
|
|
||||||
|
|
@ -91,10 +83,8 @@ async function generateSocialImage(
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
deck,
|
deck,
|
||||||
section,
|
|
||||||
fonts,
|
fonts,
|
||||||
fileData,
|
fileData,
|
||||||
iconBase64,
|
|
||||||
imageBase64,
|
imageBase64,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -129,21 +119,20 @@ async function processOgImage(
|
||||||
fileData,
|
fileData,
|
||||||
unescapeHTML(i18n(cfg.locale).propertyDefaults.description),
|
unescapeHTML(i18n(cfg.locale).propertyDefaults.description),
|
||||||
)
|
)
|
||||||
const siteMetadata = resolveSocialMetadata(fileData)
|
const socialMetadata = resolveSocialMetadata(fileData)
|
||||||
const deck = resolveSocialDeck(fileData, description, siteMetadata)
|
const deck = resolveSocialDeck(fileData, description, socialMetadata)
|
||||||
const section = resolveSocialSection(fileData, siteMetadata)
|
|
||||||
|
|
||||||
const stream = await generateSocialImage(
|
const stream = await generateSocialImage(
|
||||||
{
|
{
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
deck,
|
deck,
|
||||||
section,
|
|
||||||
fonts,
|
fonts,
|
||||||
cfg,
|
cfg,
|
||||||
fileData,
|
fileData,
|
||||||
},
|
},
|
||||||
fullOptions,
|
fullOptions,
|
||||||
|
socialMetadata,
|
||||||
)
|
)
|
||||||
|
|
||||||
return write({
|
return write({
|
||||||
|
|
@ -204,11 +193,15 @@ export const CustomOgImages: QuartzEmitterPlugin<Partial<SocialImageOptions>> =
|
||||||
const generatedOgImagePath = useGeneratedCard
|
const generatedOgImagePath = useGeneratedCard
|
||||||
? `https://${baseUrl}/${pageData.slug!}-og-image.webp`
|
? `https://${baseUrl}/${pageData.slug!}-og-image.webp`
|
||||||
: undefined
|
: undefined
|
||||||
const pageSiteMetadata = resolveSocialMetadata(pageData)
|
|
||||||
const pageSocialImage = resolveSocialImage(pageData, pageSiteMetadata)
|
|
||||||
const imageFromMetadata = socialImageUrl(baseUrl, pageData, pageSocialImage)
|
|
||||||
const defaultOgImagePath = `https://${baseUrl}/static/og-image.png`
|
const defaultOgImagePath = `https://${baseUrl}/static/og-image.png`
|
||||||
const ogImagePath = generatedOgImagePath ?? imageFromMetadata ?? defaultOgImagePath
|
const ogImagePath =
|
||||||
|
generatedOgImagePath ??
|
||||||
|
socialImageUrl(
|
||||||
|
baseUrl,
|
||||||
|
pageData,
|
||||||
|
resolveSocialImage(pageData, resolveSocialMetadata(pageData)),
|
||||||
|
) ??
|
||||||
|
defaultOgImagePath
|
||||||
const ogImageMimeType = imageMimeType(ogImagePath)
|
const ogImageMimeType = imageMimeType(ogImagePath)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
|
|
@ -107,3 +107,35 @@ test("extractDescriptionText keeps the first paragraph when it is normal content
|
||||||
"This first paragraph is the actual summary, not decorative throat-clearing.",
|
"This first paragraph is the actual summary, not decorative throat-clearing.",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("extractDescriptionText keeps an unquoted emphasized opening paragraph", () => {
|
||||||
|
const tree: Root = {
|
||||||
|
type: "root",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
type: "element",
|
||||||
|
tagName: "h1",
|
||||||
|
properties: {},
|
||||||
|
children: [{ type: "text", value: "Why Aetheria Went Quiet" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "element",
|
||||||
|
tagName: "p",
|
||||||
|
properties: {},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
type: "element",
|
||||||
|
tagName: "em",
|
||||||
|
properties: {},
|
||||||
|
children: [{ type: "text", value: "This opening note is emphasized, not a tagline." }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
extractDescriptionText(tree, "Why Aetheria Went Quiet"),
|
||||||
|
"This opening note is emphasized, not a tagline.",
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { Element, Root as HTMLRoot, RootContent } from "hast"
|
||||||
import { toString } from "hast-util-to-string"
|
import { toString } from "hast-util-to-string"
|
||||||
import { QuartzTransformerPlugin } from "../types"
|
import { QuartzTransformerPlugin } from "../types"
|
||||||
import { escapeHTML } from "../../util/escape"
|
import { escapeHTML } from "../../util/escape"
|
||||||
|
import { isStandaloneTagline } from "../../util/social"
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
descriptionLength: number
|
descriptionLength: number
|
||||||
|
|
@ -36,23 +37,6 @@ function isMeaningfulNode(node: RootContent): boolean {
|
||||||
return normalizeWhitespace(toString(node)).length > 0
|
return normalizeWhitespace(toString(node)).length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function isStandalonePreviewTagline(node: RootContent): boolean {
|
|
||||||
if (!isElementNode(node) || node.tagName !== "p") {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const meaningfulChildren = node.children.filter(
|
|
||||||
(child) => !(child.type === "text" && normalizeWhitespace(child.value).length === 0),
|
|
||||||
)
|
|
||||||
|
|
||||||
if (meaningfulChildren.length !== 1) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const onlyChild = meaningfulChildren[0]
|
|
||||||
return isElementNode(onlyChild) && ["em", "strong"].includes(onlyChild.tagName)
|
|
||||||
}
|
|
||||||
|
|
||||||
function isStructuredMetadataParagraph(node: RootContent): boolean {
|
function isStructuredMetadataParagraph(node: RootContent): boolean {
|
||||||
if (!isElementNode(node) || node.tagName !== "p") {
|
if (!isElementNode(node) || node.tagName !== "p") {
|
||||||
return false
|
return false
|
||||||
|
|
@ -80,7 +64,7 @@ export function extractDescriptionText(tree: HTMLRoot, pageTitle?: string): stri
|
||||||
startIdx++
|
startIdx++
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startIdx < children.length && pageTitle && isStandalonePreviewTagline(children[startIdx])) {
|
if (startIdx < children.length && pageTitle && isStandaloneTagline(children[startIdx])) {
|
||||||
startIdx++
|
startIdx++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ import { Options as TypstOptions } from "@myriaddreamin/rehype-typst"
|
||||||
interface Options {
|
interface Options {
|
||||||
renderEngine: "katex" | "mathjax" | "typst"
|
renderEngine: "katex" | "mathjax" | "typst"
|
||||||
customMacros: MacroType
|
customMacros: MacroType
|
||||||
katexOptions: Omit<KatexOptions, "macros" | "output">
|
// `output` defaults to "html"; "htmlAndMathml" adds MathML for screen readers (KaTeX hides it visually).
|
||||||
|
katexOptions: Omit<KatexOptions, "macros">
|
||||||
mathJaxOptions: Omit<MathjaxOptions, "macros">
|
mathJaxOptions: Omit<MathjaxOptions, "macros">
|
||||||
typstOptions: TypstOptions
|
typstOptions: TypstOptions
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,6 @@ export type SocialImageOptions = {
|
||||||
imageStructure: (
|
imageStructure: (
|
||||||
options: ImageOptions & {
|
options: ImageOptions & {
|
||||||
userOpts: UserOpts
|
userOpts: UserOpts
|
||||||
iconBase64?: string
|
|
||||||
imageBase64?: string
|
imageBase64?: string
|
||||||
},
|
},
|
||||||
) => JSXInternal.Element
|
) => JSXInternal.Element
|
||||||
|
|
@ -158,10 +157,6 @@ export type ImageOptions = {
|
||||||
* short deck/tagline to use inside the image card
|
* short deck/tagline to use inside the image card
|
||||||
*/
|
*/
|
||||||
deck: string
|
deck: string
|
||||||
/**
|
|
||||||
* section label for the card
|
|
||||||
*/
|
|
||||||
section?: string
|
|
||||||
/**
|
/**
|
||||||
* header + body font to be used when generating satori image (as promise to work around sync in component)
|
* header + body font to be used when generating satori image (as promise to work around sync in component)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ function stripSurroundingQuotes(value: string) {
|
||||||
.trim()
|
.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
function isStandaloneTagline(node: RootContent) {
|
export function isStandaloneTagline(node: RootContent): boolean {
|
||||||
if (!isElementNode(node) || node.tagName !== "p") {
|
if (!isElementNode(node) || node.tagName !== "p") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +44,7 @@ function isStandaloneTagline(node: RootContent) {
|
||||||
return taglinePattern.test(normalizeWhitespace(toString(child)))
|
return taglinePattern.test(normalizeWhitespace(toString(child)))
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractTopTagline(root?: HtmlRoot): string | undefined {
|
export function extractTopTagline(root?: HtmlRoot): string | undefined {
|
||||||
if (!root) {
|
if (!root) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
@ -173,24 +173,6 @@ export function resolveSocialDeck(
|
||||||
return description
|
return description
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveSocialSection(
|
|
||||||
fileData: QuartzPluginData,
|
|
||||||
siteMetadata = resolveSiteSocialMetadata(fileData),
|
|
||||||
): string {
|
|
||||||
if (
|
|
||||||
typeof fileData.frontmatter?.socialSection === "string" &&
|
|
||||||
fileData.frontmatter.socialSection
|
|
||||||
) {
|
|
||||||
return fileData.frontmatter.socialSection.trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (siteMetadata.section && siteMetadata.section.trim().length > 0) {
|
|
||||||
return siteMetadata.section.trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
export function resolveSocialImage(
|
export function resolveSocialImage(
|
||||||
fileData: QuartzPluginData,
|
fileData: QuartzPluginData,
|
||||||
siteMetadata = resolveSiteSocialMetadata(fileData),
|
siteMetadata = resolveSiteSocialMetadata(fileData),
|
||||||
|
|
|
||||||
|
|
@ -40,20 +40,6 @@ async function exists(targetPath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function linkNodeModules(graphRoot) {
|
|
||||||
const source = path.join(engineRoot, "node_modules")
|
|
||||||
const dest = path.join(graphRoot, "node_modules")
|
|
||||||
|
|
||||||
if (!(await exists(source))) {
|
|
||||||
throw new Error(
|
|
||||||
"GameCult-Quartz dependencies are missing. Run `npm ci` in the GameCult-Quartz repo first.",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
await fs.rm(dest, { recursive: true, force: true })
|
|
||||||
await fs.symlink(source, dest, "junction")
|
|
||||||
}
|
|
||||||
|
|
||||||
async function prepareNorn(nornRoot) {
|
async function prepareNorn(nornRoot) {
|
||||||
const viewerRoot = path.join(nornRoot, "web", "norn-viewer")
|
const viewerRoot = path.join(nornRoot, "web", "norn-viewer")
|
||||||
const revisionPath = path.join(engineRoot, "quartz", "graph-spa", "norn-revision.txt")
|
const revisionPath = path.join(engineRoot, "quartz", "graph-spa", "norn-revision.txt")
|
||||||
|
|
@ -186,7 +172,10 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
await buildNorn(norn)
|
await buildNorn(norn)
|
||||||
await linkNodeModules(graphRoot)
|
const vitePath = path.join(graphRoot, "node_modules", "vite", "bin", "vite.js")
|
||||||
|
if (!(await exists(vitePath))) {
|
||||||
|
throw new Error(`Graph SPA dependencies are missing. Run 'npm ci' in '${graphRoot}'.`)
|
||||||
|
}
|
||||||
await runProcess(
|
await runProcess(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
["./node_modules/vite/bin/vite.js", "build", "--base", "./"],
|
["./node_modules/vite/bin/vite.js", "build", "--base", "./"],
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ async function copyEngineScaffold(runtimeRoot) {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
filter: (candidate) => {
|
filter: (candidate) => {
|
||||||
const relative = path.relative(engineRoot, candidate).split(path.sep).join("/")
|
const relative = path.relative(engineRoot, candidate).split(path.sep).join("/")
|
||||||
return relative !== "quartz/graph-spa/node_modules"
|
return relative !== "quartz/graph-spa"
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue