@astrojs/starlight 0.30.1 → 0.30.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,25 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.30.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2717](https://github.com/withastro/starlight/pull/2717) [`c5fcbb3`](https://github.com/withastro/starlight/commit/c5fcbb33a7a0511ac372f5d006a69f4195d1e266) Thanks [@delucis](https://github.com/delucis)! - Fixes a list item spacing issue where line break elements (`<br>`) could receive a margin, breaking layout in Firefox
8
+
9
+ - [#2724](https://github.com/withastro/starlight/pull/2724) [`02d7ac6`](https://github.com/withastro/starlight/commit/02d7ac66a0bdca3f26001f556de070027d4e0faf) Thanks [@dionysuzx](https://github.com/dionysuzx)! - Adds social link support for Farcaster
10
+
11
+ - [#2635](https://github.com/withastro/starlight/pull/2635) [`ec4b851`](https://github.com/withastro/starlight/commit/ec4b85154ea301d9144ff49f3abd009e3a929387) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue where the language picker in multilingual sites could display the wrong language when navigating between pages with the browser back/forward buttons.
12
+
13
+ - [#2726](https://github.com/withastro/starlight/pull/2726) [`e54ebd5`](https://github.com/withastro/starlight/commit/e54ebd5c879deb3fdff2180426b377181773b85f) Thanks [@techfg](https://github.com/techfg)! - Adds icon for phone
14
+
15
+ ## 0.30.2
16
+
17
+ ### Patch Changes
18
+
19
+ - [#2702](https://github.com/withastro/starlight/pull/2702) [`02d16f3`](https://github.com/withastro/starlight/commit/02d16f3638db609501897c5e3647cc20eb5ec142) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue with autogenerated sidebars when using Starlight with Astro's new Content Layer API with directories containing spaces or special characters.
20
+
21
+ - [#2704](https://github.com/withastro/starlight/pull/2704) [`fd16470`](https://github.com/withastro/starlight/commit/fd164704b25ec5c000a2765eb0930b87e9a4e61e) Thanks [@delucis](https://github.com/delucis)! - Fixes display of focus indicator around site title
22
+
3
23
  ## 0.30.1
4
24
 
5
25
  ### Patch Changes
@@ -41,7 +41,10 @@ const shouldRenderSearch =
41
41
 
42
42
  .title-wrapper {
43
43
  /* Prevent long titles overflowing and covering the search and menu buttons on narrow viewports. */
44
- overflow: hidden;
44
+ overflow: clip;
45
+ /* Avoid clipping focus ring around link inside title wrapper. */
46
+ padding: 0.25rem;
47
+ margin: -0.25rem;
45
48
  }
46
49
 
47
50
  .right-group,
@@ -108,6 +108,8 @@ export const BuiltInIcons = {
108
108
  '<path d="M20.9 2H3.1A1.1 1.1 0 0 0 2 3.1v17.8A1.1 1.1 0 0 0 3.1 22h9.58v-7.75h-2.6v-3h2.6V9a3.64 3.64 0 0 1 3.88-4 20.26 20.26 0 0 1 2.33.12v2.7H17.3c-1.26 0-1.5.6-1.5 1.47v1.93h3l-.39 3H15.8V22h5.1a1.1 1.1 0 0 0 1.1-1.1V3.1A1.1 1.1 0 0 0 20.9 2Z"/>',
109
109
  email:
110
110
  '<path d="M19 4H5a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3V7a3 3 0 0 0-3-3Zm-.41 2-5.88 5.88a1 1 0 0 1-1.42 0L5.41 6ZM20 17a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7.41l5.88 5.88a3 3 0 0 0 4.24 0L20 7.41Z"/>',
111
+ phone:
112
+ '<path d="M19.44 13c-.22 0-.45-.07-.67-.12a9.44 9.44 0 0 1-1.31-.39 2 2 0 0 0-2.48 1l-.22.45a12.18 12.18 0 0 1-2.66-2 12.18 12.18 0 0 1-2-2.66l.42-.28a2 2 0 0 0 1-2.48 10.33 10.33 0 0 1-.39-1.31c-.05-.22-.09-.45-.12-.68a3 3 0 0 0-3-2.49h-3a3 3 0 0 0-3 3.41 19 19 0 0 0 16.52 16.46h.38a3 3 0 0 0 2-.76 3 3 0 0 0 1-2.25v-3a3 3 0 0 0-2.47-2.9Zm.5 6a1 1 0 0 1-.34.75 1.05 1.05 0 0 1-.82.25A17 17 0 0 1 4.07 5.22a1.09 1.09 0 0 1 .25-.82 1 1 0 0 1 .75-.34h3a1 1 0 0 1 1 .79q.06.41.15.81a11.12 11.12 0 0 0 .46 1.55l-1.4.65a1 1 0 0 0-.49 1.33 14.49 14.49 0 0 0 7 7 1 1 0 0 0 .76 0 1 1 0 0 0 .57-.52l.62-1.4a13.69 13.69 0 0 0 1.58.46q.4.09.81.15a1 1 0 0 1 .79 1Z"/>',
111
113
  reddit:
112
114
  '<path d="M14.41 16.87a3.38 3.38 0 0 1-2.37.63 3.37 3.37 0 0 1-2.36-.63 1 1 0 0 0-1.42 1.41 5.11 5.11 0 0 0 3.78 1.22 5.12 5.12 0 0 0 3.78-1.22 1 1 0 1 0-1.41-1.41ZM9.2 15a1 1 0 1 0-1-1 1 1 0 0 0 1 1Zm6-2a1 1 0 1 0 1 1 1 1 0 0 0-1-1Zm7.8-1.22a3.77 3.77 0 0 0-6.8-2.26 16.5 16.5 0 0 0-3.04-.48l.85-5.7 2.09.7a3 3 0 0 0 6-.06v-.02a3.03 3.03 0 0 0-3-2.96 2.98 2.98 0 0 0-2.34 1.16l-3.24-1.1a1 1 0 0 0-1.3.8l-1.09 7.17a16.66 16.66 0 0 0-3.34.49 3.77 3.77 0 0 0-6.22 4.23A4.86 4.86 0 0 0 1 16c0 3.92 4.83 7 11 7s11-3.08 11-7a4.86 4.86 0 0 0-.57-2.25 3.78 3.78 0 0 0 .57-1.97ZM19.1 3a1 1 0 1 1-1 1 1.02 1.02 0 0 1 1-1ZM4.77 10a1.76 1.76 0 0 1 .88.25A9.98 9.98 0 0 0 3 11.92v-.14A1.78 1.78 0 0 1 4.78 10ZM12 21c-4.88 0-9-2.29-9-5s4.12-5 9-5 9 2.29 9 5-4.12 5-9 5Zm8.99-9.08a9.98 9.98 0 0 0-2.65-1.67 1.76 1.76 0 0 1 .88-.25A1.78 1.78 0 0 1 21 11.78l-.01.14Z"/>',
113
115
  patreon:
@@ -42,6 +42,16 @@ function localizedPathname(locale: string | undefined): string {
42
42
  window.location.pathname = e.currentTarget.value;
43
43
  }
44
44
  });
45
+ window.addEventListener('pageshow', (event) => {
46
+ if (!event.persisted) return;
47
+ // If the page was loaded from a cache, the language select selected index might not be
48
+ // in sync with the current page.
49
+ const markupSelectedIndex =
50
+ select.querySelector<HTMLOptionElement>('option[selected]')?.index;
51
+ if (markupSelectedIndex !== select.selectedIndex) {
52
+ select.selectedIndex = markupSelectedIndex ?? 0;
53
+ }
54
+ });
45
55
  }
46
56
  }
47
57
  }
@@ -12,12 +12,21 @@ interface Props {
12
12
  selected: boolean;
13
13
  }>;
14
14
  }
15
+
16
+ /**
17
+ * The `autocomplete="off"` attribute is used to prevent the browser from automatically selecting a
18
+ * value for this input, e.g. based on the user's previous selections, as this could lead to
19
+ * incorrect values being selected for example when the user switches between languages and uses
20
+ * the back button.
21
+ * Note that this attribute is only useful when a value is not restored at a later stage, e.g. the
22
+ * bfcache that ignores this attribute when restoring the value.
23
+ */
15
24
  ---
16
25
 
17
26
  <label style={`--sl-select-width: ${Astro.props.width}`}>
18
27
  <span class="sr-only">{Astro.props.label}</span>
19
28
  <Icon name={Astro.props.icon} class="icon label-icon" />
20
- <select value={Astro.props.value}>
29
+ <select value={Astro.props.value} autocomplete="off">
21
30
  {
22
31
  Astro.props.options.map(({ value, selected, label }) => (
23
32
  <option value={value} selected={selected} set:html={label} />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.30.1",
3
+ "version": "0.30.3",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
package/schemas/social.ts CHANGED
@@ -37,6 +37,7 @@ export const socialLinks = [
37
37
  'tiktok',
38
38
  'nostr',
39
39
  'backstage',
40
+ 'farcaster',
40
41
  ] as const;
41
42
 
42
43
  export const SocialLinksSchema = () =>
@@ -89,6 +90,7 @@ export const SocialLinksSchema = () =>
89
90
  tiktok: 'TikTok',
90
91
  nostr: 'Nostr',
91
92
  backstage: 'Backstage',
93
+ farcaster: 'Farcaster',
92
94
  }[key];
93
95
  labelledLinks[key] = { label, url };
94
96
  }
@@ -24,7 +24,7 @@
24
24
 
25
25
  .sl-markdown-content
26
26
  li
27
- > :last-child:not(li, ul, ol):not(a, strong, em, del, span, input, :where(.not-content *)) {
27
+ > :last-child:not(li, ul, ol, a, strong, em, del, span, input, code, br, :where(.not-content *)) {
28
28
  margin-bottom: 1.25rem;
29
29
  }
30
30
 
@@ -24,6 +24,8 @@ const SlugKey = Symbol('SlugKey');
24
24
 
25
25
  const neverPathFormatter = createPathFormatter({ trailingSlash: 'never' });
26
26
 
27
+ const docsCollectionPathFromRoot = getCollectionPathFromRoot('docs', project);
28
+
27
29
  export interface Link {
28
30
  type: 'link';
29
31
  label: string;
@@ -103,13 +105,15 @@ function groupFromAutogenerateConfig(
103
105
  ): Group {
104
106
  const { collapsed: subgroupCollapsed, directory } = item.autogenerate;
105
107
  const localeDir = locale ? locale + '/' + directory : directory;
106
- const dirDocs = routes.filter(
107
- (doc) =>
108
+ const dirDocs = routes.filter((doc) => {
109
+ const filePathFromContentDir = getRoutePathRelativeToCollectionRoot(doc, locale);
110
+ return (
108
111
  // Match against `foo.md` or `foo/index.md`.
109
- stripExtension(doc.id) === localeDir ||
112
+ stripExtension(filePathFromContentDir) === localeDir ||
110
113
  // Match against `foo/anything/else.md`.
111
- doc.id.startsWith(localeDir + '/')
112
- );
114
+ filePathFromContentDir.startsWith(localeDir + '/')
115
+ );
116
+ });
113
117
  const tree = treeify(dirDocs, locale, localeDir);
114
118
  const label = pickLang(item.translations, localeToLang(locale)) || item.label;
115
119
  return {
@@ -219,24 +223,22 @@ function getBreadcrumbs(path: string, baseDir: string): string[] {
219
223
  return relativePath.split('/');
220
224
  }
221
225
 
226
+ /** Return the path of a route relative to the root of the collection, which is equivalent to legacy IDs. */
227
+ function getRoutePathRelativeToCollectionRoot(route: Route, locale: string | undefined) {
228
+ return project.legacyCollections
229
+ ? route.id
230
+ : // For collections with a loader, use a localized filePath relative to the collection
231
+ localizedId(route.entry.filePath.replace(`${docsCollectionPathFromRoot}/`, ''), locale);
232
+ }
233
+
222
234
  /** Turn a flat array of routes into a tree structure. */
223
235
  function treeify(routes: Route[], locale: string | undefined, baseDir: string): Dir {
224
236
  const treeRoot: Dir = makeDir(baseDir);
225
- const collectionPathFromRoot = getCollectionPathFromRoot('docs', project);
226
237
  routes
227
238
  // Remove any entries that should be hidden
228
239
  .filter((doc) => !doc.entry.data.sidebar.hidden)
229
240
  // Compute the path of each entry from the root of the collection ahead of time.
230
- .map(
231
- (doc) =>
232
- [
233
- project.legacyCollections
234
- ? doc.id
235
- : // For collections with a loader, use a localized filePath relative to the collection
236
- localizedId(doc.entry.filePath.replace(`${collectionPathFromRoot}/`, ''), locale),
237
- doc,
238
- ] as const
239
- )
241
+ .map((doc) => [getRoutePathRelativeToCollectionRoot(doc, locale), doc] as const)
240
242
  // Sort by depth, to build the tree depth first.
241
243
  .sort(([a], [b]) => b.split('/').length - a.split('/').length)
242
244
  // Build the tree