Skip to content

Commit

Permalink
fix: starlight page id for legacy collections
Browse files Browse the repository at this point in the history
  • Loading branch information
HiDeoo committed Nov 26, 2024
1 parent 4d119e6 commit 8aa6621
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/starlight/utils/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface Route extends LocaleData {
entryMeta: LocaleData;
/** The slug, a.k.a. permalink, for this page. */
slug: string;
/** The unique ID for this page. */
/** The slug or unique ID if using the `legacy.collections` flag. */
id: string;
/** True if this page is untranslated in the current language and using fallback content from the default locale. */
isFallback?: true;
Expand Down
8 changes: 4 additions & 4 deletions packages/starlight/utils/starlight-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export type StarlightPageProps = Prettify<
*/
type StarlightPageDocsEntry = Omit<StarlightDocsEntry, 'id' | 'render'> & {
/**
* The unique ID for this Starlight page which cannot be inferred from codegen like content
* collection entries.
* The unique ID if using the `legacy.collections` for this Starlight page which cannot be
* inferred from codegen like content collection entries or the slug.
*/
id: string;
};
Expand All @@ -114,14 +114,14 @@ export async function generateStarlightPageRouteData({
const { isFallback, frontmatter, ...routeProps } = props;
const slug = urlToSlug(url);
const pageFrontmatter = await getStarlightPageFrontmatter(frontmatter);
const id = slug;
const id = project.legacyCollections ? `${stripLeadingAndTrailingSlashes(slug)}.md` : slug;
const localeData = slugToLocaleData(slug);
const sidebar = props.sidebar
? getSidebarFromConfig(validateSidebarProp(props.sidebar), url.pathname, localeData.locale)
: getSidebar(url.pathname, localeData.locale);
const headings = props.headings ?? [];
const pageDocsEntry: StarlightPageDocsEntry = {
id: slug,
id,
slug,
body: '',
collection: 'docs',
Expand Down

0 comments on commit 8aa6621

Please sign in to comment.