@astrojs/starlight 0.30.4 → 0.30.6

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,21 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.30.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2722](https://github.com/withastro/starlight/pull/2722) [`0b206d3`](https://github.com/withastro/starlight/commit/0b206d3a23f0876146dc17f5e507984362917696) Thanks [@techfg](https://github.com/techfg)! - Fixes display of long site title on mobile
8
+
9
+ - [#2762](https://github.com/withastro/starlight/pull/2762) [`7ab1576`](https://github.com/withastro/starlight/commit/7ab157639da62fdc6b444b0280ad4c9d5ee4872f) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Prevents the header title from being translated by automatic translation systems.
10
+
11
+ ## 0.30.5
12
+
13
+ ### Patch Changes
14
+
15
+ - [#2757](https://github.com/withastro/starlight/pull/2757) [`e7b0e74`](https://github.com/withastro/starlight/commit/e7b0e742dffb7c4a8f4619297e4bd6e5a8015edb) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes a UI string translation issue for languages with a region subtag.
16
+
17
+ - [#2760](https://github.com/withastro/starlight/pull/2760) [`aec9edd`](https://github.com/withastro/starlight/commit/aec9edd14827a45fbc92d82db83dd713571e0c2d) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds 5 new icons: `left-caret`, `up-arrow`, `down-arrow`, `download`, and `cloud-download`.
18
+
3
19
  ## 0.30.4
4
20
 
5
21
  ### Patch Changes
@@ -45,6 +45,7 @@ const shouldRenderSearch =
45
45
  /* Avoid clipping focus ring around link inside title wrapper. */
46
46
  padding: 0.25rem;
47
47
  margin: -0.25rem;
48
+ min-width: 0;
48
49
  }
49
50
 
50
51
  .right-group,
@@ -7,6 +7,12 @@ export const BuiltInIcons = {
7
7
  '<path d="M17 9.17a1 1 0 0 0-1.41 0L12 12.71 8.46 9.17a1 1 0 1 0-1.41 1.42l4.24 4.24a1.002 1.002 0 0 0 1.42 0L17 10.59a1.002 1.002 0 0 0 0-1.42Z"/>',
8
8
  'right-caret':
9
9
  '<path d="m14.83 11.29-4.24-4.24a1 1 0 1 0-1.42 1.41L12.71 12l-3.54 3.54a1 1 0 0 0 0 1.41 1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.24-4.24a1.002 1.002 0 0 0 0-1.42Z"/>',
10
+ 'left-caret':
11
+ '<path d="m11.29 12 3.54-3.54a1 1 0 0 0 0-1.41 1 1 0 0 0-1.42 0l-4.24 4.24a1 1 0 0 0 0 1.42L13.41 17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29 1 1 0 0 0 0-1.41Z"/>',
12
+ 'up-arrow':
13
+ '<path d="m17.71 11.29-5-5a1 1 0 0 0-.33-.21 1 1 0 0 0-.76 0 1 1 0 0 0-.33.21l-5 5a1 1 0 0 0 1.42 1.42L11 9.41V17a1 1 0 0 0 2 0V9.41l3.29 3.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42Z"/>',
14
+ 'down-arrow':
15
+ '<path d="M17.71 11.29a1 1 0 0 0-1.42 0L13 14.59V7a1 1 0 0 0-2 0v7.59l-3.29-3.3a1 1 0 0 0-1.42 1.42l5 5a1 1 0 0 0 .33.21.94.94 0 0 0 .76 0 1 1 0 0 0 .33-.21l5-5a1 1 0 0 0 0-1.42Z"/>',
10
16
  'right-arrow':
11
17
  '<path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/>',
12
18
  'left-arrow':
@@ -25,6 +31,10 @@ export const BuiltInIcons = {
25
31
  '<path d="m21.32 9.55-1.89-.63.89-1.78A1 1 0 0 0 20.13 6L18 3.87a1 1 0 0 0-1.15-.19l-1.78.89-.63-1.89A1 1 0 0 0 13.5 2h-3a1 1 0 0 0-.95.68l-.63 1.89-1.78-.89A1 1 0 0 0 6 3.87L3.87 6a1 1 0 0 0-.19 1.15l.89 1.78-1.89.63a1 1 0 0 0-.68.94v3a1 1 0 0 0 .68.95l1.89.63-.89 1.78A1 1 0 0 0 3.87 18L6 20.13a1 1 0 0 0 1.15.19l1.78-.89.63 1.89a1 1 0 0 0 .95.68h3a1 1 0 0 0 .95-.68l.63-1.89 1.78.89a1 1 0 0 0 1.13-.19L20.13 18a1 1 0 0 0 .19-1.15l-.89-1.78 1.89-.63a1 1 0 0 0 .68-.94v-3a1 1 0 0 0-.68-.95ZM20 12.78l-1.2.4A2 2 0 0 0 17.64 16l.57 1.14-1.1 1.1-1.11-.6a2 2 0 0 0-2.79 1.16l-.4 1.2h-1.59l-.4-1.2A2 2 0 0 0 8 17.64l-1.14.57-1.1-1.1.6-1.11a2 2 0 0 0-1.16-2.82l-1.2-.4v-1.56l1.2-.4A2 2 0 0 0 6.36 8l-.57-1.11 1.1-1.1L8 6.36a2 2 0 0 0 2.82-1.16l.4-1.2h1.56l.4 1.2A2 2 0 0 0 16 6.36l1.14-.57 1.1 1.1-.6 1.11a2 2 0 0 0 1.16 2.79l1.2.4v1.59ZM12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8Zm0 6a2 2 0 1 1 0-4 2 2 0 0 1 0 4Z"/>',
26
32
  external:
27
33
  '<path d="M19.33 10.18a1 1 0 0 1-.77 0 1 1 0 0 1-.62-.93l.01-1.83-8.2 8.2a1 1 0 0 1-1.41-1.42l8.2-8.2H14.7a1 1 0 0 1 0-2h4.25a1 1 0 0 1 1 1v4.25a1 1 0 0 1-.62.93Z"/><path d="M11 4a1 1 0 1 1 0 2H7a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1v-4a1 1 0 1 1 2 0v4a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h4Z"/>',
34
+ download:
35
+ '<path d="M8.29 13.29a1 1 0 0 0 0 1.42l3 3a1 1 0 0 0 1.42 0l3-3a1 1 0 0 0-1.42-1.42L13 14.59V3a1 1 0 0 0-2 0v11.59l-1.29-1.3a1 1 0 0 0-1.42 0ZM18 9h-2a1 1 0 0 0 0 2h2a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h2a1 1 0 0 0 0-2H6a3 3 0 0 0-3 3v7a3 3 0 0 0 3 3h12a3 3 0 0 0 3-3v-7a3 3 0 0 0-3-3Z"/>',
36
+ 'cloud-download':
37
+ '<path d="M14.29 17.29 13 18.59V13a1 1 0 0 0-2 0v5.59l-1.29-1.3a1 1 0 0 0-1.42 1.42l3 3a1 1 0 0 0 .33.21.94.94 0 0 0 .76 0 1 1 0 0 0 .33-.21l3-3a1 1 0 0 0-1.42-1.42Zm4.13-11.07A7 7 0 0 0 5.06 8.11 4 4 0 0 0 6 16a1 1 0 0 0 0-2 2 2 0 0 1 0-4 1 1 0 0 0 1-1 5 5 0 0 1 9.73-1.61 1 1 0 0 0 .78.67 3 3 0 0 1 .24 5.84 1 1 0 1 0 .5 1.94 5 5 0 0 0 .17-9.62Z"/>',
28
38
  moon: '<path d="M21.64 13a1 1 0 0 0-1.05-.14 8.049 8.049 0 0 1-3.37.73 8.15 8.15 0 0 1-8.14-8.1 8.59 8.59 0 0 1 .25-2A1 1 0 0 0 8 2.36a10.14 10.14 0 1 0 14 11.69 1 1 0 0 0-.36-1.05Zm-9.5 6.69A8.14 8.14 0 0 1 7.08 5.22v.27a10.15 10.15 0 0 0 10.14 10.14 9.784 9.784 0 0 0 2.1-.22 8.11 8.11 0 0 1-7.18 4.32v-.04Z"/>',
29
39
  sun: '<path d="M5 12a1 1 0 0 0-1-1H3a1 1 0 0 0 0 2h1a1 1 0 0 0 1-1Zm.64 5-.71.71a1 1 0 0 0 0 1.41 1 1 0 0 0 1.41 0l.71-.71A1 1 0 0 0 5.64 17ZM12 5a1 1 0 0 0 1-1V3a1 1 0 0 0-2 0v1a1 1 0 0 0 1 1Zm5.66 2.34a1 1 0 0 0 .7-.29l.71-.71a1 1 0 1 0-1.41-1.41l-.66.71a1 1 0 0 0 0 1.41 1 1 0 0 0 .66.29Zm-12-.29a1 1 0 0 0 1.41 0 1 1 0 0 0 0-1.41l-.71-.71a1.004 1.004 0 1 0-1.43 1.41l.73.71ZM21 11h-1a1 1 0 0 0 0 2h1a1 1 0 0 0 0-2Zm-2.64 6A1 1 0 0 0 17 18.36l.71.71a1 1 0 0 0 1.41 0 1 1 0 0 0 0-1.41l-.76-.66ZM12 6.5a5.5 5.5 0 1 0 5.5 5.5A5.51 5.51 0 0 0 12 6.5Zm0 9a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7Zm0 3.5a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-1a1 1 0 0 0-1-1Z"/>',
30
40
  laptop:
@@ -29,7 +29,7 @@ const { siteTitle, siteTitleHref } = Astro.props;
29
29
  </>
30
30
  )
31
31
  }
32
- <span class:list={{ 'sr-only': config.logo?.replacesTitle }}>
32
+ <span class:list={{ 'sr-only': config.logo?.replacesTitle }} translate="no">
33
33
  {siteTitle}
34
34
  </span>
35
35
  </a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.30.4",
3
+ "version": "0.30.6",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
@@ -13,7 +13,12 @@ import type {
13
13
  import { createPathFormatter } from './createPathFormatter';
14
14
  import { formatPath } from './format-path';
15
15
  import { BuiltInDefaultLocale, pickLang } from './i18n';
16
- import { ensureLeadingSlash, ensureTrailingSlash, stripLeadingAndTrailingSlashes } from './path';
16
+ import {
17
+ ensureLeadingSlash,
18
+ ensureTrailingSlash,
19
+ stripExtension,
20
+ stripLeadingAndTrailingSlashes,
21
+ } from './path';
17
22
  import { getLocaleRoutes, routes, type Route } from './routing';
18
23
  import { localeToLang, localizedId, slugToPathname } from './slugs';
19
24
  import type { StarlightConfig } from './user-config';
@@ -510,12 +515,6 @@ function applyPrevNextLinkConfig(
510
515
  return paginationEnabled ? link : undefined;
511
516
  }
512
517
 
513
- /** Remove the extension from a path. */
514
- function stripExtension(path: string) {
515
- const periodIndex = path.lastIndexOf('.');
516
- return path.slice(0, periodIndex > -1 ? periodIndex : undefined);
517
- }
518
-
519
518
  /** Get a sidebar badge for a given item. */
520
519
  function getSidebarBadge(
521
520
  config: I18nBadgeConfig,
package/utils/path.ts CHANGED
@@ -50,3 +50,9 @@ export function ensureHtmlExtension(path: string) {
50
50
  }
51
51
  return ensureLeadingSlash(path);
52
52
  }
53
+
54
+ /** Remove the extension from a path. */
55
+ export function stripExtension(path: string) {
56
+ const periodIndex = path.lastIndexOf('.');
57
+ return path.slice(0, periodIndex > -1 ? periodIndex : undefined);
58
+ }
@@ -1,15 +1,20 @@
1
1
  import { getCollection, type CollectionEntry, type DataCollectionKey } from 'astro:content';
2
2
  import config from 'virtual:starlight/user-config';
3
+ import project from 'virtual:starlight/project-context';
3
4
  import pluginTranslations from 'virtual:starlight/plugin-translations';
4
5
  import type { i18nSchemaOutput } from '../schemas/i18n';
5
6
  import { createTranslationSystem } from './createTranslationSystem';
6
7
  import type { RemoveIndexSignature } from './types';
8
+ import { getCollectionPathFromRoot } from './collection';
9
+ import { stripExtension, stripLeadingSlash } from './path';
7
10
 
8
11
  // @ts-ignore - This may be a type error in projects without an i18n collection and running
9
12
  // `tsc --noEmit` in their project. Note that it is not possible to inline this type in
10
13
  // `UserI18nSchema` because this would break types for users having multiple data collections.
11
14
  type i18nCollection = CollectionEntry<'i18n'>;
12
15
 
16
+ const i18nCollectionPathFromRoot = getCollectionPathFromRoot('i18n', project);
17
+
13
18
  export type UserI18nSchema = 'i18n' extends DataCollectionKey
14
19
  ? i18nCollection extends { data: infer T }
15
20
  ? i18nSchemaOutput & T
@@ -17,14 +22,20 @@ export type UserI18nSchema = 'i18n' extends DataCollectionKey
17
22
  : i18nSchemaOutput;
18
23
  export type UserI18nKeys = keyof RemoveIndexSignature<UserI18nSchema>;
19
24
 
20
- /** Get all translation data from the i18n collection, keyed by `id`, which matches locale. */
25
+ /** Get all translation data from the i18n collection, keyed by `lang`, which are BCP-47 language tags. */
21
26
  async function loadTranslations() {
22
27
  // Briefly override `console.warn()` to silence logging when a project has no i18n collection.
23
28
  const warn = console.warn;
24
29
  console.warn = () => {};
25
30
  const userTranslations: Record<string, UserI18nSchema> = Object.fromEntries(
26
31
  // @ts-ignore — may be a type error in projects without an i18n collection
27
- (await getCollection('i18n')).map(({ id, data }) => [id, data] as const)
32
+ (await getCollection('i18n')).map(({ id, data, filePath }) => {
33
+ const lang =
34
+ project.legacyCollections || !filePath
35
+ ? id
36
+ : stripExtension(stripLeadingSlash(filePath.replace(i18nCollectionPathFromRoot, '')));
37
+ return [lang, data] as const;
38
+ })
28
39
  );
29
40
  // Restore the original warn implementation.
30
41
  console.warn = warn;
@@ -1,16 +1,3 @@
1
- declare module 'virtual:starlight/project-context' {
2
- const ProjectContext: {
3
- root: string;
4
- srcDir: string;
5
- trailingSlash: import('astro').AstroConfig['trailingSlash'];
6
- build: {
7
- format: import('astro').AstroConfig['build']['format'];
8
- };
9
- legacyCollections: boolean;
10
- };
11
- export default ProjectContext;
12
- }
13
-
14
1
  declare module 'virtual:starlight/git-info' {
15
2
  export function getNewestCommitDate(file: string): Date;
16
3
  }
package/virtual.d.ts CHANGED
@@ -7,3 +7,18 @@ declare module 'virtual:starlight/plugin-translations' {
7
7
  const PluginTranslations: import('./utils/plugins').PluginTranslations;
8
8
  export default PluginTranslations;
9
9
  }
10
+
11
+ // TODO: Move back to `virtual-internal.d.ts` when possible. For example, when dropping support for
12
+ // legacy collections, `utils/translations.ts` would no longer need to import project context.
13
+ declare module 'virtual:starlight/project-context' {
14
+ const ProjectContext: {
15
+ root: string;
16
+ srcDir: string;
17
+ trailingSlash: import('astro').AstroConfig['trailingSlash'];
18
+ build: {
19
+ format: import('astro').AstroConfig['build']['format'];
20
+ };
21
+ legacyCollections: boolean;
22
+ };
23
+ export default ProjectContext;
24
+ }