Loading README.md +1 −0 Original line number Diff line number Diff line <!-- deno-fmt-ignore-file -->  Fedify: a fediverse server framework ==================================== Loading docs/_config.ts +41 −30 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import image from "lume_markdown_plugins/image.ts"; import externalLinks from "npm:markdown-it-external-links@0.0.6"; import callouts from "npm:markdown-it-obsidian-callouts@0.2.3"; import { maxWith } from "@std/collections"; import { SemVer, compare, format, parse } from "@std/semver"; import { compare, format, parse, SemVer } from "@std/semver"; const site = lume({}, { markdown: { Loading @@ -22,6 +22,8 @@ site.use(lumocs()); site.use(title()); site.use(image()); site.copy("img"); async function getPackageVersion(): Promise<string> { const response = await fetch("https://jsr.io/@fedify/fedify/meta.json"); const json = await response.json(); Loading Loading @@ -49,13 +51,13 @@ async function getApiSymbols( const response = await fetch( `https://jsr.io/api/scopes/fedify/packages/fedify/versions/${ encodeURIComponent(version) }/docs/search` }/docs/search`, ); const json = await response.json(); const types = Object.fromEntries( json.nodes.map( (node: { name: string; kind: SymbolType[] }) => [node.name, node.kind[0]] ) (node: { name: string; kind: SymbolType[] }) => [node.name, node.kind[0]], ), ); await kv.set(["api", version], types); return types; Loading @@ -66,13 +68,15 @@ async function getApiUrl( symbol: string, attr?: string, ): Promise<string | null> { const baseUrl = `https://jsr.io/@fedify/fedify@${version}/doc/~/${symbol}` const baseUrl = `https://jsr.io/@fedify/fedify@${version}/doc/~/${symbol}`; if (attr == null) return baseUrl; const kv = await Deno.openKv(); const cache = await kv.get<Record<string, string>>(["api", version, symbol]); let anchors: Record<string, string>; if (cache != null && cache.value != null && Array.isArray(cache.value) && cache.value.length > 0) { if ( cache != null && cache.value != null && Array.isArray(cache.value) && cache.value.length > 0 ) { anchors = cache.value; } else { const response = await fetch(baseUrl, { Loading @@ -80,7 +84,7 @@ async function getApiUrl( }); const html = await response.text(); const matches = html.matchAll( /\sid="((?:call_signature|property|accessor|method)_([A-Za-z_][A-Za-z0-9_]*?)(?:_\d+)?)"/g /\sid="((?:call_signature|property|accessor|method)_([A-Za-z_][A-Za-z0-9_]*?)(?:_\d+)?)"/g, ); anchors = {}; for (const match of matches) { Loading @@ -96,10 +100,15 @@ const version = await getPackageVersion(); const symbols = await getApiSymbols(version); site.process([".html"], async (pages) => { const pattern = /^(~)?([A-Za-z][A-Za-z0-9]*)(?:\.([a-z][A-Za-z0-9]*))?(\(\))?$/; for (const page of pages) if (page.document != null) for (const code of page.document.querySelectorAll<HTMLElement>(":not(a) > :not(a) > code")) { const pattern = /^(~)?([A-Za-z][A-Za-z0-9]*)(?:\.([a-z][A-Za-z0-9]*))?(\(\))?$/; for (const page of pages) { if (page.document != null) { for ( const code of page.document.querySelectorAll<HTMLElement>( ":not(a) > :not(a) > code", ) ) { if (code.innerText == null || code.innerText.includes("\n")) continue; const match = pattern.exec(code.innerText); if (match == null) continue; Loading @@ -108,7 +117,7 @@ site.process([".html"], async (pages) => { const apiUrl = await getApiUrl( version, symbol, attr attr, ); if (apiUrl == null) continue; const link = page.document.createElement("a"); Loading @@ -119,6 +128,8 @@ site.process([".html"], async (pages) => { : `${attr}${parens ?? ""}`; link.appendChild(code); } } } }); export default site; docs/_data.json +3 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ "title": "=title", "site": "Fedify", "lang": "en", "description": "=description" "description": "=description", "logo": "/img/logo.svg", "icon": "/img/logo.svg" }, "top_links": [ { Loading docs/_includes/head.njk +14 −0 Original line number Diff line number Diff line <link rel="icon" type="image/png" href="/img/favicon-192x192.png" sizes="192x192"> <link rel="icon" type="image/png" href="/img/favicon-32x32.png" sizes="32x32"> <style> :root { --font-size: 20px; } .navbar-logo { max-width: 4rem; max-height: 4rem; border-radius: 100%; border: 0.2rem solid gray; background-color: white; } .navbar-brand { font-size: 1.5rem; margin-left: 0; vertical-align: middle; } a.external-link:not(:has(img))::after { vertical-align: super; content: '↗'; Loading docs/img/favicon-192x192.png 0 → 100755 +8.83 KiB Loading image diff... Loading
README.md +1 −0 Original line number Diff line number Diff line <!-- deno-fmt-ignore-file -->  Fedify: a fediverse server framework ==================================== Loading
docs/_config.ts +41 −30 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import image from "lume_markdown_plugins/image.ts"; import externalLinks from "npm:markdown-it-external-links@0.0.6"; import callouts from "npm:markdown-it-obsidian-callouts@0.2.3"; import { maxWith } from "@std/collections"; import { SemVer, compare, format, parse } from "@std/semver"; import { compare, format, parse, SemVer } from "@std/semver"; const site = lume({}, { markdown: { Loading @@ -22,6 +22,8 @@ site.use(lumocs()); site.use(title()); site.use(image()); site.copy("img"); async function getPackageVersion(): Promise<string> { const response = await fetch("https://jsr.io/@fedify/fedify/meta.json"); const json = await response.json(); Loading Loading @@ -49,13 +51,13 @@ async function getApiSymbols( const response = await fetch( `https://jsr.io/api/scopes/fedify/packages/fedify/versions/${ encodeURIComponent(version) }/docs/search` }/docs/search`, ); const json = await response.json(); const types = Object.fromEntries( json.nodes.map( (node: { name: string; kind: SymbolType[] }) => [node.name, node.kind[0]] ) (node: { name: string; kind: SymbolType[] }) => [node.name, node.kind[0]], ), ); await kv.set(["api", version], types); return types; Loading @@ -66,13 +68,15 @@ async function getApiUrl( symbol: string, attr?: string, ): Promise<string | null> { const baseUrl = `https://jsr.io/@fedify/fedify@${version}/doc/~/${symbol}` const baseUrl = `https://jsr.io/@fedify/fedify@${version}/doc/~/${symbol}`; if (attr == null) return baseUrl; const kv = await Deno.openKv(); const cache = await kv.get<Record<string, string>>(["api", version, symbol]); let anchors: Record<string, string>; if (cache != null && cache.value != null && Array.isArray(cache.value) && cache.value.length > 0) { if ( cache != null && cache.value != null && Array.isArray(cache.value) && cache.value.length > 0 ) { anchors = cache.value; } else { const response = await fetch(baseUrl, { Loading @@ -80,7 +84,7 @@ async function getApiUrl( }); const html = await response.text(); const matches = html.matchAll( /\sid="((?:call_signature|property|accessor|method)_([A-Za-z_][A-Za-z0-9_]*?)(?:_\d+)?)"/g /\sid="((?:call_signature|property|accessor|method)_([A-Za-z_][A-Za-z0-9_]*?)(?:_\d+)?)"/g, ); anchors = {}; for (const match of matches) { Loading @@ -96,10 +100,15 @@ const version = await getPackageVersion(); const symbols = await getApiSymbols(version); site.process([".html"], async (pages) => { const pattern = /^(~)?([A-Za-z][A-Za-z0-9]*)(?:\.([a-z][A-Za-z0-9]*))?(\(\))?$/; for (const page of pages) if (page.document != null) for (const code of page.document.querySelectorAll<HTMLElement>(":not(a) > :not(a) > code")) { const pattern = /^(~)?([A-Za-z][A-Za-z0-9]*)(?:\.([a-z][A-Za-z0-9]*))?(\(\))?$/; for (const page of pages) { if (page.document != null) { for ( const code of page.document.querySelectorAll<HTMLElement>( ":not(a) > :not(a) > code", ) ) { if (code.innerText == null || code.innerText.includes("\n")) continue; const match = pattern.exec(code.innerText); if (match == null) continue; Loading @@ -108,7 +117,7 @@ site.process([".html"], async (pages) => { const apiUrl = await getApiUrl( version, symbol, attr attr, ); if (apiUrl == null) continue; const link = page.document.createElement("a"); Loading @@ -119,6 +128,8 @@ site.process([".html"], async (pages) => { : `${attr}${parens ?? ""}`; link.appendChild(code); } } } }); export default site;
docs/_data.json +3 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ "title": "=title", "site": "Fedify", "lang": "en", "description": "=description" "description": "=description", "logo": "/img/logo.svg", "icon": "/img/logo.svg" }, "top_links": [ { Loading
docs/_includes/head.njk +14 −0 Original line number Diff line number Diff line <link rel="icon" type="image/png" href="/img/favicon-192x192.png" sizes="192x192"> <link rel="icon" type="image/png" href="/img/favicon-32x32.png" sizes="32x32"> <style> :root { --font-size: 20px; } .navbar-logo { max-width: 4rem; max-height: 4rem; border-radius: 100%; border: 0.2rem solid gray; background-color: white; } .navbar-brand { font-size: 1.5rem; margin-left: 0; vertical-align: middle; } a.external-link:not(:has(img))::after { vertical-align: super; content: '↗'; Loading