@astrojs/starlight 0.22.0 → 0.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/__e2e__/fixtures/basics/node_modules/.bin/astro +2 -2
- package/__e2e__/fixtures/basics/src/content/docs/tabs.mdx +17 -0
- package/__e2e__/tabs.test.ts +23 -0
- package/package.json +1 -1
- package/translations/ru.json +2 -2
- package/user-components/Tabs.astro +2 -2
- package/utils/createPathFormatter.ts +1 -0
- package/utils/route-data.ts +1 -1
- package/utils/starlight-page.ts +2 -1
- package/utils/user-config.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.22.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1811](https://github.com/withastro/starlight/pull/1811) [`fe06aa13`](https://github.com/withastro/starlight/commit/fe06aa1307208ef9f5b249181ec29837f96940c2) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes a `<Tabs>` sync issue when inconsistently using the `icon` prop or not on `<TabItem>` components.
|
|
8
|
+
|
|
9
|
+
- [#1826](https://github.com/withastro/starlight/pull/1826) [`52ea7381`](https://github.com/withastro/starlight/commit/52ea7381e131338a03cffb3499ba1699951cea1e) Thanks [@dragomano](https://github.com/dragomano)! - Updates Russian UI translations
|
|
10
|
+
|
|
11
|
+
## 0.22.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`1c0fc384`](https://github.com/withastro/starlight/commit/1c0fc3849771713d5a3e7a572bdbf1483ae5551b) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue where the `siteTitle` property would not be set when using the `<StarlightPage />` component.
|
|
16
|
+
|
|
3
17
|
## 0.22.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/starlight/starlight/node_modules/.pnpm/astro@4.3.5_@types+node@18.16.
|
|
9
|
+
export NODE_PATH="/home/runner/work/starlight/starlight/node_modules/.pnpm/astro@4.3.5_@types+node@18.16.19_typescript@5.4.5/node_modules/astro/node_modules:/home/runner/work/starlight/starlight/node_modules/.pnpm/astro@4.3.5_@types+node@18.16.19_typescript@5.4.5/node_modules:/home/runner/work/starlight/starlight/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="/home/runner/work/starlight/starlight/node_modules/.pnpm/astro@4.3.5_@types+node@18.16.
|
|
11
|
+
export NODE_PATH="/home/runner/work/starlight/starlight/node_modules/.pnpm/astro@4.3.5_@types+node@18.16.19_typescript@5.4.5/node_modules/astro/node_modules:/home/runner/work/starlight/starlight/node_modules/.pnpm/astro@4.3.5_@types+node@18.16.19_typescript@5.4.5/node_modules:/home/runner/work/starlight/starlight/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../astro/astro.js" "$@"
|
|
@@ -35,3 +35,20 @@ A set of tabs using the `style` sync key.
|
|
|
35
35
|
<TabItem label="css">css code</TabItem>
|
|
36
36
|
<TabItem label="tailwind">tailwind code</TabItem>
|
|
37
37
|
</Tabs>
|
|
38
|
+
|
|
39
|
+
Another set of tabs using the `pkg` sync key and using icons.
|
|
40
|
+
|
|
41
|
+
<Tabs syncKey="pkg">
|
|
42
|
+
<TabItem label="npm" icon="seti:npm">
|
|
43
|
+
another npm command
|
|
44
|
+
</TabItem>
|
|
45
|
+
<TabItem label="pnpm" icon="pnpm">
|
|
46
|
+
another pnpm command
|
|
47
|
+
</TabItem>
|
|
48
|
+
<TabItem label="bun" icon="bun">
|
|
49
|
+
another bun command
|
|
50
|
+
</TabItem>
|
|
51
|
+
<TabItem label="yarn" icon="seti:yarn">
|
|
52
|
+
another yarn command
|
|
53
|
+
</TabItem>
|
|
54
|
+
</Tabs>
|
package/__e2e__/tabs.test.ts
CHANGED
|
@@ -116,6 +116,29 @@ test('preserves tabs position when alternating between tabs with different conte
|
|
|
116
116
|
expect((await tabs.boundingBox())?.y).toBe(initialBoundingBox?.y);
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
+
test('syncs tabs with the same sync key if they do not consistenly use icons', async ({
|
|
120
|
+
page,
|
|
121
|
+
starlight,
|
|
122
|
+
}) => {
|
|
123
|
+
await starlight.goto('/tabs');
|
|
124
|
+
|
|
125
|
+
const tabs = page.locator('starlight-tabs');
|
|
126
|
+
const pkgTabsA = tabs.nth(0); // This set does not use icons for tab items.
|
|
127
|
+
const pkgTabsB = tabs.nth(4); // This set uses icons for tab items.
|
|
128
|
+
|
|
129
|
+
// Select the pnpm tab in the first set of synced tabs.
|
|
130
|
+
await pkgTabsA.getByRole('tab').filter({ hasText: 'pnpm' }).click();
|
|
131
|
+
|
|
132
|
+
await expectSelectedTab(pkgTabsA, 'pnpm', 'pnpm command');
|
|
133
|
+
await expectSelectedTab(pkgTabsB, 'pnpm', 'another pnpm command');
|
|
134
|
+
|
|
135
|
+
// Select the yarn tab in the second set of synced tabs.
|
|
136
|
+
await pkgTabsB.getByRole('tab').filter({ hasText: 'yarn' }).click();
|
|
137
|
+
|
|
138
|
+
await expectSelectedTab(pkgTabsB, 'yarn', 'another yarn command');
|
|
139
|
+
await expectSelectedTab(pkgTabsA, 'yarn', 'yarn command');
|
|
140
|
+
});
|
|
141
|
+
|
|
119
142
|
async function expectSelectedTab(tabs: Locator, label: string, panel: string) {
|
|
120
143
|
expect((await tabs.getByRole('tab', { selected: true }).textContent())?.trim()).toBe(label);
|
|
121
144
|
expect((await tabs.getByRole('tabpanel').textContent())?.trim()).toBe(panel);
|
package/package.json
CHANGED
package/translations/ru.json
CHANGED
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"page.lastUpdated": "Последнее обновление:",
|
|
19
19
|
"page.previousLink": "Предыдущая",
|
|
20
20
|
"page.nextLink": "Следующая",
|
|
21
|
-
"page.draft": "
|
|
21
|
+
"page.draft": "Этот контент является черновиком и не будет добавлен в производственные сборки.",
|
|
22
22
|
"404.text": "Страница не найдена. Проверьте URL или используйте поиск по сайту.",
|
|
23
23
|
"aside.note": "Заметка",
|
|
24
|
-
"aside.tip": "
|
|
24
|
+
"aside.tip": "Совет",
|
|
25
25
|
"aside.caution": "Осторожно",
|
|
26
26
|
"aside.danger": "Опасно",
|
|
27
27
|
"fileTree.directory": "Директория",
|
|
@@ -158,7 +158,7 @@ const { html, panels } = processPanels(panelHtml);
|
|
|
158
158
|
newTab.setAttribute('aria-selected', 'true');
|
|
159
159
|
if (shouldSync) {
|
|
160
160
|
newTab.focus();
|
|
161
|
-
StarlightTabs.#syncTabs(this, newTab.
|
|
161
|
+
StarlightTabs.#syncTabs(this, newTab.innerText);
|
|
162
162
|
window.scrollTo({
|
|
163
163
|
top: window.scrollY + (this.getBoundingClientRect().top - previousTabsOffset),
|
|
164
164
|
});
|
|
@@ -173,7 +173,7 @@ const { html, panels } = processPanels(panelHtml);
|
|
|
173
173
|
|
|
174
174
|
for (const receiver of syncedTabs) {
|
|
175
175
|
if (receiver === emitter) continue;
|
|
176
|
-
const labelIndex = receiver.tabs.findIndex((tab) => tab.
|
|
176
|
+
const labelIndex = receiver.tabs.findIndex((tab) => tab.innerText === label);
|
|
177
177
|
if (labelIndex === -1) continue;
|
|
178
178
|
receiver.switchTab(receiver.tabs[labelIndex], labelIndex, false);
|
|
179
179
|
}
|
|
@@ -34,6 +34,7 @@ function formatPath(
|
|
|
34
34
|
href: string,
|
|
35
35
|
{ format = 'directory', trailingSlash = 'ignore' }: FormatPathOptions
|
|
36
36
|
) {
|
|
37
|
+
// @ts-expect-error — TODO: add support for `preserve` (https://github.com/withastro/starlight/issues/1781)
|
|
37
38
|
const formatStrategy = formatStrategies[format];
|
|
38
39
|
const trailingSlashStrategy = trailingSlashStrategies[trailingSlash];
|
|
39
40
|
|
package/utils/route-data.ts
CHANGED
|
@@ -111,7 +111,7 @@ function getEditUrl({ entry, id, isFallback }: PageProps): URL | undefined {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/** Get the site title for a given language. **/
|
|
114
|
-
function getSiteTitle(lang: string): string {
|
|
114
|
+
export function getSiteTitle(lang: string): string {
|
|
115
115
|
const defaultLang = config.defaultLocale.lang as string;
|
|
116
116
|
if (lang && config.title[lang]) {
|
|
117
117
|
return config.title[lang] as string;
|
package/utils/starlight-page.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type ContentConfig, type SchemaContext } from 'astro:content';
|
|
|
3
3
|
import config from 'virtual:starlight/user-config';
|
|
4
4
|
import { parseWithFriendlyErrors } from './error-map';
|
|
5
5
|
import { stripLeadingAndTrailingSlashes } from './path';
|
|
6
|
-
import { getToC, type PageProps, type StarlightRouteData } from './route-data';
|
|
6
|
+
import { getSiteTitle, getToC, type PageProps, type StarlightRouteData } from './route-data';
|
|
7
7
|
import type { StarlightDocsEntry } from './routing';
|
|
8
8
|
import { slugToLocaleData, urlToSlug } from './slugs';
|
|
9
9
|
import { getPrevNextLinks, getSidebar } from './navigation';
|
|
@@ -223,6 +223,7 @@ export async function generateStarlightPageRouteData({
|
|
|
223
223
|
lastUpdated,
|
|
224
224
|
pagination: getPrevNextLinks(sidebar, config.pagination, entry.data),
|
|
225
225
|
sidebar,
|
|
226
|
+
siteTitle: getSiteTitle(localeData.lang),
|
|
226
227
|
slug,
|
|
227
228
|
toc: getToC({
|
|
228
229
|
...routeProps,
|
package/utils/user-config.ts
CHANGED