debug: log getPageBySlug resolution path (temp)
This commit is contained in:
@@ -254,12 +254,15 @@ export async function getPageBySlug(
|
|||||||
return fetch(u.toString());
|
return fetch(u.toString());
|
||||||
};
|
};
|
||||||
let res = await trySlug(slug);
|
let res = await trySlug(slug);
|
||||||
|
console.log(`[getPageBySlug] slug="${slug}" first=${res.status}`);
|
||||||
if (res.status === 404 && !slug.startsWith("/")) {
|
if (res.status === 404 && !slug.startsWith("/")) {
|
||||||
res = await trySlug("/" + slug);
|
res = await trySlug("/" + slug);
|
||||||
|
console.log(`[getPageBySlug] slug="${slug}" leading-slash=${res.status}`);
|
||||||
}
|
}
|
||||||
if (res.status === 404) {
|
if (res.status === 404) {
|
||||||
const items = await getPages();
|
const items = await getPages();
|
||||||
const norm = normalizePageSlug(slug);
|
const norm = normalizePageSlug(slug);
|
||||||
|
console.log(`[getPageBySlug] fallback items=${items.length} norm="${norm}"`);
|
||||||
const match = items.find(
|
const match = items.find(
|
||||||
(p) =>
|
(p) =>
|
||||||
normalizePageSlug(p.slug) === norm ||
|
normalizePageSlug(p.slug) === norm ||
|
||||||
@@ -267,8 +270,10 @@ export async function getPageBySlug(
|
|||||||
p._slug === slug ||
|
p._slug === slug ||
|
||||||
p.slug === slug,
|
p.slug === slug,
|
||||||
);
|
);
|
||||||
|
console.log(`[getPageBySlug] match=${match?._slug ?? 'NONE'}`);
|
||||||
if (match?._slug) {
|
if (match?._slug) {
|
||||||
res = await trySlug(match._slug);
|
res = await trySlug(match._slug);
|
||||||
|
console.log(`[getPageBySlug] match fetch=${res.status}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res.status === 404) return null;
|
if (res.status === 404) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user