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