Skip to content

Commit fa5413f

Browse files
committed
Fix compatibility with Starlight v0.32.0
1 parent 5ad74e0 commit fa5413f

File tree

11 files changed

+404
-19
lines changed

11 files changed

+404
-19
lines changed

apps/docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"astro": "astro"
1111
},
1212
"dependencies": {
13-
"@astrojs/starlight": "catalog:",
13+
"@astrojs/starlight": "^0.32.1",
1414
"@fontsource-variable/space-grotesk": "^5.1.1",
1515
"@fontsource/space-mono": "^5.1.2",
1616
"@iconify-json/lucide": "^1.2.22",
17-
"astro": "catalog:",
17+
"astro": "^5.3.0",
1818
"sharp": "^0.33.5",
1919
"starlight-ion-theme": "workspace:",
2020
"starlight-package-managers": "^0.9.0",

apps/docs/src/content/docs/changelog.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
title: "Changelog"
33
---
44

5+
## v2.2.0 (Feb. 22, 2025)
6+
7+
Fixed compatibility issues with Starlight v0.32.0.
8+
9+
### Breaking Changes
10+
11+
- Ion now requires Starlight v0.32.0 or higher.
12+
513
## v2.1.2 (Jan. 25, 2025)
614

715
### Bug Fixes

packages/starlight-ion-theme/components/Head.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { createHead } from 'starlight-ion-theme/utils/head.js';
88
import { localizedUrl } from 'starlight-ion-theme/utils/localizedUrl.js';
99
import type { Props } from '@astrojs/starlight/props';
1010
11-
const { entry, lang, siteTitle } = Astro.props;
11+
const { entry, lang, siteTitle } = Astro.locals.starlightRoute;
1212
const { data } = entry;
1313
1414
const canonical = Astro.site ? new URL(Astro.url.pathname, Astro.site) : undefined;

packages/starlight-ion-theme/components/Hero.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Props } from '@astrojs/starlight/props';
55
66
import { PAGE_TITLE_ID } from 'starlight-ion-theme/constants';
77
8-
const { data } = Astro.props.entry;
8+
const { data } = Astro.locals.starlightRoute.entry;
99
const { title = data.title, tagline, image, actions = [] } = data.hero || {};
1010
1111
const imageAttrs = {

packages/starlight-ion-theme/components/PageTitle.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { PAGE_TITLE_ID } from 'starlight-ion-theme/constants';
44
import type { Props } from '@astrojs/starlight/props';
55
import { icons } from 'ion:globals';
66
7-
const { entry } = Astro.props;
7+
const { entry } = Astro.locals.starlightRoute;
88
---
99

1010
<h1 id={PAGE_TITLE_ID}>

packages/starlight-ion-theme/components/Pagination.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Icon as AstroIcon } from 'astro-icon/components';
44
import type { Props } from '@astrojs/starlight/props';
55
import { footer } from 'ion:globals';
66
7-
const { dir, labels, pagination } = Astro.props;
7+
const { dir, pagination } = Astro.locals.starlightRoute;
88
const { prev, next } = pagination;
99
const isRtl = dir === 'rtl';
1010

packages/starlight-ion-theme/components/Sidebar.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Props } from '@astrojs/starlight/props';
44
import MobileMenuFooter from 'virtual:starlight/components/MobileMenuFooter';
55
import SidebarSublist from 'starlight-ion-theme/components/SidebarSublist.astro';
66
7-
const { sidebar } = Astro.props;
7+
const { sidebar } = Astro.locals.starlightRoute;
88
---
99

1010
<SidebarSublist sublist={sidebar as any} nestedCount={0} />

packages/starlight-ion-theme/components/SidebarSublist.astro

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@ interface Props {
1111
}
1212
1313
const { sublist, nested, nestedCount } = Astro.props;
14+
15+
// export interface StarlightRouteData extends Route {
16+
// /** Title of the site. */
17+
// siteTitle: string;
18+
// /** URL or path used as the link when clicking on the site title. */
19+
// siteTitleHref: string;
20+
// /** Array of Markdown headings extracted from the current page. */
21+
// headings: MarkdownHeading[];
22+
// /** Site navigation sidebar entries for this page. */
23+
// sidebar: SidebarEntry[];
24+
// /** Whether or not the sidebar should be displayed on this page. */
25+
// hasSidebar: boolean;
26+
// /** Links to the previous and next page in the sidebar if enabled. */
27+
// pagination: PaginationLinks;
28+
// /** Table of contents for this page if enabled. */
29+
// toc: { minHeadingLevel: number; maxHeadingLevel: number; items: TocItem[] } | undefined;
30+
// /** JS Date object representing when this page was last updated if enabled. */
31+
// lastUpdated: Date | undefined;
32+
// /** URL object for the address where this page can be edited if enabled. */
33+
// editUrl: URL | undefined;
34+
// /** An Astro component to render the current page’s content if this route is a Markdown page. */
35+
// Content?: RenderResult['Content'];
36+
// }
1437
---
1538

1639
<ul class:list={{ 'top-level': !nested }}>

packages/starlight-ion-theme/components/SiteTitle.astro

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
import { logos } from 'virtual:starlight/user-images';
33
import config from 'virtual:starlight/user-config';
44
import type { Props } from '@astrojs/starlight/props';
5-
import { formatPath } from 'starlight-ion-theme/utils/format-path.js';
65
7-
const { siteTitle } = Astro.props;
8-
9-
const href = formatPath(Astro.props.locale || '/');
6+
const { siteTitle, siteTitleHref } = Astro.locals.starlightRoute;
107
---
118

12-
<a href={href} class="site-title sl-flex">
9+
<a href={siteTitleHref} class="site-title sl-flex">
1310
{
1411
config.logo && logos.dark && (
1512
<>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* This namespace is reserved for Starlight (only used for i18n at the moment).
3+
* It can be extended by plugins using module augmentation and interface merging.
4+
* For an example, see: https://starlight.astro.build/reference/plugins/#injecttranslations
5+
*/
6+
declare namespace StarlightApp {
7+
interface I18n {}
8+
}
9+
10+
/**
11+
* Extending Astro’s `App.Locals` interface registers types for the middleware added by Starlight.
12+
*/
13+
declare namespace App {
14+
interface Locals {
15+
/**
16+
* Starlight’s localization API, powered by i18next.
17+
*
18+
* @see https://starlight.astro.build/guides/i18n/#using-ui-translations
19+
*
20+
* @example
21+
* // Render a UI string for the current locale.
22+
* <p>{Astro.locals.t('404.text')}</p>
23+
*/
24+
t: import('./utils/createTranslationSystem').I18nT;
25+
26+
/**
27+
* Starlight’s data for the current route.
28+
*
29+
* @see https://starlight.astro.build/guides/route-data/
30+
*
31+
* @throws Will throw an error if accessed on non-Starlight routes.
32+
*
33+
* @example
34+
* // Render the title for the current page
35+
* <h1>{Astro.locals.starlightRoute.entry.data.title}</h1>
36+
*
37+
* @example
38+
* // Check if the current page should render the sidebar
39+
* const { hasSidebar } = Astro.locals.starlightRoute;
40+
*/
41+
starlightRoute: import('@astrojs/starlight/utils/routing/types').StarlightRouteData;
42+
}
43+
}

0 commit comments

Comments
 (0)