Skip to content

Commit 62232d1

Browse files
authored
fix(site): serve skill reference files at /skills/<slug>/references/<path> (#223)
1 parent e206ccd commit 62232d1

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/pages/skills/[slug]/references/[...path].ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@ function getContentType(path: string): string {
1111

1212
export async function getStaticPaths() {
1313
const entries = await getSkillFileEntries();
14-
return entries.map((e) => ({
15-
params: { slug: e.name, path: e.path },
16-
props: { content: e.content, filePath: e.path },
17-
}));
14+
// This route already lives under `references/`, so the catch-all `[...path]`
15+
// must be the path *relative to* `references/`. Passing the full `references/<...>`
16+
// path doubles the segment, emitting `/skills/<slug>/references/references/<...>`
17+
// and 404ing the documented `/skills/<slug>/references/<...>` URL.
18+
const prefix = 'references/';
19+
return entries
20+
.filter((e) => e.path.startsWith(prefix))
21+
.map((e) => ({
22+
params: { slug: e.name, path: e.path.slice(prefix.length) },
23+
props: { content: e.content, filePath: e.path },
24+
}));
1825
}
1926

2027
export const GET: APIRoute = ({ props }) => {

0 commit comments

Comments
 (0)