@astrojs/starlight 0.30.1 → 0.30.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 +8 -0
- package/components/Header.astro +4 -1
- package/package.json +1 -1
- package/utils/navigation.ts +18 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.30.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
9
|
+
- [#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
|
|
10
|
+
|
|
3
11
|
## 0.30.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/components/Header.astro
CHANGED
|
@@ -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:
|
|
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,
|
package/package.json
CHANGED
package/utils/navigation.ts
CHANGED
|
@@ -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(
|
|
112
|
+
stripExtension(filePathFromContentDir) === localeDir ||
|
|
110
113
|
// Match against `foo/anything/else.md`.
|
|
111
|
-
|
|
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
|