@astrojs/starlight 0.34.1 → 0.34.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 +22 -0
- package/components/SiteTitle.astro +4 -0
- package/integrations/heading-links.ts +25 -4
- package/package.json +1 -1
- package/routes/common.astro +14 -2
- package/translations/hu.json +43 -0
- package/translations/index.ts +2 -0
- package/translations/ko.json +14 -14
- package/user-components/FileTree.astro +1 -0
- package/utils/git.ts +7 -0
- package/utils/routing/data.ts +12 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.34.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3058](https://github.com/withastro/starlight/pull/3058) [`274cc06`](https://github.com/withastro/starlight/commit/274cc06112824384771b944f504ab0faab45e2b9) Thanks [@techfg](https://github.com/techfg)! - Fixes display of focus indicator around site title
|
|
8
|
+
|
|
9
|
+
- [#3181](https://github.com/withastro/starlight/pull/3181) [`449c822`](https://github.com/withastro/starlight/commit/449c8229effaab19ece3c0a34e32595809c33cc8) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue where all headings in Markdown and MDX content were rendered with a [clickable anchor link](https://starlight.astro.build/reference/configuration/#headinglinks), even in non-Starlight pages.
|
|
10
|
+
|
|
11
|
+
- [#3168](https://github.com/withastro/starlight/pull/3168) [`ca693fe`](https://github.com/withastro/starlight/commit/ca693feb4b6aa9f26b3d536d284288773b788ac6) Thanks [@jsparkdev](https://github.com/jsparkdev)! - Updates Korean langage support with improvements and missing translations
|
|
12
|
+
|
|
13
|
+
## 0.34.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#3153](https://github.com/withastro/starlight/pull/3153) [`ea31f46`](https://github.com/withastro/starlight/commit/ea31f46be4d43339417dac7fc135d2be97080c58) Thanks [@SuperKXT](https://github.com/SuperKXT)! - Fixes hover styles for highlighted directory in FileTree component.
|
|
18
|
+
|
|
19
|
+
- [#2905](https://github.com/withastro/starlight/pull/2905) [`b5232bc`](https://github.com/withastro/starlight/commit/b5232bcd201c2e3904bde2d7717fe6cfa06d6c82) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes a potential issue for projects with dynamic routes added by an user, an Astro integration, or a Starlight plugin where some styles could end up being missing.
|
|
20
|
+
|
|
21
|
+
- [#3165](https://github.com/withastro/starlight/pull/3165) [`80a7871`](https://github.com/withastro/starlight/commit/80a7871ccad17aef8567a416a419669de6d5d3fd) Thanks [@KianNH](https://github.com/KianNH)! - Increases `maxBuffer` for an internal `spawnSync()` call to support larger Git commit histories when using Starlight's [`lastUpdated`](https://starlight.astro.build/reference/configuration/#lastupdated) feature.
|
|
22
|
+
|
|
23
|
+
- [#3158](https://github.com/withastro/starlight/pull/3158) [`d1f3c8b`](https://github.com/withastro/starlight/commit/d1f3c8b6583b93968af3c568f7af44b1b10326ec) Thanks [@heisenberg0924](https://github.com/heisenberg0924)! - Adds Hungarian language support
|
|
24
|
+
|
|
3
25
|
## 0.34.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -43,6 +43,10 @@ const { siteTitle, siteTitleHref } = Astro.locals.starlightRoute;
|
|
|
43
43
|
color: var(--sl-color-text-accent);
|
|
44
44
|
text-decoration: none;
|
|
45
45
|
white-space: nowrap;
|
|
46
|
+
min-width: 0;
|
|
47
|
+
}
|
|
48
|
+
span {
|
|
49
|
+
overflow: hidden;
|
|
46
50
|
}
|
|
47
51
|
img {
|
|
48
52
|
height: calc(var(--sl-nav-height) - 2 * var(--sl-nav-pad-y));
|
|
@@ -6,6 +6,7 @@ import { h } from 'hastscript';
|
|
|
6
6
|
import type { Transformer } from 'unified';
|
|
7
7
|
import { SKIP, visit } from 'unist-util-visit';
|
|
8
8
|
import type { HookParameters, StarlightConfig } from '../types';
|
|
9
|
+
import { resolveCollectionPath } from '../utils/collection';
|
|
9
10
|
|
|
10
11
|
const AnchorLinkIcon = h(
|
|
11
12
|
'span',
|
|
@@ -24,10 +25,14 @@ const AnchorLinkIcon = h(
|
|
|
24
25
|
* Add anchor links to headings.
|
|
25
26
|
*/
|
|
26
27
|
export default function rehypeAutolinkHeadings(
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
docsCollectionPath: string,
|
|
29
|
+
useTranslationsForLang: AutolinkHeadingsOptions['useTranslations'],
|
|
30
|
+
absolutePathToLang: AutolinkHeadingsOptions['absolutePathToLang']
|
|
29
31
|
) {
|
|
30
32
|
const transformer: Transformer<Root> = (tree, file) => {
|
|
33
|
+
// If the document is not part of the Starlight docs collection, skip it.
|
|
34
|
+
if (!normalizePath(file.path).startsWith(docsCollectionPath)) return;
|
|
35
|
+
|
|
31
36
|
const pageLang = absolutePathToLang(file.path);
|
|
32
37
|
const t = useTranslationsForLang(pageLang);
|
|
33
38
|
|
|
@@ -67,7 +72,9 @@ export default function rehypeAutolinkHeadings(
|
|
|
67
72
|
|
|
68
73
|
interface AutolinkHeadingsOptions {
|
|
69
74
|
starlightConfig: Pick<StarlightConfig, 'markdown'>;
|
|
70
|
-
astroConfig:
|
|
75
|
+
astroConfig: Pick<AstroConfig, 'srcDir'> & {
|
|
76
|
+
experimental: Pick<AstroConfig['experimental'], 'headingIdCompat'>;
|
|
77
|
+
};
|
|
71
78
|
useTranslations: HookParameters<'config:setup'>['useTranslations'];
|
|
72
79
|
absolutePathToLang: HookParameters<'config:setup'>['absolutePathToLang'];
|
|
73
80
|
}
|
|
@@ -85,10 +92,24 @@ export const starlightAutolinkHeadings = ({
|
|
|
85
92
|
rehypeHeadingIds,
|
|
86
93
|
{ experimentalHeadingIdCompat: astroConfig.experimental?.headingIdCompat },
|
|
87
94
|
],
|
|
88
|
-
rehypeAutolinkHeadings(
|
|
95
|
+
rehypeAutolinkHeadings(
|
|
96
|
+
normalizePath(resolveCollectionPath('docs', astroConfig.srcDir)),
|
|
97
|
+
useTranslations,
|
|
98
|
+
absolutePathToLang
|
|
99
|
+
),
|
|
89
100
|
]
|
|
90
101
|
: [];
|
|
91
102
|
|
|
103
|
+
/**
|
|
104
|
+
* File path separators seems to be inconsistent on Windows when the rehype plugin is used on
|
|
105
|
+
* Markdown vs MDX files.
|
|
106
|
+
* For the time being, we normalize the path to unix style path.
|
|
107
|
+
*/
|
|
108
|
+
const backSlashRegex = /\\/g;
|
|
109
|
+
function normalizePath(path: string) {
|
|
110
|
+
return path.replace(backSlashRegex, '/');
|
|
111
|
+
}
|
|
112
|
+
|
|
92
113
|
// This utility is inlined from https://github.com/syntax-tree/hast-util-heading-rank
|
|
93
114
|
// Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
|
|
94
115
|
// MIT License: https://github.com/syntax-tree/hast-util-heading-rank/blob/main/license
|
package/package.json
CHANGED
package/routes/common.astro
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { render } from 'astro:content';
|
|
2
3
|
import Page from '../components/Page.astro';
|
|
3
|
-
import { useRouteData } from '../utils/routing/data';
|
|
4
|
+
import { getRoute, useRouteData } from '../utils/routing/data';
|
|
4
5
|
import { attachRouteDataAndRunMiddleware } from '../utils/routing/middleware';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
const route = await getRoute(Astro);
|
|
8
|
+
/**
|
|
9
|
+
* The call to `render` from `astro:content` is purposely made in this file to work around a
|
|
10
|
+
* development mode head propagation issue which is heavily tied to `astro:content` imports. Even
|
|
11
|
+
* though we have a test for this, refactoring and moving this code to a different file should be
|
|
12
|
+
* avoided for now until the linked issue which also contains more details is resolved.
|
|
13
|
+
*
|
|
14
|
+
* @see https://github.com/withastro/astro/issues/13724
|
|
15
|
+
*/
|
|
16
|
+
const renderResult = await render(route.entry);
|
|
17
|
+
|
|
18
|
+
await attachRouteDataAndRunMiddleware(Astro, await useRouteData(Astro, route, renderResult));
|
|
7
19
|
|
|
8
20
|
const { Content, entry } = Astro.locals.starlightRoute;
|
|
9
21
|
---
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skipLink.label": "Tovább a tartalomhoz",
|
|
3
|
+
"search.label": "Keresés",
|
|
4
|
+
"search.ctrlKey": "Ctrl",
|
|
5
|
+
"search.cancelLabel": "Mégsem",
|
|
6
|
+
"search.devWarning": "A keresés csak a production build-ekben működik. \nPróbáld meg először buildelni, hogy kipróbálhasd.",
|
|
7
|
+
"themeSelect.accessibleLabel": "Téma választás",
|
|
8
|
+
"themeSelect.dark": "Sötét",
|
|
9
|
+
"themeSelect.light": "Világos",
|
|
10
|
+
"themeSelect.auto": "Auto",
|
|
11
|
+
"languageSelect.accessibleLabel": "Nyelv választása",
|
|
12
|
+
"menuButton.accessibleLabel": "Menü",
|
|
13
|
+
"sidebarNav.accessibleLabel": "Fő",
|
|
14
|
+
"tableOfContents.onThisPage": "Ezen az oldalon",
|
|
15
|
+
"tableOfContents.overview": "Tartalom",
|
|
16
|
+
"i18n.untranslatedContent": "Ez a tartalom még nem érhető el a jelenlegi nyelven.",
|
|
17
|
+
"page.editLink": "Oldal szerkesztése",
|
|
18
|
+
"page.lastUpdated": "Utoljára frissítve:",
|
|
19
|
+
"page.previousLink": "Előző",
|
|
20
|
+
"page.nextLink": "Következő",
|
|
21
|
+
"page.draft": "Ez a tartalom még vázlat, így nem lesz benne a production build-ben.",
|
|
22
|
+
"404.text": "Az oldal nem található. Nézd meg az URL-t vagy használd a keresőt.",
|
|
23
|
+
"aside.note": "Megjegyzés",
|
|
24
|
+
"aside.tip": "Tipp",
|
|
25
|
+
"aside.caution": "Figyelem",
|
|
26
|
+
"aside.danger": "Veszély",
|
|
27
|
+
"fileTree.directory": "Könyvtár",
|
|
28
|
+
"builtWithStarlight.label": "Starlight-tal készítve",
|
|
29
|
+
"heading.anchorLabel": "Szekció neve “{{title}}”",
|
|
30
|
+
"expressiveCode.copyButtonCopied": "Másolva!",
|
|
31
|
+
"expressiveCode.copyButtonTooltip": "Másolás",
|
|
32
|
+
"expressiveCode.terminalWindowFallbackTitle": "Terminál",
|
|
33
|
+
"pagefind.clear_search": "Törlés",
|
|
34
|
+
"pagefind.load_more": "Több találat betöltése",
|
|
35
|
+
"pagefind.search_label": "Keresés ezen az oldalon",
|
|
36
|
+
"pagefind.filters_label": "Szűrők",
|
|
37
|
+
"pagefind.zero_results": "Erre a kifejezésre nincs találat: [SEARCH_TERM]",
|
|
38
|
+
"pagefind.many_results": "[COUNT] találat erre: [SEARCH_TERM]",
|
|
39
|
+
"pagefind.one_result": "[COUNT] találat erre: [SEARCH_TERM]",
|
|
40
|
+
"pagefind.alt_search": "Erre a kifejezésre nincs találat: [SEARCH_TERM]. Találatok mutatása erre: [DIFFERENT_TERM]",
|
|
41
|
+
"pagefind.search_suggestion": "Erre a kifejezésre nincs találat: [SEARCH_TERM]. Próbáld meg ezek közül az egyiket:",
|
|
42
|
+
"pagefind.searching": "Keresés erre: [SEARCH_TERM]..."
|
|
43
|
+
}
|
package/translations/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import zhTW from './zh-TW.json';
|
|
|
29
29
|
import pl from './pl.json';
|
|
30
30
|
import sk from './sk.json';
|
|
31
31
|
import lv from './lv.json';
|
|
32
|
+
import hu from './hu.json';
|
|
32
33
|
|
|
33
34
|
const { parse } = builtinI18nSchema();
|
|
34
35
|
|
|
@@ -64,5 +65,6 @@ export default Object.fromEntries(
|
|
|
64
65
|
pl,
|
|
65
66
|
sk,
|
|
66
67
|
lv,
|
|
68
|
+
hu,
|
|
67
69
|
}).map(([key, dict]) => [key, parse(dict)])
|
|
68
70
|
);
|
package/translations/ko.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"skipLink.label": "
|
|
2
|
+
"skipLink.label": "콘텐츠로 이동",
|
|
3
3
|
"search.label": "검색",
|
|
4
4
|
"search.ctrlKey": "Ctrl",
|
|
5
5
|
"search.cancelLabel": "취소",
|
|
6
|
-
"search.devWarning": "검색 기능은 프로덕션
|
|
6
|
+
"search.devWarning": "검색 기능은 프로덕션 빌드에서만 작동합니다. \n로컬에서 테스트하려면 사이트를 빌드하고 미리 보기를 실행하세요.",
|
|
7
7
|
"themeSelect.accessibleLabel": "테마 선택",
|
|
8
|
-
"themeSelect.dark": "
|
|
9
|
-
"themeSelect.light": "
|
|
8
|
+
"themeSelect.dark": "어두운 테마",
|
|
9
|
+
"themeSelect.light": "밝은 테마",
|
|
10
10
|
"themeSelect.auto": "자동",
|
|
11
11
|
"languageSelect.accessibleLabel": "언어 선택",
|
|
12
12
|
"menuButton.accessibleLabel": "메뉴",
|
|
13
13
|
"sidebarNav.accessibleLabel": "메인",
|
|
14
|
-
"tableOfContents.onThisPage": "
|
|
14
|
+
"tableOfContents.onThisPage": "목차",
|
|
15
15
|
"tableOfContents.overview": "개요",
|
|
16
|
-
"i18n.untranslatedContent": "이 콘텐츠는 아직
|
|
17
|
-
"page.editLink": "페이지
|
|
16
|
+
"i18n.untranslatedContent": "이 콘텐츠는 아직 번역되지 않았습니다.",
|
|
17
|
+
"page.editLink": "페이지 편집",
|
|
18
18
|
"page.lastUpdated": "마지막 업데이트:",
|
|
19
|
-
"page.previousLink": "이전",
|
|
20
|
-
"page.nextLink": "다음",
|
|
21
|
-
"page.draft": "이 콘텐츠는
|
|
22
|
-
"404.text": "페이지를 찾을 수 없습니다. URL을
|
|
23
|
-
"aside.note": "
|
|
19
|
+
"page.previousLink": "이전 페이지",
|
|
20
|
+
"page.nextLink": "다음 페이지",
|
|
21
|
+
"page.draft": "이 콘텐츠는 아직 초안 상태이며, 최종 빌드에는 포함되지 않습니다.",
|
|
22
|
+
"404.text": "페이지를 찾을 수 없습니다. URL을 다시 확인해보거나 검색을 사용해보세요.",
|
|
23
|
+
"aside.note": "참고",
|
|
24
24
|
"aside.tip": "팁",
|
|
25
25
|
"aside.caution": "주의",
|
|
26
26
|
"aside.danger": "위험",
|
|
27
27
|
"fileTree.directory": "디렉터리",
|
|
28
|
-
"builtWithStarlight.label": "Starlight로
|
|
29
|
-
"heading.anchorLabel": "
|
|
28
|
+
"builtWithStarlight.label": "이 웹사이트는 Starlight로 제작되었습니다.",
|
|
29
|
+
"heading.anchorLabel": "섹션 제목: “{{title}}”"
|
|
30
30
|
}
|
package/utils/git.ts
CHANGED
|
@@ -72,6 +72,13 @@ export function getAllNewestCommitDate(rootPath: string, docsPath: string): [str
|
|
|
72
72
|
{
|
|
73
73
|
cwd: repoRoot,
|
|
74
74
|
encoding: 'utf-8',
|
|
75
|
+
// The default `maxBuffer` for `spawnSync` is 1024 * 1024 bytes, a.k.a 1 MB. In big projects,
|
|
76
|
+
// the full git history can be larger than this, so we increase this to ~10 MB. For example,
|
|
77
|
+
// Cloudflare passed 1 MB with ~4,800 pages and ~17,000 commits. If we get reports of others
|
|
78
|
+
// hitting ENOBUFS errors here in the future, we may want to switch to streaming the git log
|
|
79
|
+
// with `spawn` instead.
|
|
80
|
+
// See https://github.com/withastro/starlight/issues/3154
|
|
81
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
75
82
|
}
|
|
76
83
|
);
|
|
77
84
|
|
package/utils/routing/data.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
import { formatPath } from '../format-path';
|
|
16
16
|
import { useTranslations } from '../translations';
|
|
17
17
|
import { BuiltInDefaultLocale } from '../i18n';
|
|
18
|
-
import { getEntry,
|
|
18
|
+
import { getEntry, type RenderResult } from 'astro:content';
|
|
19
19
|
import { getCollectionPathFromRoot } from '../collection';
|
|
20
20
|
import { getHead } from '../head';
|
|
21
21
|
|
|
@@ -25,11 +25,18 @@ export interface PageProps extends Route {
|
|
|
25
25
|
|
|
26
26
|
export type RouteDataContext = Pick<APIContext, 'generator' | 'site' | 'url'>;
|
|
27
27
|
|
|
28
|
-
export async function
|
|
29
|
-
|
|
28
|
+
export async function getRoute(context: APIContext): Promise<Route> {
|
|
29
|
+
return (
|
|
30
30
|
('slug' in context.params && getRouteBySlugParam(context.params.slug)) ||
|
|
31
|
-
(await get404Route(context.locals))
|
|
32
|
-
|
|
31
|
+
(await get404Route(context.locals))
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function useRouteData(
|
|
36
|
+
context: APIContext,
|
|
37
|
+
route: Route,
|
|
38
|
+
{ Content, headings }: RenderResult
|
|
39
|
+
): Promise<StarlightRouteData> {
|
|
33
40
|
const routeData = generateRouteData({ props: { ...route, headings }, context });
|
|
34
41
|
return { ...routeData, Content };
|
|
35
42
|
}
|