Skip to content

Commit fab9c9d

Browse files
committed
fix slug -> id
1 parent b53471e commit fab9c9d

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/components/list/Directory.astro

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function compareOrder(a: Route, b: Route): boolean {
5050
return a.entry.data.sidebar.order > b.entry.data.sidebar.order;
5151
}
5252
53-
let { slug } = Astro.props;
53+
let { slug } = Astro.locals.starlightRoute;
5454
const {
5555
filterOutByTitle = [],
5656
filterOutByFileName = [],
@@ -154,9 +154,9 @@ if (!sortAlphabetically) {
154154
return (
155155
<CustomLinkCard
156156
title={item.entry.data.title}
157-
href={`/${item.slug}/`}
157+
href={`/${item.id}/`}
158158
description={item.entry.data.description}
159-
footer={callback instanceof Function && callback(item.slug)}
159+
footer={callback instanceof Function && callback(item.id)}
160160
/>
161161
);
162162
})
@@ -167,9 +167,9 @@ if (!sortAlphabetically) {
167167
<CustomLinkCard
168168
class="fallback-badge"
169169
title={item.entry.data.title}
170-
href={`/${item.slug}/`}
170+
href={`/${item.id}/`}
171171
description={item.entry.data.description}
172-
footer={callback instanceof Function && callback(item.slug)}
172+
footer={callback instanceof Function && callback(item.id)}
173173
/>
174174
))
175175
}

src/pages/[...llm_slug].ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ export function groupDocsByPrefix(
1919
prefixes.forEach((prefix) => {
2020
grouped.set(
2121
prefix,
22-
docs.filter((doc) => doc.slug.startsWith(prefix))
22+
docs.filter((doc) => doc.id.startsWith(prefix))
2323
);
2424
});
2525
// sort each group by slug
2626
for (const [prefix, items] of grouped) {
27-
items.sort((a, b) => a.slug.localeCompare(b.slug));
27+
items.sort((a, b) => a.id.localeCompare(b.id));
2828
}
2929

3030
return grouped;
@@ -38,7 +38,7 @@ export const GET: APIRoute = async ({ params, request }) => {
3838
const { llm_slug } = params;
3939
const slug = llm_slug?.replace(/\/llms\.txt$/, '');
4040
const docs = await getCollection('docs');
41-
const doc = docs.find((doc) => doc.slug === slug);
41+
const doc = docs.find((doc) => doc.id === slug);
4242
if (!doc) {
4343
return new Response('Not Found', { status: 404 });
4444
}
@@ -54,7 +54,7 @@ export async function getStaticPaths() {
5454
const docs = await getCollection('docs');
5555
const docsBySection = groupDocsByPrefix(llmsTxtSections, docs);
5656
const paths = Array.from(docsBySection.values())
57-
.map((docs) => docs.map((doc) => doc.slug))
57+
.map((docs) => docs.map((doc) => doc.id))
5858
.flat()
5959
.map((slug) => ({ params: { llm_slug: toLlmsTxtPath(slug) } }));
6060

src/pages/feed.xml.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function GET(context: APIContext) {
3434
title: post.data.title,
3535
pubDate: post.id.startsWith('blog') ? post.data.date : getTimestamp(post.id),
3636
description: post.id.startsWith('blog') ? post.data.excerpt : post.data.description,
37-
link: `/${post.slug}/`,
37+
link: `/${post.id}/`,
3838
})),
3939
});
4040
}

src/pages/llms.toc.txt.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function groupDocsByPrefix(docs: Awaited<ReturnType<typeof getCollection<'docs'>
1111
prefixes.forEach((prefix) => {
1212
grouped.set(
1313
prefix,
14-
docs.filter((doc) => doc.slug.startsWith(prefix))
14+
docs.filter((doc) => doc.id.startsWith(prefix))
1515
);
1616
});
1717

@@ -42,9 +42,9 @@ export const GET: APIRoute = async ({ params, request }) => {
4242
if (items.length > 0) {
4343
content += `\n## ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
4444
items.forEach((doc) => {
45-
const level = getHeaderLevel(doc.slug);
45+
const level = getHeaderLevel(doc.id);
4646
const indent = ' '.repeat(level - 2);
47-
content += `${indent}- [${doc.data.title}](https://tauri.app/${doc.slug}/)\n`;
47+
content += `${indent}- [${doc.data.title}](https://tauri.app/${doc.id}/)\n`;
4848
});
4949
}
5050
}

src/pages/llms.txt.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export const GET: APIRoute = async ({ params, request }) => {
1818
if (items.length > 0) {
1919
content += `\n${n++}. ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
2020
items.forEach((doc) => {
21-
const level = getHeaderLevel(doc.slug);
21+
const level = getHeaderLevel(doc.id);
2222
const indent = ' '.repeat(level - 2);
23-
content += `${indent}- [${doc.data.title}](#${doc.slug})\n`;
23+
content += `${indent}- [${doc.data.title}](#${doc.id})\n`;
2424
});
2525
}
2626
}

src/pages/pages.xml.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function GET(context: APIContext) {
3434
items: posts.map((post) => ({
3535
pubDate: getTimestamp(post.id),
3636
...post.data,
37-
link: `/${post.slug}/`,
37+
link: `/${post.id}/`,
3838
})),
3939
});
4040
}

0 commit comments

Comments
 (0)