Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/humble-friends-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@astrojs/starlight': minor
---

Updates internal `@astrojs/mdx`, `@astrojs/markdown-satteri`, and `satteri` dependencies.

⚠️ **BREAKING CHANGE:** The minimum supported version of Astro is now v7.2.5.

Please update Starlight and Astro together:

```sh
npx @astrojs/upgrade
```
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@astrojs/starlight": "workspace:*",
"@lunariajs/core": "^0.1.1",
"@types/culori": "^4.0.1",
"astro": "^7.1.6",
"astro": "^7.2.5",
"culori": "^4.0.2",
"sharp": "^0.35.3"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/starlight": "^0.41.11",
"astro": "^7.1.6",
"astro": "^7.2.5",
"sharp": "^0.35.3"
}
}
2 changes: 1 addition & 1 deletion examples/markdoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@astrojs/markdoc": "^2.0.6",
"@astrojs/starlight": "^0.41.11",
"@astrojs/starlight-markdoc": "^0.7.0",
"astro": "^7.1.6",
"astro": "^7.2.5",
"sharp": "^0.35.3"
}
}
2 changes: 1 addition & 1 deletion examples/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@astrojs/starlight": "^0.41.11",
"@astrojs/starlight-tailwind": "^5.0.0",
"@tailwindcss/vite": "^4.2.4",
"astro": "^7.1.6",
"astro": "^7.2.5",
"sharp": "^0.35.3",
"tailwindcss": "^4.2.4"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@changesets/cli": "^3.0.1",
"@eslint/js": "^10.0.1",
"@size-limit/file": "^12.1.0",
"astro": "^7.1.6",
"astro": "^7.2.5",
"eslint": "^10.3.0",
"eslint-config-prettier": "^10.1.8",
"globals": "^17.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/file-icons-generator/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Definitions } from '../starlight/src/user-components/rehype-file-tree';
import type { Definitions } from '../starlight/src/user-components/file-tree-processor';

export const seti = {
/** The GitHub repository containing the Seti UI theme using the `username/repo` format. */
Expand Down
4 changes: 2 additions & 2 deletions packages/file-icons-generator/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { spawn } from 'node:child_process';
import fs from 'node:fs/promises';
import path from 'node:path';
import { starlight } from '../config.ts';
import type { Definitions } from '../../starlight/src/user-components/rehype-file-tree.ts';
import type { Definitions } from '../../starlight/src/user-components/file-tree-processor.ts';

const copyrightNotice = `/**
* Based on https://github.com/elviswolcott/seti-icons which
Expand Down Expand Up @@ -42,7 +42,7 @@ export async function writeDefinitionsAndSVGs(
) {
const content = `${generatedFileHeader}

import type { Definitions } from './rehype-file-tree.ts';
import type { Definitions } from './file-tree-processor.ts';

${copyrightNotice}
export const definitions: Definitions = ${JSON.stringify(definitions)};
Expand Down
2 changes: 1 addition & 1 deletion packages/file-icons-generator/utils/font.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import opentype, { type Font, Glyph } from 'opentype.js';
import { seti, starlight } from '../config.ts';
import type { Definitions } from '../../starlight/src/user-components/rehype-file-tree.ts';
import type { Definitions } from '../../starlight/src/user-components/file-tree-processor.ts';
import { getFont, getSetiIconName } from './seti.ts';

// This matches the default precision used by the SVGO default preset.
Expand Down
2 changes: 1 addition & 1 deletion packages/file-icons-generator/utils/seti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { seti, starlight } from '../config.ts';
import type { Definitions } from '../../starlight/src/user-components/rehype-file-tree.ts';
import type { Definitions } from '../../starlight/src/user-components/file-tree-processor.ts';

// https://github.com/jesseweed/seti-ui/blob/master/styles/components/icons/mapping.less
// .icon-set(".bsl", "bsl", @red);
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/__e2e__/fixtures/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/starlight": "workspace:*",
"astro": "^7.1.6"
"astro": "^7.2.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/starlight": "workspace:*",
"astro": "^7.1.6"
"astro": "^7.2.5"
}
}
2 changes: 1 addition & 1 deletion packages/starlight/__e2e__/fixtures/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/starlight": "workspace:*",
"astro": "^7.1.6"
"astro": "^7.2.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/starlight": "workspace:*",
"astro": "^7.1.6"
"astro": "^7.2.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/starlight": "workspace:*",
"astro": "^7.1.6"
"astro": "^7.2.5"
}
}
2 changes: 1 addition & 1 deletion packages/starlight/__e2e__/fixtures/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"dependencies": {
"@astrojs/node": "^11.0.0",
"@astrojs/starlight": "workspace:*",
"astro": "^7.1.6"
"astro": "^7.2.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,10 @@ describeEachProcessor('code RTL support', (ctx, name) => {
expect(res.code).not.includes('dir="auto"');
});

