@astrojs/starlight 0.17.2 → 0.17.4

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,25 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.17.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1473](https://github.com/withastro/starlight/pull/1473) [`29da505`](https://github.com/withastro/starlight/commit/29da505474174fefaec4e27a2c2c3e90e3f68a31) Thanks [@delucis](https://github.com/delucis)! - Fixes a CSS bug for users with JavaScript disabled
8
+
9
+ - [#1465](https://github.com/withastro/starlight/pull/1465) [`ce3108c`](https://github.com/withastro/starlight/commit/ce3108cf6ecb77d12db973485d21e0fc7fd63ca6) Thanks [@delucis](https://github.com/delucis)! - Updates internal MDX, sitemap, and Expressive Code dependencies to the latest versions
10
+
11
+ ## 0.17.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [#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
16
+
17
+ - [#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
18
+
19
+ - [#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
20
+
21
+ - [#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.
22
+
3
23
  ## 0.17.2
4
24
 
5
25
  ### Patch Changes
@@ -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;
@@ -42,6 +42,7 @@ const pagefindEnabled =
42
42
  data-has-toc={Boolean(Astro.props.toc)}
43
43
  data-has-sidebar={Astro.props.hasSidebar}
44
44
  data-has-hero={Boolean(Astro.props.entry.data.hero)}
45
+ data-theme="dark"
45
46
  >
46
47
  <head>
47
48
  <Head {...Astro.props} />
@@ -38,9 +38,6 @@ const href = formatPath(Astro.props.locale || '/');
38
38
 
39
39
  <style>
40
40
  .site-title {
41
- justify-self: flex-start;
42
- max-width: 100%;
43
- overflow: hidden;
44
41
  align-items: center;
45
42
  gap: var(--sl-nav-gap);
46
43
  font-size: var(--sl-text-h4);
@@ -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 1.5rem later. */
99
- const bottom = top + 24;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.17.2",
3
+ "version": "0.17.4",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
@@ -166,19 +166,19 @@
166
166
  "astro": "^4.0.0"
167
167
  },
168
168
  "devDependencies": {
169
- "@astrojs/markdown-remark": "^4.0.1",
169
+ "@astrojs/markdown-remark": "^4.2.1",
170
170
  "@types/node": "^18.16.19",
171
171
  "@vitest/coverage-v8": "^1.2.2",
172
- "astro": "^4.2.1",
172
+ "astro": "^4.3.4",
173
173
  "vitest": "^1.2.2"
174
174
  },
175
175
  "dependencies": {
176
- "@astrojs/mdx": "^2.0.4",
177
- "@astrojs/sitemap": "^3.0.4",
176
+ "@astrojs/mdx": "^2.1.1",
177
+ "@astrojs/sitemap": "^3.0.5",
178
178
  "@pagefind/default-ui": "^1.0.3",
179
179
  "@types/hast": "^3.0.3",
180
180
  "@types/mdast": "^4.0.3",
181
- "astro-expressive-code": "^0.32.2",
181
+ "astro-expressive-code": "^0.32.4",
182
182
  "bcp-47": "^2.1.0",
183
183
  "hast-util-select": "^6.0.2",
184
184
  "hastscript": "^8.0.0",
@@ -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": "编辑此页",
@@ -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
- /** All translation data from the i18n collection, keyed by `id`, which matches locale. */
7
- let userTranslations: Record<string, i18nSchemaOutput> = {};
8
- try {
9
- // Load the user’s i18n collection and ignore the error if it doesn’t exist.
10
- userTranslations = Object.fromEntries(
11
- // @ts-ignore may be an error in projects without an i18n collection
12
-
13
- (await getCollection('i18n')).map(({ id, data }) => [id, data] as const)
14
- );
15
- } catch {}
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(userTranslations, config);
31
+ export const useTranslations = createTranslationSystem(await loadTranslations(), config);