@astrojs/starlight 0.17.2 → 0.17.3
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
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.17.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1461](https://github.com/withastro/starlight/pull/1461) [`2e17880`](https://github.com/withastro/starlight/commit/2e17880957d1aae2a84c77500afa9b66e5292a6a) Thanks [@liruifengv](https://github.com/liruifengv)! - Improves the table of contents title translation in Simplified Chinese
|
|
8
|
+
|
|
9
|
+
- [#1462](https://github.com/withastro/starlight/pull/1462) [`4741ccc`](https://github.com/withastro/starlight/commit/4741cccc8adbef500bcaf95416a1c61a90761c06) Thanks [@delucis](https://github.com/delucis)! - Fixes overflow of very long site titles on narrow viewports
|
|
10
|
+
|
|
11
|
+
- [#1459](https://github.com/withastro/starlight/pull/1459) [`9a8e0ec`](https://github.com/withastro/starlight/commit/9a8e0ec59cba0e088512ea9b6d17224085f3a178) Thanks [@delucis](https://github.com/delucis)! - Fixes a bug where table of contents highlighting could break given very specific combinations of content and viewport size
|
|
12
|
+
|
|
13
|
+
- [#1458](https://github.com/withastro/starlight/pull/1458) [`8c88642`](https://github.com/withastro/starlight/commit/8c88642875e8344396074a780e28fb0860b249f8) Thanks [@delucis](https://github.com/delucis)! - Silences i18n content collection warnings for projects without custom translations.
|
|
14
|
+
|
|
3
15
|
## 0.17.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/components/Header.astro
CHANGED
|
@@ -16,7 +16,7 @@ const shouldRenderSearch =
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
<div class="header sl-flex">
|
|
19
|
-
<div class="sl-flex">
|
|
19
|
+
<div class="title-wrapper sl-flex">
|
|
20
20
|
<SiteTitle {...Astro.props} />
|
|
21
21
|
</div>
|
|
22
22
|
<div class="sl-flex">
|
|
@@ -39,6 +39,11 @@ const shouldRenderSearch =
|
|
|
39
39
|
height: 100%;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
.title-wrapper {
|
|
43
|
+
/* Prevent long titles overflowing and covering the search and menu buttons on narrow viewports. */
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
.right-group,
|
|
43
48
|
.social-icons {
|
|
44
49
|
gap: 1rem;
|
|
@@ -95,8 +95,8 @@ export class StarlightTOC extends HTMLElement {
|
|
|
95
95
|
const mobileTocHeight = this.querySelector('summary')?.getBoundingClientRect().height || 0;
|
|
96
96
|
/** Start intersections at nav height + 2rem padding. */
|
|
97
97
|
const top = navBarHeight + mobileTocHeight + 32;
|
|
98
|
-
/** End intersections
|
|
99
|
-
const bottom = top +
|
|
98
|
+
/** End intersections `53px` later. This is slightly more than the maximum `margin-top` in Markdown content. */
|
|
99
|
+
const bottom = top + 53;
|
|
100
100
|
const height = document.documentElement.clientHeight;
|
|
101
101
|
return `-${top}px 0% ${bottom - height}px`;
|
|
102
102
|
}
|
package/package.json
CHANGED
package/translations/zh-CN.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"languageSelect.accessibleLabel": "选择语言",
|
|
12
12
|
"menuButton.accessibleLabel": "菜单",
|
|
13
13
|
"sidebarNav.accessibleLabel": "主要",
|
|
14
|
-
"tableOfContents.onThisPage": "
|
|
14
|
+
"tableOfContents.onThisPage": "本页内容",
|
|
15
15
|
"tableOfContents.overview": "概述",
|
|
16
16
|
"i18n.untranslatedContent": "此内容尚不支持你的语言。",
|
|
17
17
|
"page.editLink": "编辑此页",
|
package/utils/translations.ts
CHANGED
|
@@ -3,16 +3,23 @@ import config from 'virtual:starlight/user-config';
|
|
|
3
3
|
import type { i18nSchemaOutput } from '../schemas/i18n';
|
|
4
4
|
import { createTranslationSystem } from './createTranslationSystem';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
/** Get all translation data from the i18n collection, keyed by `id`, which matches locale. */
|
|
7
|
+
async function loadTranslations() {
|
|
8
|
+
let userTranslations: Record<string, i18nSchemaOutput> = {};
|
|
9
|
+
// Briefly override `console.warn()` to silence logging when a project has no i18n collection.
|
|
10
|
+
const warn = console.warn;
|
|
11
|
+
console.warn = () => {};
|
|
12
|
+
try {
|
|
13
|
+
// Load the user’s i18n collection and ignore the error if it doesn’t exist.
|
|
14
|
+
userTranslations = Object.fromEntries(
|
|
15
|
+
// @ts-ignore — may be an error in projects without an i18n collection
|
|
16
|
+
(await getCollection('i18n')).map(({ id, data }) => [id, data] as const)
|
|
17
|
+
);
|
|
18
|
+
} catch {}
|
|
19
|
+
// Restore the original warn implementation.
|
|
20
|
+
console.warn = warn;
|
|
21
|
+
return userTranslations;
|
|
22
|
+
}
|
|
16
23
|
|
|
17
24
|
/**
|
|
18
25
|
* Generate a utility function that returns UI strings for the given `locale`.
|
|
@@ -21,4 +28,4 @@ try {
|
|
|
21
28
|
* const t = useTranslations('en');
|
|
22
29
|
* const label = t('search.label'); // => 'Search'
|
|
23
30
|
*/
|
|
24
|
-
export const useTranslations = createTranslationSystem(
|
|
31
|
+
export const useTranslations = createTranslationSystem(await loadTranslations(), config);
|