@astrojs/starlight 0.41.10 → 0.42.0
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/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/MobileMenuToggle.astro +65 -0
- package/{components → dist/components}/PageFrame.astro +32 -8
- package/dist/components-internals/Icons.d.ts +415 -0
- package/dist/components-internals/Icons.js +140 -0
- package/dist/components-internals/SidebarPersistState.d.ts +1 -0
- package/dist/components-internals/SidebarPersistState.js +53 -0
- package/dist/components-internals/TableOfContents/starlight-toc.d.ts +18 -0
- package/dist/components-internals/TableOfContents/starlight-toc.js +88 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +4 -0
- package/{expressive-code.d.ts → dist/expressive-code.d.ts} +6 -13
- package/dist/expressive-code.js +31 -0
- package/dist/global.d.ts +62 -0
- package/dist/global.js +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +109 -0
- package/dist/integrations/aside-utils.d.ts +9 -0
- package/dist/integrations/aside-utils.js +35 -0
- package/dist/integrations/expressive-code/hast.d.ts +1 -0
- package/dist/integrations/expressive-code/hast.js +2 -0
- package/dist/integrations/expressive-code/index.d.ts +60 -0
- package/dist/integrations/expressive-code/index.js +48 -0
- package/dist/integrations/expressive-code/preprocessor.d.ts +17 -0
- package/dist/integrations/expressive-code/preprocessor.js +76 -0
- package/dist/integrations/expressive-code/themes/night-owl-dark.js +4 -0
- package/dist/integrations/expressive-code/themes/night-owl-light.js +4 -0
- package/dist/integrations/expressive-code/theming.d.ts +16 -0
- package/dist/integrations/expressive-code/theming.js +71 -0
- package/dist/integrations/expressive-code/translations.d.ts +8 -0
- package/dist/integrations/expressive-code/translations.js +26 -0
- package/dist/integrations/markdown-icon.d.ts +8 -0
- package/dist/integrations/markdown-icon.js +14 -0
- package/dist/integrations/markdown-plugins.d.ts +18 -0
- package/dist/integrations/markdown-plugins.js +36 -0
- package/dist/integrations/markdown-processor.d.ts +29 -0
- package/dist/integrations/markdown-processor.js +44 -0
- package/dist/integrations/pagefind.d.ts +7 -0
- package/dist/integrations/pagefind.js +34 -0
- package/dist/integrations/rehype-code-rtl-support.d.ts +21 -0
- package/dist/integrations/rehype-code-rtl-support.js +36 -0
- package/dist/integrations/rehype-heading-links.d.ts +10 -0
- package/dist/integrations/rehype-heading-links.js +57 -0
- package/dist/integrations/remark-asides.d.ts +32 -0
- package/dist/integrations/remark-asides.js +166 -0
- package/dist/integrations/remark-rehype.d.ts +17 -0
- package/dist/integrations/remark-rehype.js +51 -0
- package/dist/integrations/satteri.d.ts +13 -0
- package/dist/integrations/satteri.js +209 -0
- package/dist/integrations/shared/absolutePathToLang.d.ts +10 -0
- package/dist/integrations/shared/absolutePathToLang.js +13 -0
- package/dist/integrations/shared/localeToLang.d.ts +10 -0
- package/dist/integrations/shared/localeToLang.js +13 -0
- package/dist/integrations/shared/slugToLocale.d.ts +12 -0
- package/dist/integrations/shared/slugToLocale.js +15 -0
- package/dist/integrations/sitemap.d.ts +12 -0
- package/dist/integrations/sitemap.js +19 -0
- package/dist/integrations/vite-layer-order.d.ts +15 -0
- package/dist/integrations/vite-layer-order.js +56 -0
- package/dist/integrations/vite-lazy-barrel-optimization.d.ts +12 -0
- package/dist/integrations/vite-lazy-barrel-optimization.js +33 -0
- package/dist/integrations/vite-virtual-modules.d.ts +14 -0
- package/dist/integrations/vite-virtual-modules.js +108 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +3 -0
- package/dist/loaders.d.ts +20 -0
- package/dist/loaders.js +49 -0
- package/dist/locals.d.ts +15 -0
- package/dist/locals.js +33 -0
- package/dist/package.js +4 -0
- package/{props.ts → dist/props.d.ts} +6 -4
- package/dist/props.js +1 -0
- package/dist/route-data.d.ts +7 -0
- package/dist/route-data.js +6 -0
- package/dist/schema.d.ts +426 -0
- package/dist/schema.js +103 -0
- package/dist/schemas/badge.d.ts +86 -0
- package/dist/schemas/badge.js +39 -0
- package/dist/schemas/components.d.ts +236 -0
- package/dist/schemas/components.js +36 -0
- package/dist/schemas/expressiveCode.d.ts +7 -0
- package/dist/schemas/expressiveCode.js +5 -0
- package/dist/schemas/favicon.d.ts +9 -0
- package/dist/schemas/favicon.js +32 -0
- package/dist/schemas/head.d.ts +33 -0
- package/dist/schemas/head.js +41 -0
- package/dist/schemas/hero.d.ts +319 -0
- package/dist/schemas/hero.js +73 -0
- package/dist/schemas/i18n.d.ts +125 -0
- package/dist/schemas/i18n.js +76 -0
- package/dist/schemas/icon.d.ts +284 -0
- package/dist/schemas/icon.js +7 -0
- package/dist/schemas/locale.d.ts +20 -0
- package/dist/schemas/locale.js +11 -0
- package/dist/schemas/logo.d.ts +32 -0
- package/dist/schemas/logo.js +14 -0
- package/dist/schemas/pagefind.d.ts +166 -0
- package/dist/schemas/pagefind.js +31 -0
- package/dist/schemas/prevNextLink.d.ts +10 -0
- package/dist/schemas/prevNextLink.js +14 -0
- package/dist/schemas/sidebar.d.ts +205 -0
- package/dist/schemas/sidebar.js +71 -0
- package/dist/schemas/site-title.d.ts +7 -0
- package/dist/schemas/site-title.js +17 -0
- package/dist/schemas/social.d.ts +292 -0
- package/dist/schemas/social.js +18 -0
- package/dist/schemas/tableOfContents.d.ts +24 -0
- package/dist/schemas/tableOfContents.js +16 -0
- package/{style → dist/style}/anchor-links.css +13 -1
- package/dist/translations/ar.js +36 -0
- package/dist/translations/ca.js +46 -0
- package/dist/translations/cs.js +46 -0
- package/dist/translations/da.js +33 -0
- package/dist/translations/de.js +33 -0
- package/dist/translations/el.js +33 -0
- package/dist/translations/en.js +33 -0
- package/dist/translations/es.js +46 -0
- package/dist/translations/fa.js +33 -0
- package/dist/translations/fi.js +33 -0
- package/dist/translations/fr.js +36 -0
- package/dist/translations/gl.js +46 -0
- package/dist/translations/he.js +33 -0
- package/dist/translations/hi.js +36 -0
- package/dist/translations/hu.js +46 -0
- package/dist/translations/id.js +33 -0
- package/dist/translations/index.d.ts +48 -0
- package/dist/translations/index.js +75 -0
- package/dist/translations/it.js +36 -0
- package/dist/translations/ja.js +36 -0
- package/dist/translations/ko.js +36 -0
- package/dist/translations/lv.js +33 -0
- package/dist/translations/nb.js +33 -0
- package/dist/translations/nl.js +33 -0
- package/dist/translations/pl.js +36 -0
- package/dist/translations/pt.js +36 -0
- package/dist/translations/ro.js +33 -0
- package/dist/translations/ru.js +36 -0
- package/dist/translations/sk.js +33 -0
- package/dist/translations/sv.js +33 -0
- package/dist/translations/th.js +33 -0
- package/dist/translations/tr.js +33 -0
- package/dist/translations/uk.js +33 -0
- package/dist/translations/vi.js +33 -0
- package/dist/translations/zh-CN.js +36 -0
- package/dist/translations/zh-TW.js +36 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -0
- package/{user-components → dist/user-components}/FileTree.astro +1 -1
- package/{user-components → dist/user-components}/Steps.astro +1 -1
- package/{user-components → dist/user-components}/TabItem.astro +1 -1
- package/{user-components → dist/user-components}/Tabs.astro +1 -1
- package/dist/user-components/file-tree-icons.d.ts +178 -0
- package/dist/user-components/file-tree-icons.js +632 -0
- package/dist/user-components/file-tree-processor.d.ts +16 -0
- package/dist/user-components/file-tree-processor.js +132 -0
- package/dist/user-components/steps-processor.d.ts +10 -0
- package/dist/user-components/steps-processor.js +39 -0
- package/dist/user-components/tabs-processor.d.ts +23 -0
- package/dist/user-components/tabs-processor.js +70 -0
- package/dist/utils/base.d.ts +7 -0
- package/dist/utils/base.js +15 -0
- package/dist/utils/canonical.d.ts +10 -0
- package/dist/utils/canonical.js +14 -0
- package/dist/utils/collection-fs.d.ts +13 -0
- package/dist/utils/collection-fs.js +19 -0
- package/{utils/collection.ts → dist/utils/collection.d.ts} +9 -20
- package/dist/utils/collection.js +26 -0
- package/dist/utils/createPathFormatter.d.ts +9 -0
- package/dist/utils/createPathFormatter.js +35 -0
- package/dist/utils/createTranslationSystem.d.ts +23 -0
- package/dist/utils/createTranslationSystem.js +84 -0
- package/dist/utils/error-map.d.ts +23 -0
- package/dist/utils/error-map.js +125 -0
- package/dist/utils/format-path.d.ts +4 -0
- package/dist/utils/format-path.js +9 -0
- package/dist/utils/generateToC.d.ts +14 -0
- package/dist/utils/generateToC.js +25 -0
- package/dist/utils/git.d.ts +12 -0
- package/dist/utils/git.js +71 -0
- package/dist/utils/gitInlined.d.ts +6 -0
- package/dist/utils/gitInlined.js +11 -0
- package/dist/utils/head.d.ts +7 -0
- package/dist/utils/head.js +233 -0
- package/dist/utils/i18n.d.ts +50 -0
- package/dist/utils/i18n.js +141 -0
- package/dist/utils/localizedUrl.d.ts +8 -0
- package/dist/utils/localizedUrl.js +28 -0
- package/dist/utils/navigation.d.ts +19 -0
- package/dist/utils/navigation.js +353 -0
- package/dist/utils/path.d.ts +21 -0
- package/dist/utils/path.js +51 -0
- package/dist/utils/plugins.d.ts +721 -0
- package/dist/utils/plugins.js +174 -0
- package/dist/utils/routing/data.d.ts +20 -0
- package/dist/utils/routing/data.js +127 -0
- package/dist/utils/routing/index.d.ts +21 -0
- package/dist/utils/routing/index.js +106 -0
- package/dist/utils/routing/middleware.d.ts +11 -0
- package/dist/utils/routing/middleware.js +65 -0
- package/dist/utils/routing/types.d.ts +93 -0
- package/dist/utils/routing/types.js +1 -0
- package/dist/utils/slugs.d.ts +45 -0
- package/dist/utils/slugs.js +104 -0
- package/dist/utils/starlight-page.d.ts +36 -0
- package/dist/utils/starlight-page.js +120 -0
- package/dist/utils/translations-fs.d.ts +15 -0
- package/dist/utils/translations-fs.js +39 -0
- package/dist/utils/translations.d.ts +20 -0
- package/dist/utils/translations.js +29 -0
- package/dist/utils/types.d.ts +5 -0
- package/dist/utils/types.js +1 -0
- package/dist/utils/url.d.ts +7 -0
- package/{utils/url.ts → dist/utils/url.js} +5 -4
- package/dist/utils/user-config.d.ts +2055 -0
- package/dist/utils/user-config.js +136 -0
- package/dist/utils/validateLogoImports.d.ts +5 -0
- package/dist/utils/validateLogoImports.js +16 -0
- package/dist/utils/zodDeepMerge.d.ts +16 -0
- package/dist/utils/zodDeepMerge.js +53 -0
- package/package.json +62 -33
- package/CHANGELOG.md +0 -3043
- package/components/MobileMenuToggle.astro +0 -114
- package/components-internals/Icons.ts +0 -248
- package/components-internals/SidebarPersistState.ts +0 -71
- package/components-internals/TableOfContents/starlight-toc.ts +0 -127
- package/constants.ts +0 -4
- package/expressive-code.mjs +0 -23
- package/global.d.ts +0 -11
- package/i18n.d.ts +0 -18
- package/index.ts +0 -200
- package/integrations/aside-utils.ts +0 -41
- package/integrations/expressive-code/hast.d.ts +0 -5
- package/integrations/expressive-code/hast.mjs +0 -9
- package/integrations/expressive-code/index.ts +0 -125
- package/integrations/expressive-code/preprocessor.ts +0 -126
- package/integrations/expressive-code/themes/night-owl-dark.jsonc +0 -1796
- package/integrations/expressive-code/themes/night-owl-light.jsonc +0 -1695
- package/integrations/expressive-code/theming.ts +0 -105
- package/integrations/expressive-code/translations.ts +0 -36
- package/integrations/markdown-icon.ts +0 -13
- package/integrations/markdown-plugins.ts +0 -71
- package/integrations/markdown-processor.ts +0 -64
- package/integrations/pagefind.ts +0 -60
- package/integrations/rehype-code-rtl-support.ts +0 -37
- package/integrations/rehype-heading-links.ts +0 -79
- package/integrations/remark-asides.ts +0 -219
- package/integrations/remark-rehype.ts +0 -87
- package/integrations/satteri.ts +0 -265
- package/integrations/shared/absolutePathToLang.ts +0 -26
- package/integrations/shared/localeToLang.ts +0 -15
- package/integrations/shared/slugToLocale.ts +0 -18
- package/integrations/sitemap.ts +0 -23
- package/integrations/vite-layer-order.ts +0 -69
- package/integrations/vite-lazy-barrel-optimization.ts +0 -40
- package/integrations/vite-virtual-modules.ts +0 -175
- package/internal.ts +0 -6
- package/loaders.ts +0 -63
- package/locals.d.ts +0 -43
- package/locals.ts +0 -43
- package/route-data.ts +0 -11
- package/schema.ts +0 -167
- package/schemas/badge.ts +0 -40
- package/schemas/components.ts +0 -265
- package/schemas/expressiveCode.ts +0 -12
- package/schemas/favicon.ts +0 -40
- package/schemas/head.ts +0 -50
- package/schemas/hero.ts +0 -69
- package/schemas/i18n.ts +0 -244
- package/schemas/icon.ts +0 -7
- package/schemas/logo.ts +0 -28
- package/schemas/pagefind.ts +0 -128
- package/schemas/prevNextLink.ts +0 -18
- package/schemas/sidebar.ts +0 -163
- package/schemas/site-title.ts +0 -20
- package/schemas/social.ts +0 -23
- package/schemas/tableOfContents.ts +0 -21
- package/translations/README.md +0 -14
- package/translations/ar.json +0 -33
- package/translations/ca.json +0 -43
- package/translations/cs.json +0 -43
- package/translations/da.json +0 -30
- package/translations/de.json +0 -30
- package/translations/el.json +0 -30
- package/translations/en.json +0 -30
- package/translations/es.json +0 -43
- package/translations/fa.json +0 -30
- package/translations/fi.json +0 -30
- package/translations/fr.json +0 -33
- package/translations/gl.json +0 -43
- package/translations/he.json +0 -30
- package/translations/hi.json +0 -33
- package/translations/hu.json +0 -43
- package/translations/id.json +0 -30
- package/translations/index.ts +0 -76
- package/translations/it.json +0 -33
- package/translations/ja.json +0 -33
- package/translations/ko.json +0 -33
- package/translations/lv.json +0 -30
- package/translations/nb.json +0 -30
- package/translations/nl.json +0 -30
- package/translations/pl.json +0 -33
- package/translations/pt.json +0 -33
- package/translations/ro.json +0 -30
- package/translations/ru.json +0 -33
- package/translations/sk.json +0 -30
- package/translations/sv.json +0 -30
- package/translations/th.json +0 -30
- package/translations/tr.json +0 -30
- package/translations/uk.json +0 -30
- package/translations/vi.json +0 -30
- package/translations/zh-CN.json +0 -33
- package/translations/zh-TW.json +0 -33
- package/types.ts +0 -7
- package/user-components/file-tree-icons.ts +0 -782
- package/user-components/rehype-file-tree.ts +0 -251
- package/user-components/rehype-steps.ts +0 -85
- package/user-components/rehype-tabs.ts +0 -121
- package/utils/base.ts +0 -15
- package/utils/canonical.ts +0 -19
- package/utils/collection-fs.ts +0 -20
- package/utils/createPathFormatter.ts +0 -60
- package/utils/createTranslationSystem.ts +0 -137
- package/utils/error-map.ts +0 -222
- package/utils/format-path.ts +0 -7
- package/utils/generateToC.ts +0 -33
- package/utils/git.ts +0 -121
- package/utils/gitInlined.ts +0 -20
- package/utils/head.ts +0 -235
- package/utils/i18n.ts +0 -221
- package/utils/localizedUrl.ts +0 -51
- package/utils/navigation.ts +0 -566
- package/utils/path.ts +0 -58
- package/utils/plugins.ts +0 -498
- package/utils/routing/data.ts +0 -154
- package/utils/routing/index.ts +0 -135
- package/utils/routing/middleware.ts +0 -81
- package/utils/routing/types.ts +0 -101
- package/utils/slugs.ts +0 -119
- package/utils/starlight-page.ts +0 -205
- package/utils/translations-fs.ts +0 -54
- package/utils/translations.ts +0 -57
- package/utils/types.ts +0 -15
- package/utils/user-config.ts +0 -348
- package/utils/validateLogoImports.ts +0 -21
- package/utils/zodDeepMerge.ts +0 -144
- package/virtual-internal.d.ts +0 -149
- package/virtual.d.ts +0 -27
- /package/{components → dist/components}/AnchorHeading.astro +0 -0
- /package/{components → dist/components}/Banner.astro +0 -0
- /package/{components → dist/components}/ContentNotice.astro +0 -0
- /package/{components → dist/components}/ContentPanel.astro +0 -0
- /package/{components → dist/components}/DraftContentNotice.astro +0 -0
- /package/{components → dist/components}/EditLink.astro +0 -0
- /package/{components → dist/components}/FallbackContentNotice.astro +0 -0
- /package/{components → dist/components}/Footer.astro +0 -0
- /package/{components → dist/components}/Head.astro +0 -0
- /package/{components → dist/components}/Header.astro +0 -0
- /package/{components → dist/components}/Hero.astro +0 -0
- /package/{components → dist/components}/LanguageSelect.astro +0 -0
- /package/{components → dist/components}/LastUpdated.astro +0 -0
- /package/{components → dist/components}/MarkdownContent.astro +0 -0
- /package/{components → dist/components}/MobileMenuFooter.astro +0 -0
- /package/{components → dist/components}/MobileTableOfContents.astro +0 -0
- /package/{components → dist/components}/Page.astro +0 -0
- /package/{components → dist/components}/PageSidebar.astro +0 -0
- /package/{components → dist/components}/PageTitle.astro +0 -0
- /package/{components → dist/components}/Pagination.astro +0 -0
- /package/{components → dist/components}/Search.astro +0 -0
- /package/{components → dist/components}/Select.astro +0 -0
- /package/{components → dist/components}/Sidebar.astro +0 -0
- /package/{components → dist/components}/SidebarPersister.astro +0 -0
- /package/{components → dist/components}/SidebarRestorePoint.astro +0 -0
- /package/{components → dist/components}/SidebarSublist.astro +0 -0
- /package/{components → dist/components}/SiteTitle.astro +0 -0
- /package/{components → dist/components}/SkipLink.astro +0 -0
- /package/{components → dist/components}/SocialIcons.astro +0 -0
- /package/{components → dist/components}/StarlightPage.astro +0 -0
- /package/{components → dist/components}/TableOfContents.astro +0 -0
- /package/{components → dist/components}/ThemeProvider.astro +0 -0
- /package/{components → dist/components}/ThemeSelect.astro +0 -0
- /package/{components → dist/components}/TwoColumnContent.astro +0 -0
- /package/{components-internals → dist/components-internals}/TableOfContents/TableOfContentsList.astro +0 -0
- /package/{components.ts → dist/components.ts} +0 -0
- /package/{routes → dist/routes}/common.astro +0 -0
- /package/{routes → dist/routes}/ssr/404.astro +0 -0
- /package/{routes → dist/routes}/ssr/index.astro +0 -0
- /package/{routes → dist/routes}/static/404.astro +0 -0
- /package/{routes → dist/routes}/static/index.astro +0 -0
- /package/{style → dist/style}/asides.css +0 -0
- /package/{style → dist/style}/layers.css +0 -0
- /package/{style → dist/style}/markdown.css +0 -0
- /package/{style → dist/style}/print.css +0 -0
- /package/{style → dist/style}/props.css +0 -0
- /package/{style → dist/style}/reset.css +0 -0
- /package/{style → dist/style}/util.css +0 -0
- /package/{user-components → dist/user-components}/Aside.astro +0 -0
- /package/{user-components → dist/user-components}/Badge.astro +0 -0
- /package/{user-components → dist/user-components}/Card.astro +0 -0
- /package/{user-components → dist/user-components}/CardGrid.astro +0 -0
- /package/{user-components → dist/user-components}/Icon.astro +0 -0
- /package/{user-components → dist/user-components}/LinkButton.astro +0 -0
- /package/{user-components → dist/user-components}/LinkCard.astro +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { BuiltInDefaultLocale } from "./i18n.js";
|
|
2
|
+
import { ComponentConfigSchema } from "../schemas/components.js";
|
|
3
|
+
import { ExpressiveCodeSchema } from "../schemas/expressiveCode.js";
|
|
4
|
+
import { FaviconSchema } from "../schemas/favicon.js";
|
|
5
|
+
import { HeadConfigSchema } from "../schemas/head.js";
|
|
6
|
+
import { LogoConfigSchema } from "../schemas/logo.js";
|
|
7
|
+
import { PagefindConfigDefaults, PagefindConfigSchema } from "../schemas/pagefind.js";
|
|
8
|
+
import { SidebarItemSchema } from "../schemas/sidebar.js";
|
|
9
|
+
import { TitleConfigSchema, TitleTransformConfigSchema } from "../schemas/site-title.js";
|
|
10
|
+
import { SocialLinksSchema } from "../schemas/social.js";
|
|
11
|
+
import { UserConfigTableOfContentsSchema } from "../schemas/tableOfContents.js";
|
|
12
|
+
import { LocaleConfigSchema } from "../schemas/locale.js";
|
|
13
|
+
import { z } from "astro/zod";
|
|
14
|
+
import { parse, stringify } from "bcp-47";
|
|
15
|
+
//#region src/utils/user-config.ts
|
|
16
|
+
const UserConfigSchema = z.object({
|
|
17
|
+
title: TitleConfigSchema(),
|
|
18
|
+
description: z.string().optional(),
|
|
19
|
+
logo: LogoConfigSchema(),
|
|
20
|
+
social: SocialLinksSchema(),
|
|
21
|
+
tableOfContents: UserConfigTableOfContentsSchema(),
|
|
22
|
+
editLink: z.object({ baseUrl: z.url().optional() }).optional().default({}),
|
|
23
|
+
locales: z.object({ root: LocaleConfigSchema().required({ lang: true }).optional() }).catchall(LocaleConfigSchema()).transform((locales, ctx) => {
|
|
24
|
+
for (const key in locales) {
|
|
25
|
+
const locale = locales[key];
|
|
26
|
+
let lang = locale.lang || key;
|
|
27
|
+
const schema = parse(lang, { forgiving: true });
|
|
28
|
+
schema.region = schema.region?.toUpperCase();
|
|
29
|
+
const normalizedLang = stringify(schema);
|
|
30
|
+
if (!normalizedLang) {
|
|
31
|
+
ctx.issues.push({
|
|
32
|
+
code: "custom",
|
|
33
|
+
message: `Could not validate language tag "${lang}" at locales.${key}.lang.`,
|
|
34
|
+
input: lang
|
|
35
|
+
});
|
|
36
|
+
return z.NEVER;
|
|
37
|
+
}
|
|
38
|
+
if (normalizedLang !== lang) {
|
|
39
|
+
console.warn(`Warning: using "${normalizedLang}" language tag for locales.${key}.lang instead of "${lang}".`);
|
|
40
|
+
lang = normalizedLang;
|
|
41
|
+
}
|
|
42
|
+
locale.lang = lang;
|
|
43
|
+
}
|
|
44
|
+
return locales;
|
|
45
|
+
}).optional(),
|
|
46
|
+
defaultLocale: z.string().optional(),
|
|
47
|
+
sidebar: SidebarItemSchema.array().optional(),
|
|
48
|
+
head: HeadConfigSchema({ source: "config" }),
|
|
49
|
+
customCss: z.string().array().optional().default([]).superRefine((paths, ctx) => {
|
|
50
|
+
const invalidPathRegex = /^\.?\/public\/.+$/;
|
|
51
|
+
const invalidPaths = paths.filter((path) => invalidPathRegex.test(path));
|
|
52
|
+
if (invalidPaths.length > 0) ctx.issues.push({
|
|
53
|
+
code: "custom",
|
|
54
|
+
message: `These paths in your Starlight \`customCss\` config are invalid: ${invalidPaths.map((path) => `\`"${path}"\``).join(", ")}\n\nCSS files specified in \`customCss\` should be in the \`src/\` directory, not the \`public/\` directory.\n\nYou should move these CSS files into the \`src/\` directory and update the path in \`customCss\` to match.`,
|
|
55
|
+
input: paths
|
|
56
|
+
});
|
|
57
|
+
}),
|
|
58
|
+
lastUpdated: z.boolean().default(false),
|
|
59
|
+
pagination: z.boolean().default(true),
|
|
60
|
+
favicon: FaviconSchema(),
|
|
61
|
+
expressiveCode: ExpressiveCodeSchema(),
|
|
62
|
+
pagefind: z.boolean().transform((val) => val && PagefindConfigDefaults()).or(PagefindConfigSchema()).optional(),
|
|
63
|
+
components: ComponentConfigSchema(),
|
|
64
|
+
titleDelimiter: z.string().default("|"),
|
|
65
|
+
disable404Route: z.boolean().default(false),
|
|
66
|
+
prerender: z.boolean().default(true),
|
|
67
|
+
credits: z.boolean().default(false),
|
|
68
|
+
routeMiddleware: z.string().transform((string) => [string]).or(z.string().array()).default([]).superRefine((middlewares, ctx) => {
|
|
69
|
+
const invalidPathRegex = /^\.?\/src\/middleware(?:\/index)?\.[jt]s$/;
|
|
70
|
+
const invalidPaths = middlewares.filter((middleware) => invalidPathRegex.test(middleware));
|
|
71
|
+
for (const invalidPath of invalidPaths) ctx.issues.push({
|
|
72
|
+
code: "custom",
|
|
73
|
+
message: `The \`"${invalidPath}"\` path in your Starlight \`routeMiddleware\` config conflicts with Astro’s middleware locations.\n\nYou should rename \`${invalidPath}\` to something else like \`./src/starlightRouteData.ts\` and update the \`routeMiddleware\` file path to match.\n\n- More about Starlight route middleware: https://starlight.astro.build/guides/route-data/#how-to-customize-route-data
|
|
74
|
+
- More about Astro middleware: https://docs.astro.build/en/guides/middleware/`,
|
|
75
|
+
input: middlewares
|
|
76
|
+
});
|
|
77
|
+
}),
|
|
78
|
+
markdown: z.object({
|
|
79
|
+
headingLinks: z.boolean().default(true),
|
|
80
|
+
processedDirs: z.string().array().default([])
|
|
81
|
+
}).prefault({})
|
|
82
|
+
});
|
|
83
|
+
const StarlightConfigSchema = z.strictObject({ ...UserConfigSchema.shape }).transform((config) => ({
|
|
84
|
+
...config,
|
|
85
|
+
pagefind: typeof config.pagefind === "undefined" ? config.prerender && PagefindConfigDefaults() : config.pagefind
|
|
86
|
+
})).refine((config) => !(!config.prerender && config.pagefind), { error: "Pagefind search is not supported with prerendering disabled." }).transform(({ title, locales, defaultLocale, ...config }, ctx) => {
|
|
87
|
+
const configuredLocales = Object.keys(locales ?? {});
|
|
88
|
+
if (locales !== void 0 && (configuredLocales.length > 1 || configuredLocales.length === 1 && locales.root === void 0)) {
|
|
89
|
+
const defaultLocaleConfig = locales[defaultLocale || "root"];
|
|
90
|
+
if (!defaultLocaleConfig) {
|
|
91
|
+
const availableLocales = configuredLocales.map((l) => `"${l}"`).join(", ");
|
|
92
|
+
ctx.issues.push({
|
|
93
|
+
code: "custom",
|
|
94
|
+
message: "Could not determine the default locale. Please make sure `defaultLocale` in your Starlight config is one of " + availableLocales,
|
|
95
|
+
input: locales
|
|
96
|
+
});
|
|
97
|
+
return z.NEVER;
|
|
98
|
+
}
|
|
99
|
+
const parsedTitle = TitleTransformConfigSchema(defaultLocaleConfig.lang).parse(title);
|
|
100
|
+
return {
|
|
101
|
+
...config,
|
|
102
|
+
title: parsedTitle,
|
|
103
|
+
/** Flag indicating if this site has multiple locales set up. */
|
|
104
|
+
isMultilingual: configuredLocales.length > 1,
|
|
105
|
+
/** Flag indicating if the Starlight built-in default locale is used. */
|
|
106
|
+
isUsingBuiltInDefaultLocale: false,
|
|
107
|
+
/** Full locale object for this site’s default language. */
|
|
108
|
+
defaultLocale: {
|
|
109
|
+
...defaultLocaleConfig,
|
|
110
|
+
locale: defaultLocale
|
|
111
|
+
},
|
|
112
|
+
locales
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** Full locale object for this site’s default language. */
|
|
116
|
+
const defaultLocaleConfig = {
|
|
117
|
+
label: BuiltInDefaultLocale.label,
|
|
118
|
+
lang: BuiltInDefaultLocale.lang,
|
|
119
|
+
dir: BuiltInDefaultLocale.dir,
|
|
120
|
+
locale: void 0,
|
|
121
|
+
...locales?.root
|
|
122
|
+
};
|
|
123
|
+
const parsedTitle = TitleTransformConfigSchema(defaultLocaleConfig.lang).parse(title);
|
|
124
|
+
return {
|
|
125
|
+
...config,
|
|
126
|
+
title: parsedTitle,
|
|
127
|
+
/** Flag indicating if this site has multiple locales set up. */
|
|
128
|
+
isMultilingual: false,
|
|
129
|
+
/** Flag indicating if the Starlight built-in default locale is used. */
|
|
130
|
+
isUsingBuiltInDefaultLocale: locales?.root === void 0,
|
|
131
|
+
defaultLocale: defaultLocaleConfig,
|
|
132
|
+
locales: void 0
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
//#endregion
|
|
136
|
+
export { StarlightConfigSchema };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import config from "virtual:starlight/user-config";
|
|
2
|
+
import { logos } from "virtual:starlight/user-images";
|
|
3
|
+
//#region src/utils/validateLogoImports.ts
|
|
4
|
+
/** Check user-imported logo images have resolved correctly. */
|
|
5
|
+
function validateLogoImports() {
|
|
6
|
+
if (config.logo) {
|
|
7
|
+
let err;
|
|
8
|
+
if ("src" in config.logo) {
|
|
9
|
+
if (!logos.dark || !logos.light) err = `Could not resolve logo import for "${config.logo.src}" (logo.src)`;
|
|
10
|
+
} else if (!logos.dark) err = `Could not resolve logo import for "${config.logo.dark}" (logo.dark)`;
|
|
11
|
+
else if (!logos.light) err = `Could not resolve logo import for "${config.logo.light}" (logo.light)`;
|
|
12
|
+
if (err) throw new Error(err);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { validateLogoImports };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "astro/zod";
|
|
2
|
+
//#region src/utils/zodDeepMerge.d.ts
|
|
3
|
+
/** Type-level equivalent of {@link mergeWithDefaultSchema}. */
|
|
4
|
+
type DeepMergedSchema<Default extends z.core.$ZodType, User extends z.core.$ZodType> = User extends z.ZodOptional<infer WrappedSchema extends z.core.$ZodType> ? z.ZodOptional<DeepMergedSchema<UnwrappedSchema<Default>, WrappedSchema>> : User extends z.ZodNullable<infer WrappedSchema extends z.core.$ZodType> ? z.ZodNullable<DeepMergedSchema<UnwrappedSchema<Default>, WrappedSchema>> : User extends z.ZodDefault<infer WrappedSchema extends z.core.$ZodType> ? z.ZodDefault<DeepMergedSchema<UnwrappedSchema<Default>, WrappedSchema>> : User extends z.ZodPrefault<infer WrappedSchema extends z.core.$ZodType> ? z.ZodPrefault<DeepMergedSchema<UnwrappedSchema<Default>, WrappedSchema>> : User extends z.ZodUnion<infer Users extends readonly z.core.$ZodType[]> ? z.ZodUnion<DeepMergedUnionMembers<UnwrappedSchema<Default>, Users>> : UnwrappedSchema<Default> extends z.ZodObject<infer DefaultShape> ? User extends z.ZodObject<infer UserShape, infer UserConfig> ? z.ZodObject<DeepMergedShape<DefaultShape, UserShape>, UserConfig> : User : UnwrappedSchema<Default> extends z.ZodArray<infer DefaultItemSchema extends z.core.$ZodType> ? User extends z.ZodArray<infer UserItemSchema extends z.core.$ZodType> ? z.ZodArray<DeepMergedSchema<DefaultItemSchema, UserItemSchema>> : User : User;
|
|
5
|
+
/** Type-level equivalent of {@link unwrapSchema}. */
|
|
6
|
+
type UnwrappedSchema<T extends z.core.$ZodType> = T extends z.ZodOptional<infer Wrapped extends z.core.$ZodType> ? UnwrappedSchema<Wrapped> : T extends z.ZodNullable<infer Wrapped extends z.core.$ZodType> ? UnwrappedSchema<Wrapped> : T extends z.ZodDefault<infer Wrapped extends z.core.$ZodType> ? UnwrappedSchema<Wrapped> : T extends z.ZodPrefault<infer Wrapped extends z.core.$ZodType> ? UnwrappedSchema<Wrapped> : T;
|
|
7
|
+
/**
|
|
8
|
+
* Merged Zod object shapes, preserving default properties, adding user-only properties, and
|
|
9
|
+
* recursively merging shared properties.
|
|
10
|
+
*/
|
|
11
|
+
type DeepMergedShape<Default extends z.ZodRawShape, User extends z.ZodRawShape> = { [Key in keyof Default | keyof User]: Key extends keyof User ? Key extends keyof Default ? DeepMergedSchema<Default[Key], User[Key]> : User[Key] : Key extends keyof Default ? Default[Key] : never; };
|
|
12
|
+
/** Merged union schemas where each union member is deep-merged with the default schema. */
|
|
13
|
+
type DeepMergedUnionMembers<Default extends z.core.$ZodType, Users extends readonly z.core.$ZodType[]> = { [Key in keyof Users]: Users[Key] extends z.core.$ZodType ? DeepMergedSchema<Default, Users[Key]> : Users[Key]; };
|
|
14
|
+
declare function deepMergeSchemas(defaultSchema: z.ZodType, userSchema: z.ZodType): z.ZodType;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DeepMergedSchema, deepMergeSchemas };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/utils/zodDeepMerge.ts
|
|
2
|
+
function deepMergeSchemas(defaultSchema, userSchema) {
|
|
3
|
+
const unwrappedDefaultSchema = unwrapSchema(defaultSchema);
|
|
4
|
+
if (isWrappedSchema(userSchema)) return userSchema.clone({
|
|
5
|
+
...userSchema._zod.def,
|
|
6
|
+
innerType: deepMergeSchemas(unwrappedDefaultSchema, userSchema._zod.def.innerType)
|
|
7
|
+
});
|
|
8
|
+
if (isZodUnion(userSchema)) return userSchema.clone({
|
|
9
|
+
...userSchema._zod.def,
|
|
10
|
+
options: userSchema.options.map((schema) => deepMergeSchemas(unwrappedDefaultSchema, schema))
|
|
11
|
+
});
|
|
12
|
+
if (isZodObject(unwrappedDefaultSchema) && isZodObject(userSchema)) {
|
|
13
|
+
const shape = { ...unwrappedDefaultSchema.shape };
|
|
14
|
+
for (const key of Object.keys(userSchema.shape)) {
|
|
15
|
+
const userFieldSchema = userSchema.shape[key];
|
|
16
|
+
const defaultFieldSchema = shape[key];
|
|
17
|
+
shape[key] = defaultFieldSchema ? deepMergeSchemas(defaultFieldSchema, userFieldSchema) : userFieldSchema;
|
|
18
|
+
}
|
|
19
|
+
return userSchema.safeExtend(shape);
|
|
20
|
+
}
|
|
21
|
+
if (isZodArray(unwrappedDefaultSchema) && isZodArray(userSchema)) return userSchema.clone({
|
|
22
|
+
...userSchema._zod.def,
|
|
23
|
+
element: deepMergeSchemas(unwrappedDefaultSchema.element, userSchema.element)
|
|
24
|
+
});
|
|
25
|
+
return userSchema;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Unwrap any Zod schema that wraps other schemas, such as `z.optional()`, `z.nullable()`,
|
|
29
|
+
* `z.default()`, etc. until we reach the innermost schema.
|
|
30
|
+
*/
|
|
31
|
+
function unwrapSchema(schema) {
|
|
32
|
+
let current = schema;
|
|
33
|
+
while (isWrappedSchema(current)) current = current._zod.def.innerType;
|
|
34
|
+
return current;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if a schema wraps another schema which can happen when using modifiers like
|
|
38
|
+
* `z.optional()`, `z.nullable()`, `z.default()`, etc.
|
|
39
|
+
*/
|
|
40
|
+
function isWrappedSchema(schema) {
|
|
41
|
+
return schema._zod.def.type === "optional" || schema._zod.def.type === "nullable" || schema._zod.def.type === "default" || schema._zod.def.type === "prefault";
|
|
42
|
+
}
|
|
43
|
+
function isZodObject(schema) {
|
|
44
|
+
return schema._zod.def.type === "object";
|
|
45
|
+
}
|
|
46
|
+
function isZodArray(schema) {
|
|
47
|
+
return schema._zod.def.type === "array";
|
|
48
|
+
}
|
|
49
|
+
function isZodUnion(schema) {
|
|
50
|
+
return schema._zod.def.type === "union";
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { deepMergeSchemas };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/starlight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "Build beautiful, high-performance documentation websites with Astro",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -13,37 +13,61 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/withastro/starlight",
|
|
16
|
+
"url": "git+https://github.com/withastro/starlight.git",
|
|
17
17
|
"directory": "packages/starlight"
|
|
18
18
|
},
|
|
19
19
|
"bugs": "https://github.com/withastro/starlight/issues",
|
|
20
20
|
"homepage": "https://starlight.astro.build",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
|
-
".":
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"./
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"./
|
|
32
|
-
"./
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./locals": {
|
|
28
|
+
"types": "./dist/locals.d.ts",
|
|
29
|
+
"import": "./dist/locals.js"
|
|
30
|
+
},
|
|
31
|
+
"./components": "./dist/components.ts",
|
|
32
|
+
"./components/*": "./dist/components/*",
|
|
33
|
+
"./internal": {
|
|
34
|
+
"types": "./dist/internal.d.ts",
|
|
35
|
+
"import": "./dist/internal.js"
|
|
36
|
+
},
|
|
37
|
+
"./props": {
|
|
38
|
+
"types": "./dist/props.d.ts",
|
|
39
|
+
"import": "./dist/props.js"
|
|
40
|
+
},
|
|
41
|
+
"./schema": {
|
|
42
|
+
"types": "./dist/schema.d.ts",
|
|
43
|
+
"import": "./dist/schema.js"
|
|
44
|
+
},
|
|
45
|
+
"./loaders": {
|
|
46
|
+
"types": "./dist/loaders.d.ts",
|
|
47
|
+
"import": "./dist/loaders.js"
|
|
48
|
+
},
|
|
49
|
+
"./route-data": {
|
|
50
|
+
"types": "./dist/route-data.d.ts",
|
|
51
|
+
"import": "./dist/route-data.js"
|
|
52
|
+
},
|
|
53
|
+
"./types": {
|
|
54
|
+
"types": "./dist/types.d.ts",
|
|
55
|
+
"import": "./dist/types.js"
|
|
56
|
+
},
|
|
33
57
|
"./expressive-code": {
|
|
34
|
-
"types": "./expressive-code.d.ts",
|
|
35
|
-
"
|
|
58
|
+
"types": "./dist/expressive-code.d.ts",
|
|
59
|
+
"import": "./dist/expressive-code.js"
|
|
36
60
|
},
|
|
37
61
|
"./expressive-code/hast": {
|
|
38
|
-
"types": "./integrations/expressive-code/hast.d.ts",
|
|
39
|
-
"
|
|
62
|
+
"types": "./dist/integrations/expressive-code/hast.d.ts",
|
|
63
|
+
"import": "./dist/integrations/expressive-code/hast.js"
|
|
40
64
|
},
|
|
41
|
-
"./routes/*": "./routes/*",
|
|
42
|
-
"./style/markdown.css": "./style/markdown.css"
|
|
65
|
+
"./routes/*": "./dist/routes/*",
|
|
66
|
+
"./style/markdown.css": "./dist/style/markdown.css"
|
|
43
67
|
},
|
|
44
68
|
"peerDependencies": {
|
|
45
|
-
"@astrojs/markdown-remark": "^7.
|
|
46
|
-
"astro": "^7.
|
|
69
|
+
"@astrojs/markdown-remark": "^7.3.0",
|
|
70
|
+
"astro": "^7.2.10"
|
|
47
71
|
},
|
|
48
72
|
"peerDependenciesMeta": {
|
|
49
73
|
"@astrojs/markdown-remark": {
|
|
@@ -51,51 +75,56 @@
|
|
|
51
75
|
}
|
|
52
76
|
},
|
|
53
77
|
"devDependencies": {
|
|
54
|
-
"@astrojs/markdown-remark": "^7.
|
|
78
|
+
"@astrojs/markdown-remark": "^7.3.0",
|
|
79
|
+
"@codspeed/vitest-plugin": "^5.7.1",
|
|
55
80
|
"@playwright/test": "^1.61.1",
|
|
56
81
|
"@types/node": "^22.19.17",
|
|
57
82
|
"@vitest/coverage-v8": "^4.1.5",
|
|
58
|
-
"astro": "^7.
|
|
83
|
+
"astro": "^7.2.10",
|
|
59
84
|
"linkedom": "^0.18.12",
|
|
60
85
|
"vitest": "^4.1.5"
|
|
61
86
|
},
|
|
62
87
|
"dependencies": {
|
|
63
|
-
"@astrojs/markdown-satteri": "^0.
|
|
64
|
-
"@astrojs/mdx": "^
|
|
88
|
+
"@astrojs/markdown-satteri": "^0.4.0",
|
|
89
|
+
"@astrojs/mdx": "^8.0.0",
|
|
65
90
|
"@astrojs/sitemap": "^3.7.3",
|
|
66
91
|
"@pagefind/default-ui": "^1.3.0",
|
|
67
|
-
"@types/hast": "^3.0.
|
|
92
|
+
"@types/hast": "^3.0.5",
|
|
68
93
|
"@types/js-yaml": "^4.0.9",
|
|
69
94
|
"@types/mdast": "^4.0.4",
|
|
70
95
|
"astro-expressive-code": "^0.44.0",
|
|
71
96
|
"bcp-47": "^2.1.0",
|
|
72
|
-
"hast-util-
|
|
97
|
+
"hast-util-format": "^1.1.0",
|
|
73
98
|
"hast-util-select": "^6.0.4",
|
|
99
|
+
"hast-util-to-html": "^9.0.5",
|
|
74
100
|
"hast-util-to-string": "^3.0.1",
|
|
75
101
|
"hastscript": "^9.0.1",
|
|
76
102
|
"i18next": "^26.0.7",
|
|
77
103
|
"js-yaml": "^4.1.1",
|
|
78
104
|
"klona": "^2.0.6",
|
|
79
|
-
"magic-string": "^
|
|
105
|
+
"magic-string": "^1.2.3",
|
|
80
106
|
"mdast-util-directive": "^3.1.0",
|
|
81
107
|
"mdast-util-to-markdown": "^2.1.2",
|
|
82
108
|
"mdast-util-to-string": "^4.0.0",
|
|
83
109
|
"pagefind": "^1.5.2",
|
|
84
|
-
"rehype": "^13.0.2",
|
|
85
|
-
"rehype-format": "^5.0.1",
|
|
86
110
|
"remark-directive": "^4.0.0",
|
|
87
|
-
"satteri": "^0.
|
|
111
|
+
"satteri": "^0.10.3",
|
|
88
112
|
"ultrahtml": "^1.6.0",
|
|
89
113
|
"unified": "^11.0.5",
|
|
90
114
|
"unist-util-visit": "^5.1.0",
|
|
91
115
|
"vfile": "^6.0.3"
|
|
92
116
|
},
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
|
|
117
|
+
"files": [
|
|
118
|
+
"dist"
|
|
119
|
+
],
|
|
96
120
|
"scripts": {
|
|
121
|
+
"build": "tsdown",
|
|
97
122
|
"test": "VITE_CONFIG_NATIVE_IGNORE_WARNING=true vitest",
|
|
98
123
|
"test:coverage": "VITE_CONFIG_NATIVE_IGNORE_WARNING=true vitest run --coverage",
|
|
124
|
+
"test:dist": "pnpm build && pnpm test:dist:ci",
|
|
125
|
+
"test:dist:ci": "VITE_CONFIG_NATIVE_IGNORE_WARNING=true STARLIGHT_TEST_DIST=true vitest run",
|
|
126
|
+
"bench": "pnpm bench:functional",
|
|
127
|
+
"bench:functional": "VITE_CONFIG_NATIVE_IGNORE_WARNING=true vitest bench --run --config vitest.functional.bench.config.ts __bench_fn__/*.bench.ts",
|
|
99
128
|
"test:e2e": "playwright install --with-deps chromium && playwright test",
|
|
100
129
|
"test:e2e:ci": "playwright test"
|
|
101
130
|
}
|