@astrojs/starlight 0.25.4 → 0.25.5
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/Icons.ts +3 -0
- package/package.json +1 -1
- package/schemas/social.ts +2 -0
- package/user-components/FileTree.astro +2 -1
- package/utils/localizedUrl.ts +2 -1
- package/utils/navigation.ts +7 -4
- package/utils/slugs.ts +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.25.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2171](https://github.com/withastro/starlight/pull/2171) [`c8258d7`](https://github.com/withastro/starlight/commit/c8258d7ef9264a0f85710d463a83d16013dc1934) Thanks [@delucis](https://github.com/delucis)! - Improves build performance slightly for bigger sites
|
|
8
|
+
|
|
9
|
+
- [#2199](https://github.com/withastro/starlight/pull/2199) [`91557fd`](https://github.com/withastro/starlight/commit/91557fd73a43ab596f0fefb7c9aa0218b9a0b208) Thanks [@connorjs](https://github.com/connorjs)! - Adds Azure DevOps (`azureDevOps`) icon for use in social links.
|
|
10
|
+
|
|
3
11
|
## 0.25.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/components/Icons.ts
CHANGED
|
@@ -92,6 +92,9 @@ export const BuiltInIcons = {
|
|
|
92
92
|
'<path d="M20.47 2H3.53a1.45 1.45 0 0 0-1.47 1.43v17.14A1.45 1.45 0 0 0 3.53 22h16.94a1.45 1.45 0 0 0 1.47-1.43V3.43A1.45 1.45 0 0 0 20.47 2ZM8.09 18.74h-3v-9h3v9ZM6.59 8.48a1.56 1.56 0 0 1 0-3.12 1.57 1.57 0 1 1 0 3.12Zm12.32 10.26h-3v-4.83c0-1.21-.43-2-1.52-2A1.65 1.65 0 0 0 12.85 13a2 2 0 0 0-.1.73v5h-3v-9h3V11a3 3 0 0 1 2.71-1.5c2 0 3.45 1.29 3.45 4.06v5.18Z"/>',
|
|
93
93
|
twitch:
|
|
94
94
|
'<path d="M2.5 1 1 4.8v15.4h5.5V23h3.1l3-2.8H17l6-5.7V1H2.6ZM21 13.5l-3.4 3.3H12l-3 2.8v-2.8H4.5V3H21v10.5Zm-3.4-6.8v5.8h-2V6.7h2Zm-5.5 0v5.8h-2V6.7h2Z"/>',
|
|
95
|
+
azureDevOps:
|
|
96
|
+
'<path d="M17,4v9.74l-4,3.28-6.2-2.26V17L3.29,12.41l10.23.8V4.44Zm-3.41.49L7.85,1V3.29L2.58,4.84,1,6.87v4.61l2.26,1V6.57Z"/>',
|
|
97
|
+
|
|
95
98
|
microsoftTeams:
|
|
96
99
|
'<path d="M13.78 7.2a3.63 3.63 0 1 0-4.3-3.68h1.78a2.52 2.52 0 0 1 2.52 2.53V7.2zM7.34 18.8h3.92a2.52 2.52 0 0 0 2.52-2.52V8.37h4.17c.58.01 1.04.5 1.03 1.07v6.45a6.3 6.3 0 0 1-6.14 6.43 6.3 6.3 0 0 1-5.5-3.52zm16.1-14.06a2.51 2.51 0 1 1-5.02 0 2.51 2.51 0 0 1 5.02 0zm-3.36 14.24h-.17c.4-1 .59-2.05.57-3.11V9.46c0-.38-.07-.75-.23-1.09h2.69c.58 0 1.06.48 1.06 1.06v5.65a3.9 3.9 0 0 1-3.9 3.9h-.02z"/><path d="M1.02 5.02h10.24c.56 0 1.02.46 1.02 1.03v10.23a1.02 1.02 0 0 1-1.02 1.02H1.02A1.02 1.02 0 0 1 0 16.28V6.04c0-.56.46-1.02 1.02-1.02zm7.81 3.9V7.84H3.45v1.08h2.03v5.57h1.3V8.92h2.05z"/>',
|
|
97
100
|
instagram:
|
package/package.json
CHANGED
package/schemas/social.ts
CHANGED
|
@@ -14,6 +14,7 @@ export const socialLinks = [
|
|
|
14
14
|
'threads',
|
|
15
15
|
'linkedin',
|
|
16
16
|
'twitch',
|
|
17
|
+
'azureDevOps',
|
|
17
18
|
'microsoftTeams',
|
|
18
19
|
'instagram',
|
|
19
20
|
'stackOverflow',
|
|
@@ -62,6 +63,7 @@ export const SocialLinksSchema = () =>
|
|
|
62
63
|
threads: 'Threads',
|
|
63
64
|
linkedin: 'LinkedIn',
|
|
64
65
|
twitch: 'Twitch',
|
|
66
|
+
azureDevOps: 'Azure DevOps',
|
|
65
67
|
microsoftTeams: 'Microsoft Teams',
|
|
66
68
|
instagram: 'Instagram',
|
|
67
69
|
stackOverflow: 'Stack Overflow',
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { stripLeadingAndTrailingSlashes } from '../utils/path';
|
|
2
3
|
import { slugToLocaleData } from '../utils/slugs';
|
|
3
4
|
import { useTranslations } from '../utils/translations';
|
|
4
5
|
import { processFileTree } from './rehype-file-tree';
|
|
5
6
|
|
|
6
|
-
const slug = Astro.url.pathname
|
|
7
|
+
const slug = stripLeadingAndTrailingSlashes(Astro.url.pathname);
|
|
7
8
|
const t = useTranslations(slugToLocaleData(slug).locale);
|
|
8
9
|
|
|
9
10
|
const fileTreeHtml = await Astro.slots.render('default');
|
package/utils/localizedUrl.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import config from 'virtual:starlight/user-config';
|
|
2
|
+
import { stripTrailingSlash } from './path';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Get the equivalent of the passed URL for the passed locale.
|
|
@@ -12,7 +13,7 @@ export function localizedUrl(url: URL, locale: string | undefined): URL {
|
|
|
12
13
|
}
|
|
13
14
|
if (locale === 'root') locale = '';
|
|
14
15
|
/** Base URL with trailing `/` stripped. */
|
|
15
|
-
const base = import.meta.env.BASE_URL
|
|
16
|
+
const base = stripTrailingSlash(import.meta.env.BASE_URL);
|
|
16
17
|
const hasBase = url.pathname.startsWith(base);
|
|
17
18
|
// Temporarily remove base to simplify
|
|
18
19
|
if (hasBase) url.pathname = url.pathname.replace(base, '');
|
package/utils/navigation.ts
CHANGED
|
@@ -139,10 +139,10 @@ function linkFromInternalSidebarLinkItem(
|
|
|
139
139
|
locale: string | undefined,
|
|
140
140
|
currentPathname: string
|
|
141
141
|
) {
|
|
142
|
-
let slugWithLocale = locale ? locale + '/' + item.slug : item.slug;
|
|
143
142
|
// Astro passes root `index.[md|mdx]` entries with a slug of `index`
|
|
144
|
-
|
|
145
|
-
const
|
|
143
|
+
const slug = item.slug === 'index' ? '' : item.slug;
|
|
144
|
+
const localizedSlug = locale ? (slug ? locale + '/' + slug : locale) : slug;
|
|
145
|
+
const entry = routes.find((entry) => localizedSlug === entry.slug);
|
|
146
146
|
if (!entry) {
|
|
147
147
|
const hasExternalSlashes = item.slug.at(0) === '/' || item.slug.at(-1) === '/';
|
|
148
148
|
if (hasExternalSlashes) {
|
|
@@ -410,4 +410,7 @@ function applyPrevNextLinkConfig(
|
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
/** Remove the extension from a path. */
|
|
413
|
-
|
|
413
|
+
function stripExtension(path: string) {
|
|
414
|
+
const periodIndex = path.lastIndexOf('.');
|
|
415
|
+
return path.slice(0, periodIndex > -1 ? periodIndex : undefined);
|
|
416
|
+
}
|
package/utils/slugs.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import config from 'virtual:starlight/user-config';
|
|
2
2
|
import { BuiltInDefaultLocale } from './i18n';
|
|
3
|
+
import { stripTrailingSlash } from './path';
|
|
3
4
|
|
|
4
5
|
export interface LocaleData {
|
|
5
6
|
/** Writing direction. */
|
|
@@ -52,7 +53,7 @@ export function slugToParam(slug: string): string | undefined {
|
|
|
52
53
|
return slug === 'index' || slug === ''
|
|
53
54
|
? undefined
|
|
54
55
|
: slug.endsWith('/index')
|
|
55
|
-
? slug.
|
|
56
|
+
? slug.slice(0, -6)
|
|
56
57
|
: slug;
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -77,7 +78,7 @@ export function localizedSlug(slug: string, locale: string | undefined): string
|
|
|
77
78
|
locale = locale || '';
|
|
78
79
|
if (slugLocale === slug) return locale;
|
|
79
80
|
if (slugLocale) {
|
|
80
|
-
return slug.replace(slugLocale + '/', locale ? locale + '/' : '')
|
|
81
|
+
return stripTrailingSlash(slug.replace(slugLocale + '/', locale ? locale + '/' : ''));
|
|
81
82
|
}
|
|
82
83
|
return slug ? locale + '/' + slug : locale;
|
|
83
84
|
}
|
|
@@ -106,7 +107,7 @@ export function localizedId(id: string, locale: string | undefined): string {
|
|
|
106
107
|
/** Extract the slug from a URL. */
|
|
107
108
|
export function urlToSlug(url: URL): string {
|
|
108
109
|
let pathname = url.pathname;
|
|
109
|
-
const base = import.meta.env.BASE_URL
|
|
110
|
+
const base = stripTrailingSlash(import.meta.env.BASE_URL);
|
|
110
111
|
if (pathname.startsWith(base)) pathname = pathname.replace(base, '');
|
|
111
112
|
const segments = pathname.split('/');
|
|
112
113
|
const htmlExt = '.html';
|