@rimelight/seo 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets.d.mts +39 -0
- package/dist/assets.mjs +96 -0
- package/dist/catalog.d.mts +7 -0
- package/dist/catalog.mjs +10 -0
- package/dist/index.d.mts +9 -3
- package/dist/index.mjs +10 -2
- package/dist/integration.d.mts +3 -20
- package/dist/integration.mjs +257 -7
- package/dist/manifest.d.mts +7 -0
- package/dist/manifest.mjs +44 -0
- package/dist/og.d.mts +117 -0
- package/dist/og.mjs +302 -0
- package/dist/routes/api-catalog.d.mts +5 -0
- package/dist/routes/api-catalog.mjs +38 -0
- package/dist/routes/apple-touch-icon.png.d.mts +5 -0
- package/dist/routes/apple-touch-icon.png.mjs +17 -0
- package/dist/routes/favicon.ico.d.mts +5 -0
- package/dist/routes/favicon.ico.mjs +14 -0
- package/dist/routes/favicon.svg.d.mts +5 -0
- package/dist/routes/favicon.svg.mjs +12 -0
- package/dist/routes/icon-192.png.d.mts +5 -0
- package/dist/routes/icon-192.png.mjs +17 -0
- package/dist/routes/icon-512.png.d.mts +5 -0
- package/dist/routes/icon-512.png.mjs +17 -0
- package/dist/routes/icon-maskable-512.png.d.mts +5 -0
- package/dist/routes/icon-maskable-512.png.mjs +18 -0
- package/dist/routes/llms-full.txt.d.mts +5 -0
- package/dist/routes/llms-full.txt.mjs +57 -0
- package/dist/routes/llms.txt.d.mts +1 -0
- package/dist/routes/llms.txt.mjs +60 -12
- package/dist/routes/robots.txt.mjs +32 -4
- package/dist/routes/rss.xml.d.mts +4 -0
- package/dist/routes/rss.xml.mjs +79 -0
- package/dist/routes/security.txt.d.mts +5 -0
- package/dist/routes/security.txt.mjs +24 -0
- package/dist/routes/site.webmanifest.d.mts +5 -0
- package/dist/routes/site.webmanifest.mjs +23 -0
- package/dist/routes/sitemap.xml.mjs +18 -4
- package/dist/rss.d.mts +8 -0
- package/dist/rss.mjs +44 -0
- package/dist/security.d.mts +7 -0
- package/dist/security.mjs +34 -0
- package/dist/types.d.mts +263 -3
- package/package.json +38 -3
- package/src/assets.test.ts +70 -0
- package/src/assets.ts +137 -0
- package/src/catalog.test.ts +26 -0
- package/src/catalog.ts +11 -0
- package/src/components/SEOHead.astro +1 -1
- package/src/env.d.ts +51 -3
- package/src/index.ts +33 -2
- package/src/integration.ts +307 -28
- package/src/manifest.test.ts +41 -0
- package/src/manifest.ts +59 -0
- package/src/og.ts +436 -0
- package/src/routes/api-catalog.ts +55 -0
- package/src/routes/apple-touch-icon.png.ts +19 -0
- package/src/routes/favicon.ico.ts +19 -0
- package/src/routes/favicon.svg.ts +17 -0
- package/src/routes/icon-192.png.ts +19 -0
- package/src/routes/icon-512.png.ts +19 -0
- package/src/routes/icon-maskable-512.png.ts +24 -0
- package/src/routes/llms-full.txt.ts +77 -0
- package/src/routes/llms.txt.ts +84 -13
- package/src/routes/robots.txt.ts +47 -4
- package/src/routes/rss.xml.ts +129 -0
- package/src/routes/security.txt.ts +30 -0
- package/src/routes/site.webmanifest.ts +28 -0
- package/src/routes/sitemap.xml.ts +32 -5
- package/src/rss.test.ts +28 -0
- package/src/rss.ts +63 -0
- package/src/security.test.ts +46 -0
- package/src/security.ts +78 -0
- package/src/types.ts +286 -3
package/dist/og.d.mts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
//#region src/og.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Font configuration for OG image rendering. Pass to `loadOgFonts()` or `renderOgResponse()`.
|
|
4
|
+
*/
|
|
5
|
+
export interface OgFontConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Font-family name referenced in layout styles
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* URL to the regular-weight TTF
|
|
12
|
+
*/
|
|
13
|
+
regularUrl: string;
|
|
14
|
+
/**
|
|
15
|
+
* URL to the bold-weight TTF
|
|
16
|
+
*/
|
|
17
|
+
boldUrl: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Default font: Noto Sans from jsDelivr Fontsource CDN.
|
|
21
|
+
*/
|
|
22
|
+
export declare const NOTO_SANS: OgFontConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Options for the default OG image layout. Build your own layout instead via `renderOgResponse()`
|
|
25
|
+
* directly.
|
|
26
|
+
*/
|
|
27
|
+
export interface OgLayoutOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Main heading -- required
|
|
30
|
+
*/
|
|
31
|
+
title: string;
|
|
32
|
+
/**
|
|
33
|
+
* Subtitle / excerpt beneath the title
|
|
34
|
+
*/
|
|
35
|
+
description?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Branding shown top-left. Pass a plain string (site name) or a pre-built takumi-js VNode for a
|
|
38
|
+
* custom logo treatment.
|
|
39
|
+
*/
|
|
40
|
+
brand?: string | object;
|
|
41
|
+
/**
|
|
42
|
+
* Pill badge shown bottom-left. e.g. "Blog Post", "Documentation", "Legal"
|
|
43
|
+
*/
|
|
44
|
+
badge?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Date string shown bottom-right. e.g. new Date(postedAt).toLocaleDateString()
|
|
47
|
+
*/
|
|
48
|
+
date?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Background style. "dark" -> solid #0a0a0a (default) "gradient" -> diagonal dark-to-navy
|
|
51
|
+
* gradient any string -> treated as a CSS `background` value
|
|
52
|
+
*/
|
|
53
|
+
background?: "dark" | "gradient" | (string & {});
|
|
54
|
+
/**
|
|
55
|
+
* When true, overlays a dashed red PREVIEW border. Useful during development.
|
|
56
|
+
*/
|
|
57
|
+
preview?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Rendering config shared by `renderOgResponse()` and `renderDefaultOg()`.
|
|
61
|
+
*/
|
|
62
|
+
export interface OgRenderConfig {
|
|
63
|
+
/**
|
|
64
|
+
* Font to embed -- defaults to `NOTO_SANS`
|
|
65
|
+
*/
|
|
66
|
+
font?: OgFontConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Image width in px -- defaults to 1200
|
|
69
|
+
*/
|
|
70
|
+
width?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Image height in px -- defaults to 630
|
|
73
|
+
*/
|
|
74
|
+
height?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Fetches and caches the regular + bold TTF buffers for the given font config. Uses a module-level
|
|
78
|
+
* cache keyed on `regularUrl`, so repeated calls within the same Worker lifetime are free after the
|
|
79
|
+
* first fetch.
|
|
80
|
+
*/
|
|
81
|
+
export declare function loadOgFonts(config?: OgFontConfig, timeoutMs?: number): Promise<{
|
|
82
|
+
regular: ArrayBuffer;
|
|
83
|
+
bold: ArrayBuffer;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Builds a takumi-js-compatible VNode for the default Rimelight OG layout.
|
|
87
|
+
*
|
|
88
|
+
* Consumers that need a fully custom look should build their own VNode and call
|
|
89
|
+
* `renderOgResponse()` directly -- this function is just the house style.
|
|
90
|
+
*/
|
|
91
|
+
export declare function defaultOgLayout(options: OgLayoutOptions, font?: OgFontConfig): object;
|
|
92
|
+
/**
|
|
93
|
+
* Renders any takumi-js VNode to a PNG `Response` with standard OG headers. Use this when you
|
|
94
|
+
* supply your own layout entirely.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* const vnode = myBrandedLayout({ title, description })
|
|
98
|
+
* return renderOgResponse(vnode, { font: MY_FONT })
|
|
99
|
+
*/
|
|
100
|
+
export declare function renderOgResponse(vnode: object, config?: OgRenderConfig): Promise<Response>;
|
|
101
|
+
/**
|
|
102
|
+
* Renders the default OG layout to a PNG `Response`. The 90% case -- use `renderOgResponse()` for
|
|
103
|
+
* full layout control.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* export const GET: APIRoute = async ({ request }) => {
|
|
107
|
+
* const url = new URL(request.url)
|
|
108
|
+
* return renderDefaultOg({
|
|
109
|
+
* title: url.searchParams.get("title") ?? "Untitled",
|
|
110
|
+
* description: url.searchParams.get("description") ?? "",
|
|
111
|
+
* brand: "My Site",
|
|
112
|
+
* badge: url.searchParams.get("type") ?? ""
|
|
113
|
+
* })
|
|
114
|
+
* }
|
|
115
|
+
*/
|
|
116
|
+
export declare function renderDefaultOg(options: OgLayoutOptions, config?: OgRenderConfig): Promise<Response>;
|
|
117
|
+
//#endregion
|
package/dist/og.mjs
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
//#region src/og.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default font: Noto Sans from jsDelivr Fontsource CDN.
|
|
4
|
+
*/
|
|
5
|
+
const NOTO_SANS = {
|
|
6
|
+
name: "Noto Sans",
|
|
7
|
+
regularUrl: "https://cdn.jsdelivr.net/fontsource/fonts/noto-sans@latest/latin-400-normal.ttf",
|
|
8
|
+
boldUrl: "https://cdn.jsdelivr.net/fontsource/fonts/noto-sans@latest/latin-700-normal.ttf"
|
|
9
|
+
};
|
|
10
|
+
const fontCaches = /* @__PURE__ */ new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Fetches an ArrayBuffer with a timeout.
|
|
13
|
+
*/
|
|
14
|
+
async function fetchArrayBuffer(url, timeoutMs = 5e3) {
|
|
15
|
+
const controller = new AbortController();
|
|
16
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
17
|
+
try {
|
|
18
|
+
const res = await fetch(url, { signal: controller.signal });
|
|
19
|
+
if (!res.ok) throw new Error(`Failed to fetch font from ${url}: status ${res.status}`);
|
|
20
|
+
return await res.arrayBuffer();
|
|
21
|
+
} finally {
|
|
22
|
+
clearTimeout(timeoutId);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fetches and caches the regular + bold TTF buffers for the given font config. Uses a module-level
|
|
27
|
+
* cache keyed on `regularUrl`, so repeated calls within the same Worker lifetime are free after the
|
|
28
|
+
* first fetch.
|
|
29
|
+
*/
|
|
30
|
+
async function loadOgFonts(config = NOTO_SANS, timeoutMs = 5e3) {
|
|
31
|
+
const cached = fontCaches.get(config.regularUrl);
|
|
32
|
+
if (cached) return cached;
|
|
33
|
+
const [regular, bold] = await Promise.all([fetchArrayBuffer(config.regularUrl, timeoutMs), fetchArrayBuffer(config.boldUrl, timeoutMs)]);
|
|
34
|
+
const result = {
|
|
35
|
+
regular,
|
|
36
|
+
bold
|
|
37
|
+
};
|
|
38
|
+
fontCaches.set(config.regularUrl, result);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Builds a takumi-js-compatible VNode for the default Rimelight OG layout.
|
|
43
|
+
*
|
|
44
|
+
* Consumers that need a fully custom look should build their own VNode and call
|
|
45
|
+
* `renderOgResponse()` directly -- this function is just the house style.
|
|
46
|
+
*/
|
|
47
|
+
function defaultOgLayout(options, font = NOTO_SANS) {
|
|
48
|
+
const { title, description, brand, badge, date, background = "dark", preview = false } = options;
|
|
49
|
+
const MAX_TITLE_LEN = 160;
|
|
50
|
+
const MAX_DESC_LEN = 240;
|
|
51
|
+
const safeTitle = title.length > MAX_TITLE_LEN ? title.slice(0, 159) + "…" : title;
|
|
52
|
+
const safeDescription = description && description.length > MAX_DESC_LEN ? description.slice(0, 239) + "…" : description;
|
|
53
|
+
const bg = background === "dark" ? { backgroundColor: "#0a0a0a" } : background === "gradient" ? { background: "linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%)" } : { background };
|
|
54
|
+
const isGradient = background !== "dark";
|
|
55
|
+
const brandNode = typeof brand === "object" && brand !== null ? brand : {
|
|
56
|
+
type: "span",
|
|
57
|
+
props: {
|
|
58
|
+
style: {
|
|
59
|
+
fontSize: "28px",
|
|
60
|
+
fontWeight: 700,
|
|
61
|
+
color: "#ffffff",
|
|
62
|
+
letterSpacing: "-0.02em"
|
|
63
|
+
},
|
|
64
|
+
children: brand ?? ""
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const accentBar = isGradient ? {
|
|
68
|
+
type: "div",
|
|
69
|
+
props: { style: {
|
|
70
|
+
width: "60px",
|
|
71
|
+
height: "4px",
|
|
72
|
+
backgroundColor: "#60a5fa",
|
|
73
|
+
borderRadius: "2px",
|
|
74
|
+
marginBottom: "16px"
|
|
75
|
+
} }
|
|
76
|
+
} : null;
|
|
77
|
+
const titleFontSize = isGradient ? "52px" : "56px";
|
|
78
|
+
const descColor = isGradient ? "#94a3b8" : "#a0a0a0";
|
|
79
|
+
const descFontSize = isGradient ? "22px" : "24px";
|
|
80
|
+
const badgeNode = badge ? isGradient ? {
|
|
81
|
+
type: "div",
|
|
82
|
+
props: {
|
|
83
|
+
style: {
|
|
84
|
+
padding: "6px 16px",
|
|
85
|
+
borderRadius: "9999px",
|
|
86
|
+
backgroundColor: "rgba(96,165,250,0.15)",
|
|
87
|
+
border: "1px solid rgba(96,165,250,0.3)",
|
|
88
|
+
fontSize: "14px",
|
|
89
|
+
fontWeight: 600,
|
|
90
|
+
color: "#93c5fd"
|
|
91
|
+
},
|
|
92
|
+
children: badge
|
|
93
|
+
}
|
|
94
|
+
} : {
|
|
95
|
+
type: "div",
|
|
96
|
+
props: {
|
|
97
|
+
style: {
|
|
98
|
+
padding: "8px 20px",
|
|
99
|
+
borderRadius: "9999px",
|
|
100
|
+
border: "1px solid #333333",
|
|
101
|
+
fontSize: "16px",
|
|
102
|
+
fontWeight: 600,
|
|
103
|
+
color: "#e5e5e5"
|
|
104
|
+
},
|
|
105
|
+
children: badge
|
|
106
|
+
}
|
|
107
|
+
} : null;
|
|
108
|
+
const dateNode = date ? {
|
|
109
|
+
type: "div",
|
|
110
|
+
props: {
|
|
111
|
+
style: {
|
|
112
|
+
fontSize: "16px",
|
|
113
|
+
color: "#666666"
|
|
114
|
+
},
|
|
115
|
+
children: date
|
|
116
|
+
}
|
|
117
|
+
} : null;
|
|
118
|
+
const previewOverlay = preview ? {
|
|
119
|
+
type: "div",
|
|
120
|
+
props: { style: {
|
|
121
|
+
position: "absolute",
|
|
122
|
+
inset: 0,
|
|
123
|
+
border: "6px dashed #ff4444",
|
|
124
|
+
pointerEvents: "none"
|
|
125
|
+
} }
|
|
126
|
+
} : null;
|
|
127
|
+
const previewLabel = preview ? {
|
|
128
|
+
type: "div",
|
|
129
|
+
props: {
|
|
130
|
+
style: {
|
|
131
|
+
position: "absolute",
|
|
132
|
+
top: "12px",
|
|
133
|
+
right: "12px",
|
|
134
|
+
backgroundColor: "#ff4444",
|
|
135
|
+
color: "#ffffff",
|
|
136
|
+
fontSize: "14px",
|
|
137
|
+
fontWeight: 700,
|
|
138
|
+
padding: "6px 16px",
|
|
139
|
+
borderRadius: "4px",
|
|
140
|
+
letterSpacing: "0.05em"
|
|
141
|
+
},
|
|
142
|
+
children: "PREVIEW"
|
|
143
|
+
}
|
|
144
|
+
} : null;
|
|
145
|
+
return {
|
|
146
|
+
type: "div",
|
|
147
|
+
props: {
|
|
148
|
+
style: {
|
|
149
|
+
width: "100%",
|
|
150
|
+
height: "100%",
|
|
151
|
+
display: "flex",
|
|
152
|
+
flexDirection: "column",
|
|
153
|
+
padding: "56px",
|
|
154
|
+
color: "#e5e5e5",
|
|
155
|
+
fontFamily: font.name,
|
|
156
|
+
position: "relative",
|
|
157
|
+
overflow: "hidden",
|
|
158
|
+
...bg
|
|
159
|
+
},
|
|
160
|
+
children: [
|
|
161
|
+
{
|
|
162
|
+
type: "div",
|
|
163
|
+
props: {
|
|
164
|
+
style: {
|
|
165
|
+
display: "flex",
|
|
166
|
+
alignItems: "center"
|
|
167
|
+
},
|
|
168
|
+
children: [brandNode]
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
type: "div",
|
|
173
|
+
props: {
|
|
174
|
+
style: {
|
|
175
|
+
display: "flex",
|
|
176
|
+
flexDirection: "column",
|
|
177
|
+
justifyContent: "center",
|
|
178
|
+
flexGrow: 1,
|
|
179
|
+
paddingTop: "24px"
|
|
180
|
+
},
|
|
181
|
+
children: [
|
|
182
|
+
accentBar,
|
|
183
|
+
{
|
|
184
|
+
type: "div",
|
|
185
|
+
props: {
|
|
186
|
+
style: {
|
|
187
|
+
fontSize: titleFontSize,
|
|
188
|
+
fontWeight: 700,
|
|
189
|
+
color: "#ffffff",
|
|
190
|
+
lineHeight: 1.15,
|
|
191
|
+
maxWidth: "950px"
|
|
192
|
+
},
|
|
193
|
+
children: safeTitle
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
safeDescription ? {
|
|
197
|
+
type: "div",
|
|
198
|
+
props: {
|
|
199
|
+
style: {
|
|
200
|
+
fontSize: descFontSize,
|
|
201
|
+
fontWeight: 400,
|
|
202
|
+
color: descColor,
|
|
203
|
+
marginTop: isGradient ? "12px" : "16px",
|
|
204
|
+
lineHeight: 1.4,
|
|
205
|
+
maxWidth: isGradient ? "800px" : "850px"
|
|
206
|
+
},
|
|
207
|
+
children: safeDescription
|
|
208
|
+
}
|
|
209
|
+
} : null
|
|
210
|
+
].filter(Boolean)
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
type: "div",
|
|
215
|
+
props: {
|
|
216
|
+
style: {
|
|
217
|
+
display: "flex",
|
|
218
|
+
alignItems: "center",
|
|
219
|
+
justifyContent: isGradient ? "flex-start" : "space-between",
|
|
220
|
+
gap: "12px",
|
|
221
|
+
marginTop: "auto"
|
|
222
|
+
},
|
|
223
|
+
children: [badgeNode, dateNode].filter(Boolean)
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
previewOverlay,
|
|
227
|
+
previewLabel
|
|
228
|
+
].filter(Boolean)
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Renders any takumi-js VNode to a PNG `Response` with standard OG headers. Use this when you
|
|
234
|
+
* supply your own layout entirely.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* const vnode = myBrandedLayout({ title, description })
|
|
238
|
+
* return renderOgResponse(vnode, { font: MY_FONT })
|
|
239
|
+
*/
|
|
240
|
+
async function renderOgResponse(vnode, config = {}) {
|
|
241
|
+
const { font = NOTO_SANS, width = 1200, height = 630 } = config;
|
|
242
|
+
try {
|
|
243
|
+
const { render } = await import("takumi-js");
|
|
244
|
+
const { regular, bold } = await loadOgFonts(font);
|
|
245
|
+
const pngBuffer = await render(vnode, {
|
|
246
|
+
width,
|
|
247
|
+
height,
|
|
248
|
+
fonts: [{
|
|
249
|
+
name: font.name,
|
|
250
|
+
data: regular,
|
|
251
|
+
weight: 400,
|
|
252
|
+
style: "normal"
|
|
253
|
+
}, {
|
|
254
|
+
name: font.name,
|
|
255
|
+
data: bold,
|
|
256
|
+
weight: 700,
|
|
257
|
+
style: "normal"
|
|
258
|
+
}]
|
|
259
|
+
});
|
|
260
|
+
return new Response(new Blob([new Uint8Array(pngBuffer)], { type: "image/png" }), {
|
|
261
|
+
status: 200,
|
|
262
|
+
headers: {
|
|
263
|
+
"Content-Type": "image/png",
|
|
264
|
+
"Cache-Control": "public, max-age=31536000, immutable",
|
|
265
|
+
"CDN-Cache-Control": "public, max-age=31536000"
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
} catch (error) {
|
|
269
|
+
console.error("[OG Render Error]:", error);
|
|
270
|
+
return new Response(JSON.stringify({
|
|
271
|
+
error: "Failed to render Open Graph image",
|
|
272
|
+
message: error instanceof Error ? error.message : String(error)
|
|
273
|
+
}), {
|
|
274
|
+
status: 500,
|
|
275
|
+
headers: {
|
|
276
|
+
"Content-Type": "application/json",
|
|
277
|
+
"Cache-Control": "no-store"
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Renders the default OG layout to a PNG `Response`. The 90% case -- use `renderOgResponse()` for
|
|
284
|
+
* full layout control.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* export const GET: APIRoute = async ({ request }) => {
|
|
288
|
+
* const url = new URL(request.url)
|
|
289
|
+
* return renderDefaultOg({
|
|
290
|
+
* title: url.searchParams.get("title") ?? "Untitled",
|
|
291
|
+
* description: url.searchParams.get("description") ?? "",
|
|
292
|
+
* brand: "My Site",
|
|
293
|
+
* badge: url.searchParams.get("type") ?? ""
|
|
294
|
+
* })
|
|
295
|
+
* }
|
|
296
|
+
*/
|
|
297
|
+
async function renderDefaultOg(options, config = {}) {
|
|
298
|
+
const { font = NOTO_SANS } = config;
|
|
299
|
+
return renderOgResponse(defaultOgLayout(options, font), config);
|
|
300
|
+
}
|
|
301
|
+
//#endregion
|
|
302
|
+
export { NOTO_SANS, defaultOgLayout, loadOgFonts, renderDefaultOg, renderOgResponse };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { buildApiCatalog } from "../catalog.mjs";
|
|
2
|
+
import seoOptions from "virtual:rimelight-seo/options";
|
|
3
|
+
//#region src/routes/api-catalog.ts
|
|
4
|
+
const prerender = false;
|
|
5
|
+
const GET = () => {
|
|
6
|
+
const catalogOpts = typeof seoOptions?.apiCatalog === "object" ? seoOptions.apiCatalog : {};
|
|
7
|
+
const defaultItems = [{
|
|
8
|
+
rel: "self",
|
|
9
|
+
href: "/.well-known/api-catalog",
|
|
10
|
+
type: "application/linkset+json"
|
|
11
|
+
}];
|
|
12
|
+
if (seoOptions?.sitemap !== false) defaultItems.push({
|
|
13
|
+
rel: "alternate",
|
|
14
|
+
href: "/sitemap.xml",
|
|
15
|
+
type: "application/xml",
|
|
16
|
+
title: "Sitemap"
|
|
17
|
+
});
|
|
18
|
+
if (seoOptions?.rss !== false) defaultItems.push({
|
|
19
|
+
rel: "alternate",
|
|
20
|
+
href: "/rss.xml",
|
|
21
|
+
type: "application/rss+xml",
|
|
22
|
+
title: "RSS Feed"
|
|
23
|
+
});
|
|
24
|
+
if (seoOptions?.llms !== false) defaultItems.push({
|
|
25
|
+
rel: "llms",
|
|
26
|
+
href: "/llms.txt",
|
|
27
|
+
type: "text/plain",
|
|
28
|
+
title: "LLMs.txt"
|
|
29
|
+
});
|
|
30
|
+
const items = catalogOpts.items || defaultItems;
|
|
31
|
+
const catalog = buildApiCatalog({ items });
|
|
32
|
+
return new Response(JSON.stringify(catalog, null, 2), { headers: {
|
|
33
|
+
"Content-Type": "application/linkset+json; charset=utf-8",
|
|
34
|
+
"Cache-Control": "public, max-age=86400, stale-while-revalidate=604800"
|
|
35
|
+
} });
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { GET, prerender };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { generatePng } from "../assets.mjs";
|
|
2
|
+
import { masterIconBuffer } from "virtual:rimelight-seo/assets";
|
|
3
|
+
//#region src/routes/apple-touch-icon.png.ts
|
|
4
|
+
const prerender = true;
|
|
5
|
+
const GET = async () => {
|
|
6
|
+
if (!masterIconBuffer) return new Response(null, { status: 404 });
|
|
7
|
+
const png = await generatePng(masterIconBuffer, {
|
|
8
|
+
width: 180,
|
|
9
|
+
height: 180
|
|
10
|
+
});
|
|
11
|
+
return new Response(new Uint8Array(png), { headers: {
|
|
12
|
+
"Content-Type": "image/png",
|
|
13
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
14
|
+
} });
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { GET, prerender };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { generateIco } from "../assets.mjs";
|
|
2
|
+
import { masterIconBuffer } from "virtual:rimelight-seo/assets";
|
|
3
|
+
//#region src/routes/favicon.ico.ts
|
|
4
|
+
const prerender = true;
|
|
5
|
+
const GET = async () => {
|
|
6
|
+
if (!masterIconBuffer) return new Response(null, { status: 404 });
|
|
7
|
+
const ico = await generateIco(masterIconBuffer, 32);
|
|
8
|
+
return new Response(new Uint8Array(ico), { headers: {
|
|
9
|
+
"Content-Type": "image/x-icon",
|
|
10
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
11
|
+
} });
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { GET, prerender };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isSvg, masterIconBuffer } from "virtual:rimelight-seo/assets";
|
|
2
|
+
//#region src/routes/favicon.svg.ts
|
|
3
|
+
const prerender = true;
|
|
4
|
+
const GET = async () => {
|
|
5
|
+
if (!masterIconBuffer || !isSvg) return new Response(null, { status: 404 });
|
|
6
|
+
return new Response(new Uint8Array(masterIconBuffer), { headers: {
|
|
7
|
+
"Content-Type": "image/svg+xml",
|
|
8
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
9
|
+
} });
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GET, prerender };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { generatePng } from "../assets.mjs";
|
|
2
|
+
import { masterIconBuffer } from "virtual:rimelight-seo/assets";
|
|
3
|
+
//#region src/routes/icon-192.png.ts
|
|
4
|
+
const prerender = true;
|
|
5
|
+
const GET = async () => {
|
|
6
|
+
if (!masterIconBuffer) return new Response(null, { status: 404 });
|
|
7
|
+
const png = await generatePng(masterIconBuffer, {
|
|
8
|
+
width: 192,
|
|
9
|
+
height: 192
|
|
10
|
+
});
|
|
11
|
+
return new Response(new Uint8Array(png), { headers: {
|
|
12
|
+
"Content-Type": "image/png",
|
|
13
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
14
|
+
} });
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { GET, prerender };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { generatePng } from "../assets.mjs";
|
|
2
|
+
import { masterIconBuffer } from "virtual:rimelight-seo/assets";
|
|
3
|
+
//#region src/routes/icon-512.png.ts
|
|
4
|
+
const prerender = true;
|
|
5
|
+
const GET = async () => {
|
|
6
|
+
if (!masterIconBuffer) return new Response(null, { status: 404 });
|
|
7
|
+
const png = await generatePng(masterIconBuffer, {
|
|
8
|
+
width: 512,
|
|
9
|
+
height: 512
|
|
10
|
+
});
|
|
11
|
+
return new Response(new Uint8Array(png), { headers: {
|
|
12
|
+
"Content-Type": "image/png",
|
|
13
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
14
|
+
} });
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { GET, prerender };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { generateMaskablePng } from "../assets.mjs";
|
|
2
|
+
import { backgroundColor, masterIconBuffer } from "virtual:rimelight-seo/assets";
|
|
3
|
+
//#region src/routes/icon-maskable-512.png.ts
|
|
4
|
+
const prerender = true;
|
|
5
|
+
const GET = async () => {
|
|
6
|
+
if (!masterIconBuffer) return new Response(null, { status: 404 });
|
|
7
|
+
const png = await generateMaskablePng(masterIconBuffer, {
|
|
8
|
+
size: 512,
|
|
9
|
+
background: backgroundColor || "#ffffff",
|
|
10
|
+
paddingRatio: .15
|
|
11
|
+
});
|
|
12
|
+
return new Response(new Uint8Array(png), { headers: {
|
|
13
|
+
"Content-Type": "image/png",
|
|
14
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
15
|
+
} });
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { GET, prerender };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as siteConfigMod from "virtual:rimelight-seo/site-config";
|
|
2
|
+
import * as dbMod from "virtual:rimelight-seo/db";
|
|
3
|
+
import * as corpusMod from "virtual:rimelight-seo/corpus";
|
|
4
|
+
//#region src/routes/llms-full.txt.ts
|
|
5
|
+
const prerender = false;
|
|
6
|
+
const GET = async ({ site, url }) => {
|
|
7
|
+
const siteConfig = siteConfigMod.siteConfig || {};
|
|
8
|
+
const siteUrl = site ? site.toString() : siteConfig.url || `${url.protocol}//${url.host}`;
|
|
9
|
+
const title = siteConfig.name ? `${siteConfig.name} Full Documentation Corpus` : "Full Documentation Corpus";
|
|
10
|
+
const description = "Complete single-corpus documentation for AI agents and LLM ingest.";
|
|
11
|
+
if (Array.isArray(corpusMod.corpusPages) && corpusMod.corpusPages.length > 0) {
|
|
12
|
+
const sections = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const p of corpusMod.corpusPages) {
|
|
14
|
+
const key = (p.section || "GENERAL").toUpperCase();
|
|
15
|
+
if (!sections.has(key)) sections.set(key, []);
|
|
16
|
+
const slug = p.slug === "index" ? "" : p.slug;
|
|
17
|
+
const pageUrl = `${siteUrl.replace(/\/$/, "")}/${slug}`.replace(/\/+$/, "");
|
|
18
|
+
sections.get(key).push(`### ${p.title}\nURL: ${pageUrl}\n${p.description || ""}`);
|
|
19
|
+
}
|
|
20
|
+
const body = [
|
|
21
|
+
`# ${title}`,
|
|
22
|
+
"",
|
|
23
|
+
description,
|
|
24
|
+
"",
|
|
25
|
+
...Array.from(sections.entries()).flatMap(([section, pages]) => [
|
|
26
|
+
`## ${section}`,
|
|
27
|
+
"",
|
|
28
|
+
...pages,
|
|
29
|
+
""
|
|
30
|
+
])
|
|
31
|
+
].join("\n");
|
|
32
|
+
return new Response(body, { headers: {
|
|
33
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
34
|
+
"Cache-Control": "public, max-age=3600, s-maxage=86400"
|
|
35
|
+
} });
|
|
36
|
+
}
|
|
37
|
+
if (dbMod.db) try {
|
|
38
|
+
const { renderCorpusMarkdown } = await import("@rimelight/cms");
|
|
39
|
+
const body = await renderCorpusMarkdown(dbMod.db, {
|
|
40
|
+
type: "doc",
|
|
41
|
+
locale: "en",
|
|
42
|
+
siteUrl,
|
|
43
|
+
title,
|
|
44
|
+
description
|
|
45
|
+
});
|
|
46
|
+
return new Response(body, { headers: {
|
|
47
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
48
|
+
"Cache-Control": "public, max-age=3600, s-maxage=86400"
|
|
49
|
+
} });
|
|
50
|
+
} catch {}
|
|
51
|
+
return new Response(`# ${title}\n\n${description}\n`, { headers: {
|
|
52
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
53
|
+
"Cache-Control": "public, max-age=3600, s-maxage=86400"
|
|
54
|
+
} });
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { GET, prerender };
|