test('handles `dir="ltr"` on raw `<pre>` HTML per processor', async () => {
test('does not apply `dir="ltr"` on raw `<pre>` HTML', async () => {
const res = await ctx().render('<pre><code>manual</code></pre>', { processor: plain });

// Since Astro's Sätteri implementation for Shiki returns raw nodes, it, by accident, applies
// `dir="ltr"` to raw `<pre>` blocks even if they're not coming from a plugin generating HAST.
if (name === 'satteri') {
expect(res.code).includes('<pre dir="ltr"><code>manual</code></pre>');
} else {
expect(res.code).includes('<pre><code>manual</code></pre>');
}
expect(res.code).includes('<pre><code>manual</code></pre>');
});

test('does not override an existing `dir` on inline code', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test, vi } from 'vitest';
import { processFileTree } from '../../src/user-components/rehype-file-tree';
import { processFileTree } from '../../src/user-components/file-tree-processor';
import { Icons, type StarlightIcon } from '../../src/components-internals/Icons';

describe('validation', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ describe('registerDirectivesRestoration', () => {
test('registers the mdast restoration plugin on a Sätteri processor', () => {
const processor = satteri();
registerDirectivesRestoration(processor, unifiedIntegration);
expect(processor.options.mdastPlugins.map((plugin) => plugin.name)).toContain(
'starlight-directives-restoration'
expect(processor.options.mdastPlugins).toContainEqual(
expect.objectContaining({ name: 'starlight-directives-restoration' })
);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from 'vitest';
import { processSteps } from '../../src/user-components/rehype-steps';
import { processSteps } from '../../src/user-components/steps-processor';

test('empty component throws an error', () => {
expect(() => processSteps('')).toThrowErrorMatchingInlineSnapshot(
Expand Down Expand Up @@ -63,7 +63,7 @@ test('component with multiple children throws an error', () => {
});

// This tests a workaround added for https://github.com/withastro/astro/issues/15627
// See rehype-steps.ts for more details.
// See steps-processor.ts for more details.
test('component with top-level script child is processed successfully', () => {
const { html } = processSteps(
'<script type="module" src="/test-script.js"></script><ol><li>List item</li></ol>'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { expect, test } from 'vitest';
import { fromHtml } from 'hast-util-from-html';
import { toHtml } from 'hast-util-to-html';
import { selectAll } from 'hast-util-select';
import { rehype } from 'rehype';
import { processPanels, TabItemTagname } from '../../src/user-components/rehype-tabs';

const processor = rehype().data('settings', { fragment: true });
import { htmlToHast } from 'satteri';
import { processPanels, TabItemTagname } from '../../src/user-components/tabs-processor';

const TabItem = ({ label, slot, icon }: { label: string; slot: string; icon?: string }) => {
const iconAttr = icon ? ` data-icon="${icon}"` : '';
return `<${TabItemTagname} data-label="${label}"${iconAttr}>${slot}</${TabItemTagname}>`;
};

/** Get an array of HTML strings, one for each `<div role="tabpanel">` created by rehype-tabs for each tab item. */
/** Get an array of HTML strings, one for each `<div role="tabpanel">` created by tabs-processor for each tab item. */
const extractTabPanels = (html: string) => {
const tree = fromHtml(html, { fragment: true });
const tree = htmlToHast(html, { fragment: true });
const tabPanels = selectAll('div[role="tabpanel"]', tree);
return tabPanels.map((tabPanel) => processor.stringify({ type: 'root', children: [tabPanel] }));
return tabPanels.map((tabPanel) => toHtml(tabPanel));
};

test('empty component returns no html or panels', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/starlight/__tests__/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const frontmatterSchema = docsSchema()({
z.literal('gif'),
z.literal('svg'),
z.literal('avif'),
z.literal('apng'),
]),
}),
});
Expand Down
19 changes: 9 additions & 10 deletions packages/starlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,36 @@
},
"peerDependencies": {
"@astrojs/markdown-remark": "^7.2.0",
"astro": "^7.0.2"
"astro": "^7.2.5"
},
"peerDependenciesMeta": {
"@astrojs/markdown-remark": {
"optional": true
}
},
"devDependencies": {
"@astrojs/markdown-remark": "^7.2.2",
"@astrojs/markdown-remark": "^7.2.4",
"@playwright/test": "^1.61.1",
"@codspeed/vitest-plugin": "^5.7.1",
"@types/node": "^22.19.17",
"@vitest/coverage-v8": "^4.1.5",
"astro": "^7.1.6",
"astro": "^7.2.5",
"linkedom": "^0.18.12",
"vitest": "^4.1.5"
},
"dependencies": {
"@astrojs/markdown-satteri": "^0.3.5",
"@astrojs/mdx": "^7.0.5",
"@astrojs/markdown-satteri": "^0.3.8",
"@astrojs/mdx": "^7.0.8",
"@astrojs/sitemap": "^3.7.3",
"@pagefind/default-ui": "^1.3.0",
"@types/hast": "^3.0.4",
"@types/hast": "^3.0.5",
"@types/js-yaml": "^4.0.9",
"@types/mdast": "^4.0.4",
"astro-expressive-code": "^0.44.0",
"bcp-47": "^2.1.0",
"hast-util-from-html": "^2.0.3",
"hast-util-format": "^1.1.0",
"hast-util-select": "^6.0.4",
"hast-util-to-html": "^9.0.5",
"hast-util-to-string": "^3.0.1",
"hastscript": "^9.0.1",
"i18next": "^26.0.7",
Expand All @@ -87,10 +88,8 @@
"mdast-util-to-markdown": "^2.1.2",
"mdast-util-to-string": "^4.0.0",
"pagefind": "^1.5.2",
"rehype": "^13.0.2",
"rehype-format": "^5.0.1",
"remark-directive": "^4.0.0",
"satteri": "^0.9.1",
"satteri": "^0.10.3",
"ultrahtml": "^1.6.0",
"unified": "^11.0.5",
"unist-util-visit": "^5.1.0",
Expand Down
9 changes: 4 additions & 5 deletions packages/starlight/src/integrations/markdown-icon.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import type { Element, ElementContent } from 'hast';
import { fromHtml } from 'hast-util-from-html';
import type { ElementContent, Root } from 'hast';
import { htmlToHast } from 'satteri';
import { Icons } from '../components-internals/Icons';

export const headingLinkIconSvgChildrenHtml = Icons['link-alt'];
export const headingLinkIconChildren = parseIconChildren(headingLinkIconSvgChildrenHtml);

/** Parse a Starlight icon SVG fragment as children of an `<svg>` element. */
export function parseIconChildren(icon: string): ElementContent[] {
const svg = fromHtml(`<svg>${icon}</svg>`, { fragment: true, space: 'svg' })
.children[0] as Element;
return svg.children;
const tree = htmlToHast(icon, { fragment: true, space: 'svg' }) as Root;
return tree.children as ElementContent[];
}
Loading
Loading