@conloca/content-api 0.2.2 → 0.2.3
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/.build-inputs.json +71 -0
- package/dist/address-site.d.ts +6 -0
- package/dist/address-site.d.ts.map +1 -0
- package/dist/address-site.js +15 -0
- package/dist/address-site.js.map +1 -0
- package/dist/asset-metadata-store.d.ts.map +1 -1
- package/dist/asset-operations.d.ts +15 -0
- package/dist/asset-operations.d.ts.map +1 -1
- package/dist/component-registry.d.ts +3 -0
- package/dist/component-registry.d.ts.map +1 -1
- package/dist/content-utils.d.ts +4 -1
- package/dist/content-utils.d.ts.map +1 -1
- package/dist/content-utils.js +14 -1
- package/dist/content-utils.js.map +1 -1
- package/dist/editor-host.d.ts +121 -0
- package/dist/editor-host.d.ts.map +1 -0
- package/dist/editor-host.js +212 -0
- package/dist/editor-host.js.map +1 -0
- package/dist/filesystem-content-api.d.ts +15 -0
- package/dist/filesystem-content-api.d.ts.map +1 -1
- package/dist/filesystem-content-api.js +3 -2
- package/dist/filesystem-content-api.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +3 -1
- package/dist/site.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -3
- package/src/address-site.ts +19 -0
- package/src/content-utils.ts +18 -2
- package/src/editor-host.ts +268 -0
- package/src/filesystem-content-api.ts +3 -2
- package/src/index.ts +2 -0
- package/src/site.ts +3 -1
- package/src/types.ts +2 -0
package/src/content-utils.ts
CHANGED
|
@@ -193,12 +193,18 @@ export function getMetadataSize(meta: ContentMeta): number {
|
|
|
193
193
|
* - Must start with /
|
|
194
194
|
* - Cannot contain spaces (should be URL-encoded)
|
|
195
195
|
* - Cannot contain special characters that would break URLs
|
|
196
|
+
* - Cannot be under the reserved `/_conloca/` prefix
|
|
196
197
|
*/
|
|
197
198
|
export function isValidPathname(pathname: string): boolean {
|
|
198
199
|
if (!pathname?.startsWith('/')) return false;
|
|
199
200
|
if (pathname.includes(' ')) return false;
|
|
200
201
|
if (pathname.includes('?') || pathname.includes('#')) return false;
|
|
201
|
-
return
|
|
202
|
+
return !isReservedPathname(pathname);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** True for `/_conloca` and everything under it: the editor page a site build writes there owns those paths. */
|
|
206
|
+
export function isReservedPathname(pathname: string): boolean {
|
|
207
|
+
return pathname === '/_conloca' || pathname.startsWith('/_conloca/');
|
|
202
208
|
}
|
|
203
209
|
|
|
204
210
|
/**
|
|
@@ -241,7 +247,8 @@ export type PathnameValidationReason =
|
|
|
241
247
|
| 'non_ascii'
|
|
242
248
|
| 'traversal_segment'
|
|
243
249
|
| 'index_segment'
|
|
244
|
-
| 'disallowed_char'
|
|
250
|
+
| 'disallowed_char'
|
|
251
|
+
| 'reserved_prefix';
|
|
245
252
|
|
|
246
253
|
export interface PathnameValidationResult {
|
|
247
254
|
/** When valid: the normalized pathname. When invalid: the raw (trimmed) input. */
|
|
@@ -302,6 +309,15 @@ export function normalizeAndValidatePathname(input: string | undefined | null):
|
|
|
302
309
|
value = value.replace(/\/+/g, '/');
|
|
303
310
|
if (value !== '/' && value.endsWith('/')) value = value.slice(0, -1);
|
|
304
311
|
|
|
312
|
+
if (isReservedPathname(value)) {
|
|
313
|
+
return {
|
|
314
|
+
value,
|
|
315
|
+
valid: false,
|
|
316
|
+
reason: 'reserved_prefix',
|
|
317
|
+
message: 'Paths under `/_conloca/` are reserved for the editor page',
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
305
321
|
// Segment-level check: `.` and `..` are never valid path segments.
|
|
306
322
|
// Run before the generic disallowed-char check so the user gets the
|
|
307
323
|
// more specific "traversal" message.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { isRecord } from './component-vocabulary.js';
|
|
2
|
+
|
|
3
|
+
/** The wire protocol an editor page built by this release speaks; the editor UI path is /host/v<this>/. */
|
|
4
|
+
export const EDITOR_HOST_PROTOCOL = 1;
|
|
5
|
+
/** Protocols the current editor UI accepts. */
|
|
6
|
+
export const EDITOR_HOST_PROTOCOLS = { min: 1, max: 1 } as const;
|
|
7
|
+
export const DEFAULT_EDITOR_ENDPOINT = 'https://app.conloca.com';
|
|
8
|
+
/** Where the editor page is served, below the site's base. */
|
|
9
|
+
export const EDITOR_PAGE_PATH = '/_conloca/editor/';
|
|
10
|
+
/** The deployable-site id grammar (moved here from cloud-astro's site-id.ts; the census imports it too). */
|
|
11
|
+
export const SITE_ID_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
12
|
+
|
|
13
|
+
/** The parsed http(s) URL when its host is `app.` plus at least two non-empty labels, else null. */
|
|
14
|
+
function appUrl(url: string): URL | null {
|
|
15
|
+
let parsed: URL;
|
|
16
|
+
try {
|
|
17
|
+
parsed = new URL(url);
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null;
|
|
22
|
+
const labels = parsed.hostname.split('.');
|
|
23
|
+
return labels.length >= 3 && labels[0] === 'app' && labels.every((label) => label !== '') ? parsed : null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The editor UI origin for an endpoint, or null unless its host is `app.` plus at least two labels. */
|
|
27
|
+
export function editorUiOrigin(endpoint: string | undefined): string | null {
|
|
28
|
+
return appUrl(endpoint ?? DEFAULT_EDITOR_ENDPOINT)?.origin ?? null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The parent root for a URL on the editor UI origin (`app.conloca.com` → `conloca.com`), or null under the same rule. */
|
|
32
|
+
export function parentRoot(url: string): string | null {
|
|
33
|
+
return appUrl(url)?.hostname.slice('app.'.length) ?? null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Editor UI file per bare specifier the page's bundle keeps external, under `<origin>/host/v<protocol>/`. */
|
|
37
|
+
export const EDITOR_UI_MODULE_FILES = {
|
|
38
|
+
react: 'react.js',
|
|
39
|
+
'react-dom': 'react-dom.js',
|
|
40
|
+
'react-dom/client': 'react-dom-client.js',
|
|
41
|
+
'react/jsx-runtime': 'jsx-runtime.js',
|
|
42
|
+
'react/jsx-dev-runtime': 'jsx-dev-runtime.js',
|
|
43
|
+
'@puckeditor/core': 'puck.js',
|
|
44
|
+
} as const;
|
|
45
|
+
|
|
46
|
+
export type EditorHostStatus =
|
|
47
|
+
| 'ready'
|
|
48
|
+
| 'no-address'
|
|
49
|
+
| 'blocked-address'
|
|
50
|
+
| 'unreachable'
|
|
51
|
+
| 'protected'
|
|
52
|
+
| 'not-found'
|
|
53
|
+
| 'invalid'
|
|
54
|
+
| 'wrong-repo'
|
|
55
|
+
| 'wrong-site'
|
|
56
|
+
| 'unsupported-protocol'
|
|
57
|
+
| 'frame-blocked';
|
|
58
|
+
|
|
59
|
+
export type EditorFrameFailure = 'handshake-timeout' | 'origin-rejected' | 'unsupported-protocol' | 'site-load-failed';
|
|
60
|
+
|
|
61
|
+
/** The page's inline JSON block, `<script type="application/json" id="conloca-editor-host">`. URLs are base-absolute. */
|
|
62
|
+
export interface EditorHostPageData {
|
|
63
|
+
protocol: number;
|
|
64
|
+
repo: string | null;
|
|
65
|
+
siteId: string;
|
|
66
|
+
site: string;
|
|
67
|
+
css: string[];
|
|
68
|
+
editorCss: string | null;
|
|
69
|
+
sandboxFrame: string;
|
|
70
|
+
info: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** conloca.json: public facts about one deploy of the editor page. Grants nothing. */
|
|
74
|
+
export interface EditorPageInfo {
|
|
75
|
+
protocol: number;
|
|
76
|
+
repo: string | null;
|
|
77
|
+
siteId: string;
|
|
78
|
+
commit: string | null;
|
|
79
|
+
branch: string | null;
|
|
80
|
+
builtWith: string;
|
|
81
|
+
/** `path` is relative to the editor folder. */
|
|
82
|
+
componentManifest: { path: string; sha256: string } | null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const EDITOR_PAGE_INFO_FORMATS = {
|
|
86
|
+
commit: /^[0-9a-f]{40}$/,
|
|
87
|
+
builtWith: /^@conloca\/cloud-astro@\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/,
|
|
88
|
+
repo: /^[A-Za-z0-9-]{1,39}\/[A-Za-z0-9._-]{1,100}$/,
|
|
89
|
+
siteId: SITE_ID_RE,
|
|
90
|
+
sha256: /^[0-9a-f]{64}$/,
|
|
91
|
+
manifestPath: /^component-manifest\.[0-9a-f]{16}\.json$/,
|
|
92
|
+
} as const;
|
|
93
|
+
|
|
94
|
+
/** Where the host serves a build of every other branch, recorded by the production build. */
|
|
95
|
+
export type BranchDeploys = { host: 'cloudflare-pages'; project: string };
|
|
96
|
+
|
|
97
|
+
// One DNS label: the Pages project names the first label of its `pages.dev` address.
|
|
98
|
+
const PAGES_PROJECT_RE = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
99
|
+
|
|
100
|
+
/** A parsed conloca.json object, whether or not it passed `isEditorPageInfo`, as the optional-field readers take it. */
|
|
101
|
+
export type ConlocaJson = EditorPageInfo | { branchDeploys?: unknown; contentPaths?: unknown };
|
|
102
|
+
|
|
103
|
+
/** conloca.json `branchDeploys`; `undefined` when absent or malformed, so a bad optional field never makes the page invalid. */
|
|
104
|
+
export function branchDeploysOf(info: ConlocaJson): BranchDeploys | undefined {
|
|
105
|
+
const value: unknown = Reflect.get(info, 'branchDeploys');
|
|
106
|
+
if (!isRecord(value) || value.host !== 'cloudflare-pages') return undefined;
|
|
107
|
+
const { project } = value;
|
|
108
|
+
return typeof project === 'string' && PAGES_PROJECT_RE.test(project)
|
|
109
|
+
? { host: 'cloudflare-pages', project }
|
|
110
|
+
: undefined;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const CONTENT_PATHS_MAX = 16;
|
|
114
|
+
|
|
115
|
+
/** '' (the repository root) or a relative path of plain segments, at most 255 characters. */
|
|
116
|
+
function isContentPath(path: unknown): path is string {
|
|
117
|
+
if (path === '') return true;
|
|
118
|
+
if (typeof path !== 'string' || path.length > 255 || path.includes('\\')) return false;
|
|
119
|
+
return path.split('/').every((segment) => segment !== '' && segment !== '.' && segment !== '..');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* conloca.json `contentPaths`: repository paths the site's content lives under, duplicates removed;
|
|
124
|
+
* `undefined` when absent or malformed, so a bad optional field never makes the page invalid.
|
|
125
|
+
*/
|
|
126
|
+
export function contentPathsOf(info: ConlocaJson): string[] | undefined {
|
|
127
|
+
const value: unknown = Reflect.get(info, 'contentPaths');
|
|
128
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > CONTENT_PATHS_MAX) return undefined;
|
|
129
|
+
if (!value.every(isContentPath)) return undefined;
|
|
130
|
+
return [...new Set<string>(value)];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// `~^:?*[\`, `..`, `@{` and `//` anywhere (`git check-ref-format`); space and control characters are checked apart.
|
|
134
|
+
const BRANCH_FORBIDDEN_RE = /[~^:?*[\\]|\.\.|@\{|\/\//;
|
|
135
|
+
|
|
136
|
+
/** Git's ref-name rules for one branch name, at most 255 characters. */
|
|
137
|
+
export function isValidBranchName(name: string): boolean {
|
|
138
|
+
if (name === '' || name.length > 255 || name === '@' || BRANCH_FORBIDDEN_RE.test(name)) return false;
|
|
139
|
+
for (let index = 0; index < name.length; index++) {
|
|
140
|
+
const code = name.charCodeAt(index);
|
|
141
|
+
if (code <= 0x20 || code === 0x7f) return false;
|
|
142
|
+
}
|
|
143
|
+
if (name.startsWith('-') || name.startsWith('/') || name.endsWith('/') || name.endsWith('.')) return false;
|
|
144
|
+
return name.split('/').every((segment) => !segment.startsWith('.') && !segment.endsWith('.lock'));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Shape and field formats of a parsed conloca.json; null allowed where the type allows it. */
|
|
148
|
+
export function isEditorPageInfo(value: unknown): value is EditorPageInfo {
|
|
149
|
+
if (!isRecord(value)) return false;
|
|
150
|
+
const { protocol, repo, siteId, commit, branch, builtWith, componentManifest } = value;
|
|
151
|
+
const formats = EDITOR_PAGE_INFO_FORMATS;
|
|
152
|
+
return (
|
|
153
|
+
typeof protocol === 'number' &&
|
|
154
|
+
Number.isSafeInteger(protocol) &&
|
|
155
|
+
(repo === null || (typeof repo === 'string' && formats.repo.test(repo))) &&
|
|
156
|
+
typeof siteId === 'string' &&
|
|
157
|
+
formats.siteId.test(siteId) &&
|
|
158
|
+
(commit === null || (typeof commit === 'string' && formats.commit.test(commit))) &&
|
|
159
|
+
(branch === null || (typeof branch === 'string' && isValidBranchName(branch))) &&
|
|
160
|
+
typeof builtWith === 'string' &&
|
|
161
|
+
formats.builtWith.test(builtWith) &&
|
|
162
|
+
(componentManifest === null ||
|
|
163
|
+
(isRecord(componentManifest) &&
|
|
164
|
+
typeof componentManifest.path === 'string' &&
|
|
165
|
+
formats.manifestPath.test(componentManifest.path) &&
|
|
166
|
+
typeof componentManifest.sha256 === 'string' &&
|
|
167
|
+
formats.sha256.test(componentManifest.sha256)))
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** True when `location` is an absolute URL on vercel.com or a subdomain (Vercel's sign-in redirect). */
|
|
172
|
+
export function isVercelSignIn(location: string | null): boolean {
|
|
173
|
+
if (location === null) return false;
|
|
174
|
+
let host: string;
|
|
175
|
+
try {
|
|
176
|
+
host = new URL(location).hostname;
|
|
177
|
+
} catch {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
return host === 'vercel.com' || host.endsWith('.vercel.com');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Any Vercel signal on an answer: an `x-vercel-*` header or a sign-in redirect. Feeds the classifier's `vercel`. */
|
|
184
|
+
export function isFromVercel(headers: Headers): boolean {
|
|
185
|
+
for (const [name] of headers) if (name.startsWith('x-vercel-')) return true;
|
|
186
|
+
return isVercelSignIn(headers.get('location'));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** What one conloca.json answer means; `info` is the parsed file once it passed the format checks. */
|
|
190
|
+
export interface EditorHostVerdict {
|
|
191
|
+
status: EditorHostStatus;
|
|
192
|
+
reason?: 'repo-missing';
|
|
193
|
+
info?: EditorPageInfo;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* One conloca.json answer → status; body is null when not read (non-200 or over the cap).
|
|
198
|
+
* `vercel` (any Vercel signal) only picks the caller's message: an ordinary redirect on Vercel stays `invalid`.
|
|
199
|
+
*/
|
|
200
|
+
export function classifyEditorHostResponse(
|
|
201
|
+
response: {
|
|
202
|
+
status: number;
|
|
203
|
+
contentType: string | null;
|
|
204
|
+
location: string | null;
|
|
205
|
+
vercel: boolean;
|
|
206
|
+
body: string | null;
|
|
207
|
+
},
|
|
208
|
+
expected: { repoUri: string; siteId: string; protocols: { min: number; max: number } },
|
|
209
|
+
): EditorHostVerdict {
|
|
210
|
+
const { status, contentType, body } = response;
|
|
211
|
+
if (status >= 500 || status === 429) return { status: 'unreachable' };
|
|
212
|
+
if (status === 401 || status === 403) return { status: 'protected' };
|
|
213
|
+
if (status === 404) return { status: 'not-found' };
|
|
214
|
+
if (status >= 300 && status < 400) return { status: isVercelSignIn(response.location) ? 'protected' : 'invalid' };
|
|
215
|
+
if (status !== 200) return { status: 'invalid' };
|
|
216
|
+
// A host serving its HTML fallback for unknown paths.
|
|
217
|
+
if (contentType?.split(';')[0]?.trim().toLowerCase() === 'text/html') return { status: 'not-found' };
|
|
218
|
+
if (body === null) return { status: 'invalid' };
|
|
219
|
+
if (body.trimStart().startsWith('<')) return { status: 'not-found' };
|
|
220
|
+
let parsed: unknown;
|
|
221
|
+
try {
|
|
222
|
+
parsed = JSON.parse(body);
|
|
223
|
+
} catch {
|
|
224
|
+
return { status: 'invalid' };
|
|
225
|
+
}
|
|
226
|
+
if (!isEditorPageInfo(parsed)) return { status: 'invalid' };
|
|
227
|
+
const info = parsed;
|
|
228
|
+
if (info.protocol < expected.protocols.min || info.protocol > expected.protocols.max) {
|
|
229
|
+
return { status: 'unsupported-protocol', info };
|
|
230
|
+
}
|
|
231
|
+
if (info.repo === null) return { status: 'wrong-repo', reason: 'repo-missing', info };
|
|
232
|
+
if (info.repo.toLowerCase() !== expected.repoUri.toLowerCase()) return { status: 'wrong-repo', info };
|
|
233
|
+
if (info.siteId !== expected.siteId) return { status: 'wrong-site', info };
|
|
234
|
+
return { status: 'ready', info };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** A CSP source expression compared as a token: case-insensitive, without a trailing `/`. */
|
|
238
|
+
function sourceToken(source: string): string {
|
|
239
|
+
return source.toLowerCase().replace(/\/$/, '');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Frame headers of the page → whether a workspace parent may frame it. `allowedAncestors` are the source expressions
|
|
244
|
+
* that admit the workspace; `*` and `https:` always do. A `frame-ancestors` directive overrides X-Frame-Options.
|
|
245
|
+
* shortcut: sources match as exact tokens, so a broader host wildcard (`https://*.com`) reads as blocked; parse
|
|
246
|
+
* host patterns if a real site needs one.
|
|
247
|
+
*/
|
|
248
|
+
export function classifyFrameHeaders(
|
|
249
|
+
headers: { xFrameOptions: string | null; csp: string | null },
|
|
250
|
+
allowedAncestors: readonly string[],
|
|
251
|
+
): 'ok' | 'frame-blocked' {
|
|
252
|
+
const admitting = new Set(['*', 'https:', ...allowedAncestors.map(sourceToken)]);
|
|
253
|
+
// A combined header joins policies with commas; every policy is enforced on its own, by its first frame-ancestors.
|
|
254
|
+
const ancestorLists = (headers.csp ?? '').split(',').flatMap((policy) => {
|
|
255
|
+
const directive = policy
|
|
256
|
+
.split(';')
|
|
257
|
+
.map((part) => part.trim().split(/\s+/))
|
|
258
|
+
.find(([name]) => name?.toLowerCase() === 'frame-ancestors');
|
|
259
|
+
return directive ? [directive.slice(1)] : [];
|
|
260
|
+
});
|
|
261
|
+
if (ancestorLists.length > 0) {
|
|
262
|
+
return ancestorLists.every((sources) => sources.some((source) => admitting.has(sourceToken(source))))
|
|
263
|
+
? 'ok'
|
|
264
|
+
: 'frame-blocked';
|
|
265
|
+
}
|
|
266
|
+
const xfo = new Set((headers.xFrameOptions ?? '').split(',').map((value) => value.trim().toLowerCase()));
|
|
267
|
+
return xfo.has('deny') || xfo.has('sameorigin') ? 'frame-blocked' : 'ok';
|
|
268
|
+
}
|
|
@@ -431,8 +431,8 @@ export class FileSystemContentAPI implements ContentAPI {
|
|
|
431
431
|
// site's locales array) both have slots for every option-declared
|
|
432
432
|
// locale. Without this, the parser would correctly identify a file's
|
|
433
433
|
// locale but `addContent` would crash on a missing index bucket.
|
|
434
|
-
// We preserve the resolved site's existing `mdxPages
|
|
435
|
-
// through the rewrite so the locale-override doesn't clobber the
|
|
434
|
+
// We preserve the resolved site's existing `mdxPages`, `domains` and
|
|
435
|
+
// `base` through the rewrite so the locale-override doesn't clobber the
|
|
436
436
|
// per-site content config.
|
|
437
437
|
if (options.availableLocales && options.availableLocales.length > 0) {
|
|
438
438
|
const optionDefaultLocale = options.defaultLocale ?? options.availableLocales[0];
|
|
@@ -445,6 +445,7 @@ export class FileSystemContentAPI implements ContentAPI {
|
|
|
445
445
|
locales: options.availableLocales,
|
|
446
446
|
defaultLocale: optionDefaultLocale,
|
|
447
447
|
...(existingSite?.domains && { domains: existingSite.domains }),
|
|
448
|
+
...(existingSite?.base && { base: existingSite.base }),
|
|
448
449
|
...(existingSite?.mdxPages && { mdxPages: existingSite.mdxPages }),
|
|
449
450
|
},
|
|
450
451
|
},
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* For Node.js-specific APIs (filesystem, in-memory, middleware, etc.), import from '@conloca/content-api/node'
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
// The address site and its base path, shared by every host that reads a sites.json.
|
|
9
|
+
export { addressSiteName, isValidSiteBase } from './address-site.js';
|
|
8
10
|
// Upload ceiling + image allowlist. Pure data, no node deps — the source of
|
|
9
11
|
// truth other asset backends read through this entry.
|
|
10
12
|
// DEFAULT_ACCEPTED_FORMATS deliberately stays off the barrel — it is just the map's keys.
|
package/src/site.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContentAPI } from './content-api.interface.js';
|
|
2
|
-
import { localesOf } from './content-utils.js';
|
|
2
|
+
import { isReservedPathname, localesOf } from './content-utils.js';
|
|
3
3
|
import type { SiteIndex } from './site-index.js';
|
|
4
4
|
import type { ContentManifest, CreatePageInput, CreateResult, MoveResult, SiteFilters } from './types.js';
|
|
5
5
|
|
|
@@ -134,6 +134,8 @@ export class Site {
|
|
|
134
134
|
|
|
135
135
|
// Validate pathname is available (not taken or in redirects)
|
|
136
136
|
isPathnameAvailable(pathname: string, locale: string, excludeId?: string): boolean {
|
|
137
|
+
if (isReservedPathname(pathname)) return false;
|
|
138
|
+
|
|
137
139
|
// Check if pathname is already taken
|
|
138
140
|
const existing = this.getByPathname(pathname, locale);
|
|
139
141
|
if (existing && existing.id !== excludeId) {
|
package/src/types.ts
CHANGED
|
@@ -384,6 +384,8 @@ export interface SitesConfig {
|
|
|
384
384
|
domains?: {
|
|
385
385
|
[locale: string]: string;
|
|
386
386
|
};
|
|
387
|
+
/** Path the site is served under, as Astro's `base`: starts and ends with `/`; default `/`. */
|
|
388
|
+
base?: string;
|
|
387
389
|
/**
|
|
388
390
|
* Optional filesystem path for this site's mdx-type pages.
|
|
389
391
|
* When set, .mdx files under this path are surfaced in the CMS
|