@treeseed/core 0.1.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/README.md +145 -0
- package/dist/agents/index.js +5 -0
- package/dist/agents/registry-helper.js +14 -0
- package/dist/agents/registry.js +88 -0
- package/dist/components/DevWatchReload.astro +45 -0
- package/dist/components/SiteTitle.astro +51 -0
- package/dist/components/content/ContentStatusLegend.astro +18 -0
- package/dist/components/content/StatusBadge.astro +11 -0
- package/dist/components/docs/BookFontControls.astro +180 -0
- package/dist/components/docs/DesktopSidebarToggle.astro +88 -0
- package/dist/components/docs/DownloadBook.astro +34 -0
- package/dist/components/docs/Footer.astro +196 -0
- package/dist/components/docs/Header.astro +150 -0
- package/dist/components/docs/PageFrame.astro +260 -0
- package/dist/components/docs/PageSidebar.astro +63 -0
- package/dist/components/docs/PageTitle.astro +39 -0
- package/dist/components/docs/Sidebar.astro +41 -0
- package/dist/components/docs/ThemeSelect.astro +3 -0
- package/dist/components/forms/ContactForm.astro +234 -0
- package/dist/components/forms/FooterSubscribeForm.astro +189 -0
- package/dist/components/site/BookList.astro +27 -0
- package/dist/components/site/CTASection.astro +24 -0
- package/dist/components/site/ChronicleList.astro +33 -0
- package/dist/components/site/Hero.astro +18 -0
- package/dist/components/site/NotesList.astro +18 -0
- package/dist/components/site/PathCard.astro +16 -0
- package/dist/components/site/ProfileList.astro +30 -0
- package/dist/components/site/SectionIntro.astro +9 -0
- package/dist/components/site/StageBanner.astro +8 -0
- package/dist/components/site/TrustCallout.astro +9 -0
- package/dist/components/starlight.js +6 -0
- package/dist/config.js +8 -0
- package/dist/content-config.js +9 -0
- package/dist/content.js +230 -0
- package/dist/contracts.d.ts +130 -0
- package/dist/contracts.js +0 -0
- package/dist/deploy/config.d.ts +4 -0
- package/dist/deploy/config.js +154 -0
- package/dist/deploy/runtime.js +77 -0
- package/dist/env.yaml +322 -0
- package/dist/environment.d.ts +130 -0
- package/dist/environment.js +324 -0
- package/dist/index.js +81 -0
- package/dist/layouts/AuthoredEntryLayout.astro +87 -0
- package/dist/layouts/BookLayout.astro +35 -0
- package/dist/layouts/BridgeLayout.astro +11 -0
- package/dist/layouts/ContentLayout.astro +24 -0
- package/dist/layouts/MainLayout.astro +203 -0
- package/dist/layouts/NoteLayout.astro +26 -0
- package/dist/layouts/ProfileLayout.astro +81 -0
- package/dist/middleware/starlightRouteData.js +45 -0
- package/dist/pages/404.astro +29 -0
- package/dist/pages/[slug].astro +30 -0
- package/dist/pages/agents/[slug].astro +29 -0
- package/dist/pages/agents/index.astro +27 -0
- package/dist/pages/api/form/submit.js +14 -0
- package/dist/pages/books/[slug].astro +19 -0
- package/dist/pages/books/index.astro +28 -0
- package/dist/pages/contact.astro +27 -0
- package/dist/pages/feed.xml.js +34 -0
- package/dist/pages/index.astro +290 -0
- package/dist/pages/notes/[slug].astro +19 -0
- package/dist/pages/notes/index.astro +21 -0
- package/dist/pages/objectives/[slug].astro +31 -0
- package/dist/pages/objectives/index.astro +30 -0
- package/dist/pages/people/[slug].astro +29 -0
- package/dist/pages/people/index.astro +28 -0
- package/dist/pages/questions/[slug].astro +31 -0
- package/dist/pages/questions/index.astro +30 -0
- package/dist/plugin-default.js +4 -0
- package/dist/plugins/builtin/default-plugin.d.ts +21 -0
- package/dist/plugins/builtin/default-plugin.js +32 -0
- package/dist/plugins/constants.d.ts +21 -0
- package/dist/plugins/constants.js +28 -0
- package/dist/plugins/plugin.d.ts +42 -0
- package/dist/plugins/plugin.js +6 -0
- package/dist/plugins/runtime.d.ts +31 -0
- package/dist/plugins/runtime.js +120 -0
- package/dist/scripts/aggregate-book.js +112 -0
- package/dist/scripts/assert-release-tag-version.js +21 -0
- package/dist/scripts/build-dist.js +384 -0
- package/dist/scripts/build-tenant-worker.js +36 -0
- package/dist/scripts/package-tools.js +88 -0
- package/dist/scripts/patch-starlight-content-path.js +172 -0
- package/dist/scripts/paths.js +11 -0
- package/dist/scripts/publish-package.js +20 -0
- package/dist/scripts/release-verify.js +52 -0
- package/dist/scripts/run-fixture-astro-command.js +21 -0
- package/dist/scripts/tenant-astro-command.js +3 -0
- package/dist/scripts/tenant-build.js +16 -0
- package/dist/scripts/tenant-check.js +7 -0
- package/dist/scripts/test-smoke.js +105 -0
- package/dist/server.js +53 -0
- package/dist/site-resources.d.ts +29 -0
- package/dist/site-resources.js +127 -0
- package/dist/site.js +313 -0
- package/dist/styles/global.css +683 -0
- package/dist/styles/prose.css +89 -0
- package/dist/styles/tokens.css +24 -0
- package/dist/tenant/bridge.js +5 -0
- package/dist/tenant/config.d.ts +9 -0
- package/dist/tenant/config.js +124 -0
- package/dist/tenant/runtime-config.js +20 -0
- package/dist/tsconfigs/strict.json +3 -0
- package/dist/types/agents.d.ts +1 -0
- package/dist/types/agents.js +1 -0
- package/dist/types/astro-build.d.js +0 -0
- package/dist/types/cloudflare-sockets.d.js +0 -0
- package/dist/types/cloudflare.d.ts +1 -0
- package/dist/types/cloudflare.js +1 -0
- package/dist/types/forms.js +4 -0
- package/dist/utils/agents/adapters/execution.js +90 -0
- package/dist/utils/agents/adapters/mutations.js +30 -0
- package/dist/utils/agents/adapters/notification.js +16 -0
- package/dist/utils/agents/adapters/repository.js +61 -0
- package/dist/utils/agents/adapters/research.js +25 -0
- package/dist/utils/agents/adapters/verification.js +62 -0
- package/dist/utils/agents/cli-tools.js +5 -0
- package/dist/utils/agents/contracts/messages.d.ts +88 -0
- package/dist/utils/agents/contracts/messages.js +138 -0
- package/dist/utils/agents/contracts/run.d.ts +20 -0
- package/dist/utils/agents/contracts/run.js +0 -0
- package/dist/utils/agents/runtime-types.d.ts +117 -0
- package/dist/utils/agents/runtime-types.js +4 -0
- package/dist/utils/books-data.js +82 -0
- package/dist/utils/content-status.js +38 -0
- package/dist/utils/forms/config.js +87 -0
- package/dist/utils/forms/constants.js +27 -0
- package/dist/utils/forms/contact-submissions-local.js +19 -0
- package/dist/utils/forms/contact-submissions.js +72 -0
- package/dist/utils/forms/crypto.js +64 -0
- package/dist/utils/forms/guard.js +76 -0
- package/dist/utils/forms/http.js +51 -0
- package/dist/utils/forms/provider-core.js +88 -0
- package/dist/utils/forms/routing-core.js +7 -0
- package/dist/utils/forms/routing.js +13 -0
- package/dist/utils/forms/runtime-core.js +17 -0
- package/dist/utils/forms/runtime.js +27 -0
- package/dist/utils/forms/service-core.js +256 -0
- package/dist/utils/forms/service.js +55 -0
- package/dist/utils/forms/session.js +57 -0
- package/dist/utils/forms/smtp-cloudflare.js +107 -0
- package/dist/utils/forms/smtp-node.js +27 -0
- package/dist/utils/forms/smtp.js +10 -0
- package/dist/utils/forms/subscribers-local.js +21 -0
- package/dist/utils/forms/subscribers.js +53 -0
- package/dist/utils/forms/turnstile.js +31 -0
- package/dist/utils/forms/validation.js +58 -0
- package/dist/utils/hub-content.js +28 -0
- package/dist/utils/plugin-runtime.js +158 -0
- package/dist/utils/routes.js +17 -0
- package/dist/utils/seo.js +4 -0
- package/dist/utils/site-config-schema.js +282 -0
- package/dist/utils/site-config.js +122 -0
- package/dist/utils/starlight-nav.js +62 -0
- package/dist/utils/theme.js +49 -0
- package/dist/vendor/starlight/components/AnchorHeading.astro +53 -0
- package/dist/vendor/starlight/components/Banner.astro +23 -0
- package/dist/vendor/starlight/components/ContentNotice.astro +33 -0
- package/dist/vendor/starlight/components/ContentPanel.astro +27 -0
- package/dist/vendor/starlight/components/DraftContentNotice.astro +5 -0
- package/dist/vendor/starlight/components/EditLink.astro +28 -0
- package/dist/vendor/starlight/components/FallbackContentNotice.astro +5 -0
- package/dist/vendor/starlight/components/Footer.astro +61 -0
- package/dist/vendor/starlight/components/Head.astro +5 -0
- package/dist/vendor/starlight/components/Header.astro +94 -0
- package/dist/vendor/starlight/components/Hero.astro +143 -0
- package/dist/vendor/starlight/components/Icons.js +121 -0
- package/dist/vendor/starlight/components/LanguageSelect.astro +57 -0
- package/dist/vendor/starlight/components/LastUpdated.astro +14 -0
- package/dist/vendor/starlight/components/MarkdownContent.astro +5 -0
- package/dist/vendor/starlight/components/MobileMenuFooter.astro +35 -0
- package/dist/vendor/starlight/components/MobileMenuToggle.astro +107 -0
- package/dist/vendor/starlight/components/MobileTableOfContents.astro +151 -0
- package/dist/vendor/starlight/components/Page.astro +126 -0
- package/dist/vendor/starlight/components/PageFrame.astro +97 -0
- package/dist/vendor/starlight/components/PageSidebar.astro +59 -0
- package/dist/vendor/starlight/components/PageTitle.astro +17 -0
- package/dist/vendor/starlight/components/Pagination.astro +79 -0
- package/dist/vendor/starlight/components/Search.astro +488 -0
- package/dist/vendor/starlight/components/Select.astro +99 -0
- package/dist/vendor/starlight/components/Sidebar.astro +15 -0
- package/dist/vendor/starlight/components/SidebarPersistState.js +43 -0
- package/dist/vendor/starlight/components/SidebarPersister.astro +78 -0
- package/dist/vendor/starlight/components/SidebarRestorePoint.astro +12 -0
- package/dist/vendor/starlight/components/SidebarSublist.astro +154 -0
- package/dist/vendor/starlight/components/SiteTitle.astro +59 -0
- package/dist/vendor/starlight/components/SkipLink.astro +26 -0
- package/dist/vendor/starlight/components/SocialIcons.astro +32 -0
- package/dist/vendor/starlight/components/StarlightPage.astro +17 -0
- package/dist/vendor/starlight/components/TableOfContents/TableOfContentsList.astro +79 -0
- package/dist/vendor/starlight/components/TableOfContents/starlight-toc.js +93 -0
- package/dist/vendor/starlight/components/TableOfContents.astro +18 -0
- package/dist/vendor/starlight/components/ThemeProvider.astro +38 -0
- package/dist/vendor/starlight/components/ThemeSelect.astro +73 -0
- package/dist/vendor/starlight/components/TwoColumnContent.astro +54 -0
- package/dist/vendor/starlight/components.js +26 -0
- package/dist/vendor/starlight/constants.js +4 -0
- package/dist/vendor/starlight/expressive-code.d.js +1 -0
- package/dist/vendor/starlight/global.d.js +0 -0
- package/dist/vendor/starlight/i18n.d.js +1 -0
- package/dist/vendor/starlight/index.js +119 -0
- package/dist/vendor/starlight/integrations/asides-error.js +12 -0
- package/dist/vendor/starlight/integrations/asides.js +179 -0
- package/dist/vendor/starlight/integrations/code-rtl-support.js +21 -0
- package/dist/vendor/starlight/integrations/expressive-code/hast.d.js +1 -0
- package/dist/vendor/starlight/integrations/expressive-code/index.js +63 -0
- package/dist/vendor/starlight/integrations/expressive-code/preprocessor.js +92 -0
- package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-dark.jsonc +1796 -0
- package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-dark.jsonc.js +1 -0
- package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-light.jsonc +1695 -0
- package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-light.jsonc.js +1 -0
- package/dist/vendor/starlight/integrations/expressive-code/theming.js +62 -0
- package/dist/vendor/starlight/integrations/expressive-code/translations.js +29 -0
- package/dist/vendor/starlight/integrations/heading-links.js +61 -0
- package/dist/vendor/starlight/integrations/pagefind.js +43 -0
- package/dist/vendor/starlight/integrations/remark-rehype.js +68 -0
- package/dist/vendor/starlight/integrations/shared/absolutePathToLang.js +15 -0
- package/dist/vendor/starlight/integrations/shared/localeToLang.js +9 -0
- package/dist/vendor/starlight/integrations/shared/slugToLocale.js +10 -0
- package/dist/vendor/starlight/integrations/sitemap.js +20 -0
- package/dist/vendor/starlight/integrations/virtual-user-config.js +110 -0
- package/dist/vendor/starlight/integrations/vite-layer-order.js +42 -0
- package/dist/vendor/starlight/internal.js +6 -0
- package/dist/vendor/starlight/loaders.js +36 -0
- package/dist/vendor/starlight/locals.d.js +0 -0
- package/dist/vendor/starlight/locals.js +30 -0
- package/dist/vendor/starlight/package.json +231 -0
- package/dist/vendor/starlight/package.json.js +248 -0
- package/dist/vendor/starlight/props.js +0 -0
- package/dist/vendor/starlight/route-data.js +6 -0
- package/dist/vendor/starlight/routes/common.astro +23 -0
- package/dist/vendor/starlight/routes/ssr/404.astro +7 -0
- package/dist/vendor/starlight/routes/ssr/index.astro +14 -0
- package/dist/vendor/starlight/routes/static/404.astro +7 -0
- package/dist/vendor/starlight/routes/static/index.astro +12 -0
- package/dist/vendor/starlight/schema.js +102 -0
- package/dist/vendor/starlight/schemas/badge.js +26 -0
- package/dist/vendor/starlight/schemas/components.js +235 -0
- package/dist/vendor/starlight/schemas/expressiveCode.js +12 -0
- package/dist/vendor/starlight/schemas/favicon.js +33 -0
- package/dist/vendor/starlight/schemas/head.js +32 -0
- package/dist/vendor/starlight/schemas/hero.js +57 -0
- package/dist/vendor/starlight/schemas/i18n.js +101 -0
- package/dist/vendor/starlight/schemas/icon.js +7 -0
- package/dist/vendor/starlight/schemas/logo.js +24 -0
- package/dist/vendor/starlight/schemas/pagefind.js +108 -0
- package/dist/vendor/starlight/schemas/prevNextLink.js +14 -0
- package/dist/vendor/starlight/schemas/sidebar.js +80 -0
- package/dist/vendor/starlight/schemas/site-title.js +19 -0
- package/dist/vendor/starlight/schemas/social.js +19 -0
- package/dist/vendor/starlight/schemas/tableOfContents.js +16 -0
- package/dist/vendor/starlight/style/anchor-links.css +131 -0
- package/dist/vendor/starlight/style/asides.css +51 -0
- package/dist/vendor/starlight/style/layers.css +1 -0
- package/dist/vendor/starlight/style/markdown.css +253 -0
- package/dist/vendor/starlight/style/print.css +175 -0
- package/dist/vendor/starlight/style/props.css +188 -0
- package/dist/vendor/starlight/style/reset.css +52 -0
- package/dist/vendor/starlight/style/util.css +63 -0
- package/dist/vendor/starlight/translations/ar.json +30 -0
- package/dist/vendor/starlight/translations/ar.json.js +32 -0
- package/dist/vendor/starlight/translations/ca.json +43 -0
- package/dist/vendor/starlight/translations/ca.json.js +45 -0
- package/dist/vendor/starlight/translations/cs.json +43 -0
- package/dist/vendor/starlight/translations/cs.json.js +45 -0
- package/dist/vendor/starlight/translations/da.json +30 -0
- package/dist/vendor/starlight/translations/da.json.js +32 -0
- package/dist/vendor/starlight/translations/de.json +30 -0
- package/dist/vendor/starlight/translations/de.json.js +32 -0
- package/dist/vendor/starlight/translations/el.json +30 -0
- package/dist/vendor/starlight/translations/el.json.js +32 -0
- package/dist/vendor/starlight/translations/en.json +30 -0
- package/dist/vendor/starlight/translations/en.json.js +32 -0
- package/dist/vendor/starlight/translations/es.json +43 -0
- package/dist/vendor/starlight/translations/es.json.js +45 -0
- package/dist/vendor/starlight/translations/fa.json +30 -0
- package/dist/vendor/starlight/translations/fa.json.js +32 -0
- package/dist/vendor/starlight/translations/fi.json +30 -0
- package/dist/vendor/starlight/translations/fi.json.js +32 -0
- package/dist/vendor/starlight/translations/fr.json +33 -0
- package/dist/vendor/starlight/translations/fr.json.js +35 -0
- package/dist/vendor/starlight/translations/gl.json +43 -0
- package/dist/vendor/starlight/translations/gl.json.js +45 -0
- package/dist/vendor/starlight/translations/he.json +30 -0
- package/dist/vendor/starlight/translations/he.json.js +32 -0
- package/dist/vendor/starlight/translations/hi.json +30 -0
- package/dist/vendor/starlight/translations/hi.json.js +32 -0
- package/dist/vendor/starlight/translations/hu.json +43 -0
- package/dist/vendor/starlight/translations/hu.json.js +45 -0
- package/dist/vendor/starlight/translations/id.json +30 -0
- package/dist/vendor/starlight/translations/id.json.js +32 -0
- package/dist/vendor/starlight/translations/index.js +77 -0
- package/dist/vendor/starlight/translations/it.json +30 -0
- package/dist/vendor/starlight/translations/it.json.js +32 -0
- package/dist/vendor/starlight/translations/ja.json +30 -0
- package/dist/vendor/starlight/translations/ja.json.js +32 -0
- package/dist/vendor/starlight/translations/ko.json +30 -0
- package/dist/vendor/starlight/translations/ko.json.js +32 -0
- package/dist/vendor/starlight/translations/lv.json +30 -0
- package/dist/vendor/starlight/translations/lv.json.js +32 -0
- package/dist/vendor/starlight/translations/nb.json +30 -0
- package/dist/vendor/starlight/translations/nb.json.js +32 -0
- package/dist/vendor/starlight/translations/nl.json +30 -0
- package/dist/vendor/starlight/translations/nl.json.js +32 -0
- package/dist/vendor/starlight/translations/pl.json +33 -0
- package/dist/vendor/starlight/translations/pl.json.js +35 -0
- package/dist/vendor/starlight/translations/pt.json +30 -0
- package/dist/vendor/starlight/translations/pt.json.js +32 -0
- package/dist/vendor/starlight/translations/ro.json +30 -0
- package/dist/vendor/starlight/translations/ro.json.js +32 -0
- package/dist/vendor/starlight/translations/ru.json +33 -0
- package/dist/vendor/starlight/translations/ru.json.js +35 -0
- package/dist/vendor/starlight/translations/sk.json +30 -0
- package/dist/vendor/starlight/translations/sk.json.js +32 -0
- package/dist/vendor/starlight/translations/sv.json +30 -0
- package/dist/vendor/starlight/translations/sv.json.js +32 -0
- package/dist/vendor/starlight/translations/th.json +30 -0
- package/dist/vendor/starlight/translations/th.json.js +32 -0
- package/dist/vendor/starlight/translations/tr.json +30 -0
- package/dist/vendor/starlight/translations/tr.json.js +32 -0
- package/dist/vendor/starlight/translations/uk.json +30 -0
- package/dist/vendor/starlight/translations/uk.json.js +32 -0
- package/dist/vendor/starlight/translations/vi.json +30 -0
- package/dist/vendor/starlight/translations/vi.json.js +32 -0
- package/dist/vendor/starlight/translations/zh-CN.json +30 -0
- package/dist/vendor/starlight/translations/zh-CN.json.js +32 -0
- package/dist/vendor/starlight/translations/zh-TW.json +30 -0
- package/dist/vendor/starlight/translations/zh-TW.json.js +32 -0
- package/dist/vendor/starlight/types.js +0 -0
- package/dist/vendor/starlight/user-components/Aside.astro +40 -0
- package/dist/vendor/starlight/user-components/Badge.astro +148 -0
- package/dist/vendor/starlight/user-components/Card.astro +68 -0
- package/dist/vendor/starlight/user-components/CardGrid.astro +38 -0
- package/dist/vendor/starlight/user-components/FileTree.astro +137 -0
- package/dist/vendor/starlight/user-components/Icon.astro +42 -0
- package/dist/vendor/starlight/user-components/LinkButton.astro +78 -0
- package/dist/vendor/starlight/user-components/LinkCard.astro +78 -0
- package/dist/vendor/starlight/user-components/Steps.astro +90 -0
- package/dist/vendor/starlight/user-components/TabItem.astro +19 -0
- package/dist/vendor/starlight/user-components/Tabs.astro +268 -0
- package/dist/vendor/starlight/user-components/file-tree-icons.js +608 -0
- package/dist/vendor/starlight/user-components/rehype-file-tree.js +160 -0
- package/dist/vendor/starlight/user-components/rehype-steps.js +53 -0
- package/dist/vendor/starlight/user-components/rehype-tabs.js +73 -0
- package/dist/vendor/starlight/utils/base.js +14 -0
- package/dist/vendor/starlight/utils/canonical.js +13 -0
- package/dist/vendor/starlight/utils/collection-fs.js +13 -0
- package/dist/vendor/starlight/utils/collection.js +16 -0
- package/dist/vendor/starlight/utils/createPathFormatter.js +39 -0
- package/dist/vendor/starlight/utils/createTranslationSystem.js +60 -0
- package/dist/vendor/starlight/utils/error-map.js +110 -0
- package/dist/vendor/starlight/utils/format-path.js +9 -0
- package/dist/vendor/starlight/utils/generateToC.js +18 -0
- package/dist/vendor/starlight/utils/git.js +92 -0
- package/dist/vendor/starlight/utils/gitInlined.js +13 -0
- package/dist/vendor/starlight/utils/head.js +156 -0
- package/dist/vendor/starlight/utils/i18n.js +121 -0
- package/dist/vendor/starlight/utils/localizedUrl.js +37 -0
- package/dist/vendor/starlight/utils/navigation.js +320 -0
- package/dist/vendor/starlight/utils/path.js +52 -0
- package/dist/vendor/starlight/utils/plugins.js +355 -0
- package/dist/vendor/starlight/utils/routing/data.js +116 -0
- package/dist/vendor/starlight/utils/routing/index.js +107 -0
- package/dist/vendor/starlight/utils/routing/middleware.js +40 -0
- package/dist/vendor/starlight/utils/routing/types.js +0 -0
- package/dist/vendor/starlight/utils/routing.js +1 -0
- package/dist/vendor/starlight/utils/slugs.js +70 -0
- package/dist/vendor/starlight/utils/starlight-page.js +123 -0
- package/dist/vendor/starlight/utils/translations-fs.js +31 -0
- package/dist/vendor/starlight/utils/translations.js +31 -0
- package/dist/vendor/starlight/utils/types.js +0 -0
- package/dist/vendor/starlight/utils/url.js +5 -0
- package/dist/vendor/starlight/utils/user-config.js +255 -0
- package/dist/vendor/starlight/utils/validateLogoImports.js +22 -0
- package/dist/vendor/starlight/virtual-internal.d.js +0 -0
- package/dist/vendor/starlight/virtual.d.js +0 -0
- package/dist/worker/forms-worker.js +141 -0
- package/package.json +156 -0
- package/style/anchor-links.css +131 -0
- package/templates/github/deploy.workflow.yml +47 -0
- package/tsconfigs/strict.json +3 -0
- package/utils/git.ts +121 -0
- package/utils/gitInlined.ts +20 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const makeAPI = (data) => {
|
|
2
|
+
const trackedDocsFiles = new Map(data);
|
|
3
|
+
return {
|
|
4
|
+
getNewestCommitDate: (file) => {
|
|
5
|
+
const timestamp = trackedDocsFiles.get(file);
|
|
6
|
+
if (!timestamp) throw new Error(`Failed to retrieve the git history for file "${file}"`);
|
|
7
|
+
return new Date(timestamp);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
makeAPI
|
|
13
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import config from "virtual:starlight/user-config";
|
|
2
|
+
import project from "virtual:starlight/project-context";
|
|
3
|
+
import { version } from "../package.json.js";
|
|
4
|
+
import { HeadConfigSchema } from "../schemas/head.js";
|
|
5
|
+
import { fileWithBase } from "./base.js";
|
|
6
|
+
import { formatCanonical } from "./canonical.js";
|
|
7
|
+
import { localizedUrl } from "./localizedUrl.js";
|
|
8
|
+
import { isAbsoluteUrl } from "./url.js";
|
|
9
|
+
const HeadSchema = HeadConfigSchema({ source: "content" });
|
|
10
|
+
function getHead({ entry, lang }, context, siteTitle) {
|
|
11
|
+
const { data } = entry;
|
|
12
|
+
const canonical = context.site ? new URL(context.url.pathname, context.site) : void 0;
|
|
13
|
+
const canonicalHref = canonical?.href ? formatCanonical(canonical.href, {
|
|
14
|
+
format: project.build.format,
|
|
15
|
+
trailingSlash: project.trailingSlash
|
|
16
|
+
}) : void 0;
|
|
17
|
+
const description = data.description || config.description;
|
|
18
|
+
const headDefaults = [
|
|
19
|
+
{ tag: "meta", attrs: { charset: "utf-8" } },
|
|
20
|
+
{
|
|
21
|
+
tag: "meta",
|
|
22
|
+
attrs: { name: "viewport", content: "width=device-width, initial-scale=1" }
|
|
23
|
+
},
|
|
24
|
+
{ tag: "title", content: `${data.title} ${config.titleDelimiter} ${siteTitle}` },
|
|
25
|
+
...canonicalHref !== void 0 ? [{ tag: "link", attrs: { rel: "canonical", href: canonicalHref } }] : [],
|
|
26
|
+
{ tag: "meta", attrs: { name: "generator", content: context.generator } },
|
|
27
|
+
{
|
|
28
|
+
tag: "meta",
|
|
29
|
+
attrs: { name: "generator", content: `Starlight v${version}` }
|
|
30
|
+
},
|
|
31
|
+
// Favicon
|
|
32
|
+
{
|
|
33
|
+
tag: "link",
|
|
34
|
+
attrs: {
|
|
35
|
+
rel: "shortcut icon",
|
|
36
|
+
href: isAbsoluteUrl(config.favicon.href) ? config.favicon.href : fileWithBase(config.favicon.href),
|
|
37
|
+
type: config.favicon.type
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
// OpenGraph Tags
|
|
41
|
+
{ tag: "meta", attrs: { property: "og:title", content: data.title } },
|
|
42
|
+
{ tag: "meta", attrs: { property: "og:type", content: "article" } },
|
|
43
|
+
...canonicalHref !== void 0 ? [{ tag: "meta", attrs: { property: "og:url", content: canonicalHref } }] : [],
|
|
44
|
+
{ tag: "meta", attrs: { property: "og:locale", content: lang } },
|
|
45
|
+
...description !== void 0 ? [{ tag: "meta", attrs: { property: "og:description", content: description } }] : [],
|
|
46
|
+
{ tag: "meta", attrs: { property: "og:site_name", content: siteTitle } },
|
|
47
|
+
// Twitter Tags
|
|
48
|
+
{
|
|
49
|
+
tag: "meta",
|
|
50
|
+
attrs: { name: "twitter:card", content: "summary_large_image" }
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
if (description)
|
|
54
|
+
headDefaults.push({
|
|
55
|
+
tag: "meta",
|
|
56
|
+
attrs: { name: "description", content: description }
|
|
57
|
+
});
|
|
58
|
+
if (canonical && config.isMultilingual) {
|
|
59
|
+
for (const locale in config.locales) {
|
|
60
|
+
const localeOpts = config.locales[locale];
|
|
61
|
+
if (!localeOpts) continue;
|
|
62
|
+
headDefaults.push({
|
|
63
|
+
tag: "link",
|
|
64
|
+
attrs: {
|
|
65
|
+
rel: "alternate",
|
|
66
|
+
hreflang: localeOpts.lang,
|
|
67
|
+
href: localizedUrl(canonical, locale, project.trailingSlash).href
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (context.site) {
|
|
73
|
+
headDefaults.push({
|
|
74
|
+
tag: "link",
|
|
75
|
+
attrs: {
|
|
76
|
+
rel: "sitemap",
|
|
77
|
+
href: fileWithBase("/sitemap-index.xml")
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const twitterLink = config.social?.find(({ icon }) => icon === "twitter" || icon === "x.com");
|
|
82
|
+
if (twitterLink) {
|
|
83
|
+
headDefaults.push({
|
|
84
|
+
tag: "meta",
|
|
85
|
+
attrs: {
|
|
86
|
+
name: "twitter:site",
|
|
87
|
+
content: new URL(twitterLink.href).pathname.replace("/", "@")
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return createHead(headDefaults, config.head, data.head);
|
|
92
|
+
}
|
|
93
|
+
function createHead(defaults, ...heads) {
|
|
94
|
+
let head = HeadSchema.parse(defaults);
|
|
95
|
+
for (const next of heads) {
|
|
96
|
+
head = mergeHead(head, next);
|
|
97
|
+
}
|
|
98
|
+
return sortHead(head);
|
|
99
|
+
}
|
|
100
|
+
function hasTag(head, entry) {
|
|
101
|
+
switch (entry.tag) {
|
|
102
|
+
case "title":
|
|
103
|
+
return head.some(({ tag }) => tag === "title");
|
|
104
|
+
case "meta":
|
|
105
|
+
return hasOneOf(head, entry, ["name", "property", "http-equiv"]);
|
|
106
|
+
case "link":
|
|
107
|
+
return head.some(
|
|
108
|
+
({ attrs }) => entry.attrs?.rel === "canonical" && attrs?.rel === "canonical" || entry.attrs?.rel === "sitemap" && attrs?.rel === "sitemap"
|
|
109
|
+
);
|
|
110
|
+
default:
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function hasOneOf(head, entry, keys) {
|
|
115
|
+
const attr = getAttr(keys, entry);
|
|
116
|
+
if (!attr) return false;
|
|
117
|
+
const [key, val] = attr;
|
|
118
|
+
return head.some(({ tag, attrs }) => tag === entry.tag && attrs?.[key] === val);
|
|
119
|
+
}
|
|
120
|
+
function getAttr(keys, entry) {
|
|
121
|
+
let attr;
|
|
122
|
+
for (const key of keys) {
|
|
123
|
+
const val = entry.attrs?.[key];
|
|
124
|
+
if (val) {
|
|
125
|
+
attr = [key, val];
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return attr;
|
|
130
|
+
}
|
|
131
|
+
function mergeHead(oldHead, newHead) {
|
|
132
|
+
return [...oldHead.filter((tag) => !hasTag(newHead, tag)), ...newHead];
|
|
133
|
+
}
|
|
134
|
+
function sortHead(head) {
|
|
135
|
+
return head.sort((a, b) => {
|
|
136
|
+
const aImportance = getImportance(a);
|
|
137
|
+
const bImportance = getImportance(b);
|
|
138
|
+
return aImportance > bImportance ? -1 : bImportance > aImportance ? 1 : 0;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function getImportance(entry) {
|
|
142
|
+
if (entry.tag === "meta" && entry.attrs && ("charset" in entry.attrs || "http-equiv" in entry.attrs || entry.attrs.name === "viewport")) {
|
|
143
|
+
return 100;
|
|
144
|
+
}
|
|
145
|
+
if (entry.tag === "title") return 90;
|
|
146
|
+
if (entry.tag !== "meta") {
|
|
147
|
+
if (entry.tag === "link" && entry.attrs && "rel" in entry.attrs && entry.attrs.rel === "shortcut icon") {
|
|
148
|
+
return 70;
|
|
149
|
+
}
|
|
150
|
+
return 80;
|
|
151
|
+
}
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
getHead
|
|
156
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { AstroError } from "astro/errors";
|
|
2
|
+
const wellKnownRTL = ["ar", "fa", "he", "prs", "ps", "syc", "ug", "ur"];
|
|
3
|
+
const BuiltInDefaultLocale = { ...getLocaleInfo("en"), lang: "en" };
|
|
4
|
+
function processI18nConfig(starlightConfig, astroI18nConfig) {
|
|
5
|
+
if (astroI18nConfig && !starlightConfig.isUsingBuiltInDefaultLocale) {
|
|
6
|
+
throw new AstroError(
|
|
7
|
+
"Cannot provide both an Astro `i18n` configuration and a Starlight `locales` configuration.",
|
|
8
|
+
"Remove one of the two configurations.\nSee more at https://starlight.astro.build/guides/i18n/"
|
|
9
|
+
);
|
|
10
|
+
} else if (astroI18nConfig) {
|
|
11
|
+
return {
|
|
12
|
+
astroI18nConfig,
|
|
13
|
+
starlightConfig: {
|
|
14
|
+
...starlightConfig,
|
|
15
|
+
...getStarlightI18nConfig(astroI18nConfig)
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return { astroI18nConfig: getAstroI18nConfig(starlightConfig), starlightConfig };
|
|
20
|
+
}
|
|
21
|
+
function getAstroI18nConfig(config) {
|
|
22
|
+
return {
|
|
23
|
+
// When using custom locale `path`s, the default locale must match one of these paths.
|
|
24
|
+
// In Starlight, this matches the `locale` property if defined, and we fallback to the `lang`
|
|
25
|
+
// property if not (which would be set to the language’s directory name by default).
|
|
26
|
+
defaultLocale: (
|
|
27
|
+
// If the default locale is explicitly set to `root`, we use the `lang` property instead.
|
|
28
|
+
(config.defaultLocale.locale === "root" ? config.defaultLocale.lang : config.defaultLocale.locale ?? config.defaultLocale.lang) ?? BuiltInDefaultLocale.lang
|
|
29
|
+
),
|
|
30
|
+
locales: config.locales ? Object.entries(config.locales).map(([locale, localeConfig]) => {
|
|
31
|
+
return {
|
|
32
|
+
codes: [localeConfig?.lang ?? locale],
|
|
33
|
+
path: locale === "root" ? localeConfig?.lang ?? BuiltInDefaultLocale.lang : locale
|
|
34
|
+
};
|
|
35
|
+
}) : [config.defaultLocale.lang],
|
|
36
|
+
routing: {
|
|
37
|
+
prefixDefaultLocale: (
|
|
38
|
+
// Sites with multiple languages without a root locale.
|
|
39
|
+
config.isMultilingual && config.locales?.root === void 0 || // Sites with a single non-root language different from the built-in default locale.
|
|
40
|
+
!config.isMultilingual && config.locales !== void 0
|
|
41
|
+
),
|
|
42
|
+
redirectToDefaultLocale: false,
|
|
43
|
+
fallbackType: "redirect"
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function getStarlightI18nConfig(astroI18nConfig) {
|
|
48
|
+
if (astroI18nConfig.routing === "manual") {
|
|
49
|
+
throw new AstroError(
|
|
50
|
+
"Starlight is not compatible with the `manual` routing option in the Astro i18n configuration."
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const prefixDefaultLocale = astroI18nConfig.routing.prefixDefaultLocale;
|
|
54
|
+
const isMultilingual = astroI18nConfig.locales.length > 1;
|
|
55
|
+
const isMonolingualWithRootLocale = !isMultilingual && !prefixDefaultLocale;
|
|
56
|
+
const locales = isMonolingualWithRootLocale ? void 0 : Object.fromEntries(
|
|
57
|
+
astroI18nConfig.locales.map((locale) => [
|
|
58
|
+
isDefaultAstroLocale(astroI18nConfig, locale) && !prefixDefaultLocale ? "root" : isAstroLocaleExtendedConfig(locale) ? locale.path : locale,
|
|
59
|
+
inferStarlightLocaleFromAstroLocale(locale)
|
|
60
|
+
])
|
|
61
|
+
);
|
|
62
|
+
const defaultAstroLocale = astroI18nConfig.locales.find(
|
|
63
|
+
(locale) => isDefaultAstroLocale(astroI18nConfig, locale)
|
|
64
|
+
);
|
|
65
|
+
if (!defaultAstroLocale) {
|
|
66
|
+
throw new AstroError(
|
|
67
|
+
"Astro default locale not found.",
|
|
68
|
+
"This should never happen. Please open a new issue: https://github.com/withastro/starlight/issues/new?template=---01-bug-report.yml"
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
isMultilingual,
|
|
73
|
+
locales,
|
|
74
|
+
defaultLocale: {
|
|
75
|
+
...inferStarlightLocaleFromAstroLocale(defaultAstroLocale),
|
|
76
|
+
locale: isMonolingualWithRootLocale || isMultilingual && !prefixDefaultLocale ? void 0 : isAstroLocaleExtendedConfig(defaultAstroLocale) ? defaultAstroLocale.codes[0] : defaultAstroLocale
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function inferStarlightLocaleFromAstroLocale(astroLocale) {
|
|
81
|
+
const lang = isAstroLocaleExtendedConfig(astroLocale) ? astroLocale.codes[0] : astroLocale;
|
|
82
|
+
return { ...getLocaleInfo(lang), lang };
|
|
83
|
+
}
|
|
84
|
+
function isDefaultAstroLocale(astroI18nConfig, locale) {
|
|
85
|
+
return (isAstroLocaleExtendedConfig(locale) ? locale.path : locale) === astroI18nConfig.defaultLocale;
|
|
86
|
+
}
|
|
87
|
+
function isAstroLocaleExtendedConfig(locale) {
|
|
88
|
+
return typeof locale !== "string";
|
|
89
|
+
}
|
|
90
|
+
function getLocaleInfo(lang) {
|
|
91
|
+
try {
|
|
92
|
+
const locale = new Intl.Locale(lang);
|
|
93
|
+
const label = new Intl.DisplayNames(locale, { type: "language" }).of(lang);
|
|
94
|
+
if (!label || lang === label) throw new Error("Label not found.");
|
|
95
|
+
return {
|
|
96
|
+
label: label[0]?.toLocaleUpperCase(locale) + label.slice(1),
|
|
97
|
+
dir: getLocaleDir(locale)
|
|
98
|
+
};
|
|
99
|
+
} catch {
|
|
100
|
+
throw new AstroError(
|
|
101
|
+
`Failed to get locale information for the '${lang}' locale.`,
|
|
102
|
+
"Make sure to provide a valid BCP-47 tags (e.g. en, ar, or zh-CN)."
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function getLocaleDir(locale) {
|
|
107
|
+
if ("textInfo" in locale) {
|
|
108
|
+
return locale.textInfo.direction;
|
|
109
|
+
} else if ("getTextInfo" in locale) {
|
|
110
|
+
return locale.getTextInfo().direction;
|
|
111
|
+
}
|
|
112
|
+
return wellKnownRTL.includes(locale.language) ? "rtl" : "ltr";
|
|
113
|
+
}
|
|
114
|
+
function pickLang(dictionary, lang) {
|
|
115
|
+
return dictionary[lang];
|
|
116
|
+
}
|
|
117
|
+
export {
|
|
118
|
+
BuiltInDefaultLocale,
|
|
119
|
+
pickLang,
|
|
120
|
+
processI18nConfig
|
|
121
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import config from "virtual:starlight/user-config";
|
|
2
|
+
import { stripTrailingSlash } from "./path.js";
|
|
3
|
+
function localizedUrl(url, locale, trailingSlash) {
|
|
4
|
+
url = new URL(url);
|
|
5
|
+
if (!config.locales) {
|
|
6
|
+
return url;
|
|
7
|
+
}
|
|
8
|
+
if (locale === "root") locale = "";
|
|
9
|
+
const base = stripTrailingSlash(import.meta.env.BASE_URL);
|
|
10
|
+
const hasBase = url.pathname.startsWith(base);
|
|
11
|
+
if (hasBase) url.pathname = url.pathname.replace(base, "");
|
|
12
|
+
const [_leadingSlash, baseSegment] = url.pathname.split("/");
|
|
13
|
+
const htmlExt = ".html";
|
|
14
|
+
const isRootHtml = baseSegment?.endsWith(htmlExt);
|
|
15
|
+
const baseSlug = isRootHtml ? baseSegment?.slice(0, -1 * htmlExt.length) : baseSegment;
|
|
16
|
+
if (baseSlug && baseSlug in config.locales) {
|
|
17
|
+
if (locale) {
|
|
18
|
+
url.pathname = url.pathname.replace(baseSlug, locale);
|
|
19
|
+
} else if (isRootHtml) {
|
|
20
|
+
url.pathname = "/index.html";
|
|
21
|
+
} else {
|
|
22
|
+
url.pathname = url.pathname.replace("/" + baseSlug, "");
|
|
23
|
+
}
|
|
24
|
+
} else if (locale) {
|
|
25
|
+
if (baseSegment === "index.html") {
|
|
26
|
+
url.pathname = "/" + locale + ".html";
|
|
27
|
+
} else {
|
|
28
|
+
url.pathname = "/" + locale + url.pathname;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (hasBase) url.pathname = base + url.pathname;
|
|
32
|
+
if (trailingSlash === "never") url.pathname = stripTrailingSlash(url.pathname);
|
|
33
|
+
return url;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
localizedUrl
|
|
37
|
+
};
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { AstroError } from "astro/errors";
|
|
2
|
+
import project from "virtual:starlight/project-context";
|
|
3
|
+
import config from "virtual:starlight/user-config";
|
|
4
|
+
import { getCollectionPathFromRoot } from "./collection.js";
|
|
5
|
+
import { createPathFormatter } from "./createPathFormatter.js";
|
|
6
|
+
import { formatPath } from "./format-path.js";
|
|
7
|
+
import { BuiltInDefaultLocale, pickLang } from "./i18n.js";
|
|
8
|
+
import {
|
|
9
|
+
ensureLeadingSlash,
|
|
10
|
+
ensureTrailingSlash,
|
|
11
|
+
stripExtension,
|
|
12
|
+
stripLeadingAndTrailingSlashes
|
|
13
|
+
} from "./path.js";
|
|
14
|
+
import { getLocaleRoutes, routes } from "./routing.js";
|
|
15
|
+
import { localeToLang, localizedId, slugToPathname } from "./slugs.js";
|
|
16
|
+
import { isAbsoluteUrl } from "./url.js";
|
|
17
|
+
const DirKey = /* @__PURE__ */ Symbol("DirKey");
|
|
18
|
+
const SlugKey = /* @__PURE__ */ Symbol("SlugKey");
|
|
19
|
+
const neverPathFormatter = createPathFormatter({ trailingSlash: "never" });
|
|
20
|
+
const docsCollectionPathFromRoot = getCollectionPathFromRoot("docs", project);
|
|
21
|
+
function makeDir(slug) {
|
|
22
|
+
const dir = {};
|
|
23
|
+
Object.defineProperty(dir, DirKey, { enumerable: false });
|
|
24
|
+
Object.defineProperty(dir, SlugKey, { value: slug, enumerable: false });
|
|
25
|
+
return dir;
|
|
26
|
+
}
|
|
27
|
+
function isDir(data) {
|
|
28
|
+
return DirKey in data;
|
|
29
|
+
}
|
|
30
|
+
function configItemToEntry(item, currentPathname, locale, routes2) {
|
|
31
|
+
if ("link" in item) {
|
|
32
|
+
return linkFromSidebarLinkItem(item, locale);
|
|
33
|
+
} else if ("autogenerate" in item) {
|
|
34
|
+
return groupFromAutogenerateConfig(item, locale, routes2, currentPathname);
|
|
35
|
+
} else if ("slug" in item) {
|
|
36
|
+
return linkFromInternalSidebarLinkItem(item, locale);
|
|
37
|
+
} else {
|
|
38
|
+
const label = pickLang(item.translations, localeToLang(locale)) || item.label;
|
|
39
|
+
return {
|
|
40
|
+
type: "group",
|
|
41
|
+
label,
|
|
42
|
+
entries: item.items.map((i) => configItemToEntry(i, currentPathname, locale, routes2)),
|
|
43
|
+
collapsed: item.collapsed,
|
|
44
|
+
badge: getSidebarBadge(item.badge, locale, label)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function groupFromAutogenerateConfig(item, locale, routes2, currentPathname) {
|
|
49
|
+
const { attrs, collapsed: subgroupCollapsed, directory } = item.autogenerate;
|
|
50
|
+
const localeDir = locale ? locale + "/" + directory : directory;
|
|
51
|
+
const dirDocs = routes2.filter((doc) => {
|
|
52
|
+
const filePathFromContentDir = getRoutePathRelativeToCollectionRoot(doc, locale);
|
|
53
|
+
return (
|
|
54
|
+
// Match against `foo.md` or `foo/index.md`.
|
|
55
|
+
stripExtension(filePathFromContentDir) === localeDir || // Match against `foo/anything/else.md`.
|
|
56
|
+
filePathFromContentDir.startsWith(localeDir + "/")
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
const tree = treeify(dirDocs, locale, localeDir);
|
|
60
|
+
const label = pickLang(item.translations, localeToLang(locale)) || item.label;
|
|
61
|
+
return {
|
|
62
|
+
type: "group",
|
|
63
|
+
label,
|
|
64
|
+
entries: sidebarFromDir(
|
|
65
|
+
tree,
|
|
66
|
+
currentPathname,
|
|
67
|
+
locale,
|
|
68
|
+
subgroupCollapsed ?? item.collapsed,
|
|
69
|
+
attrs
|
|
70
|
+
),
|
|
71
|
+
collapsed: item.collapsed,
|
|
72
|
+
badge: getSidebarBadge(item.badge, locale, label)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function linkFromSidebarLinkItem(item, locale) {
|
|
76
|
+
let href = item.link;
|
|
77
|
+
if (!isAbsoluteUrl(href)) {
|
|
78
|
+
href = ensureLeadingSlash(href);
|
|
79
|
+
if (locale) href = "/" + locale + href;
|
|
80
|
+
}
|
|
81
|
+
const label = pickLang(item.translations, localeToLang(locale)) || item.label;
|
|
82
|
+
return makeSidebarLink(href, label, getSidebarBadge(item.badge, locale, label), item.attrs);
|
|
83
|
+
}
|
|
84
|
+
function linkFromInternalSidebarLinkItem(item, locale) {
|
|
85
|
+
const slug = item.slug === "index" ? "" : item.slug;
|
|
86
|
+
const localizedSlug = locale ? slug ? locale + "/" + slug : locale : slug;
|
|
87
|
+
const route = routes.find((entry) => localizedSlug === entry.slug);
|
|
88
|
+
if (!route) {
|
|
89
|
+
const hasExternalSlashes = item.slug.at(0) === "/" || item.slug.at(-1) === "/";
|
|
90
|
+
if (hasExternalSlashes) {
|
|
91
|
+
throw new AstroError(
|
|
92
|
+
`The slug \`"${item.slug}"\` specified in the Starlight sidebar config must not start or end with a slash.`,
|
|
93
|
+
`Please try updating \`"${item.slug}"\` to \`"${stripLeadingAndTrailingSlashes(item.slug)}"\`.`
|
|
94
|
+
);
|
|
95
|
+
} else {
|
|
96
|
+
throw new AstroError(
|
|
97
|
+
`The slug \`"${item.slug}"\` specified in the Starlight sidebar config does not exist.`,
|
|
98
|
+
"Update the Starlight config to reference a valid entry slug in the docs content collection.\nLearn more about Astro content collection slugs at https://docs.astro.build/en/reference/modules/astro-content/#getentry"
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const frontmatter = route.entry.data;
|
|
103
|
+
const label = pickLang(item.translations, localeToLang(locale)) || item.label || frontmatter.sidebar?.label || frontmatter.title;
|
|
104
|
+
const badge = item.badge ?? frontmatter.sidebar?.badge;
|
|
105
|
+
const attrs = { ...frontmatter.sidebar?.attrs, ...item.attrs };
|
|
106
|
+
return makeSidebarLink(
|
|
107
|
+
slugToPathname(route.slug),
|
|
108
|
+
label,
|
|
109
|
+
getSidebarBadge(badge, locale, label),
|
|
110
|
+
attrs
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
function makeSidebarLink(href, label, badge, attrs) {
|
|
114
|
+
if (!isAbsoluteUrl(href)) {
|
|
115
|
+
href = formatPath(href);
|
|
116
|
+
}
|
|
117
|
+
return makeLink({ label, href, badge, attrs });
|
|
118
|
+
}
|
|
119
|
+
function makeLink({
|
|
120
|
+
attrs = {},
|
|
121
|
+
badge = void 0,
|
|
122
|
+
...opts
|
|
123
|
+
}) {
|
|
124
|
+
return { type: "link", ...opts, badge, isCurrent: false, attrs };
|
|
125
|
+
}
|
|
126
|
+
function pathsMatch(pathA, pathB) {
|
|
127
|
+
return neverPathFormatter(pathA) === neverPathFormatter(pathB);
|
|
128
|
+
}
|
|
129
|
+
function getBreadcrumbs(path, baseDir) {
|
|
130
|
+
const pathWithoutExt = stripExtension(path);
|
|
131
|
+
if (pathWithoutExt === baseDir) return [];
|
|
132
|
+
baseDir = ensureTrailingSlash(baseDir);
|
|
133
|
+
const relativePath = pathWithoutExt.startsWith(baseDir) ? pathWithoutExt.replace(baseDir, "") : pathWithoutExt;
|
|
134
|
+
return relativePath.split("/");
|
|
135
|
+
}
|
|
136
|
+
function getRoutePathRelativeToCollectionRoot(route, locale) {
|
|
137
|
+
return project.legacyCollections ? route.id : (
|
|
138
|
+
// For collections with a loader, use a localized filePath relative to the collection
|
|
139
|
+
localizedId(route.entry.filePath.replace(`${docsCollectionPathFromRoot}/`, ""), locale)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
function treeify(routes2, locale, baseDir) {
|
|
143
|
+
const treeRoot = makeDir(baseDir);
|
|
144
|
+
routes2.filter((doc) => !doc.entry.data.sidebar.hidden).map((doc) => [getRoutePathRelativeToCollectionRoot(doc, locale), doc]).sort(([a], [b]) => b.split("/").length - a.split("/").length).forEach(([filePathFromContentDir, doc]) => {
|
|
145
|
+
const parts = getBreadcrumbs(filePathFromContentDir, baseDir);
|
|
146
|
+
let currentNode = treeRoot;
|
|
147
|
+
parts.forEach((part, index) => {
|
|
148
|
+
const isLeaf = index === parts.length - 1;
|
|
149
|
+
if (isLeaf && Object.hasOwn(currentNode, part)) {
|
|
150
|
+
currentNode = currentNode[part];
|
|
151
|
+
part = "index";
|
|
152
|
+
}
|
|
153
|
+
if (!isLeaf) {
|
|
154
|
+
const path = currentNode[SlugKey];
|
|
155
|
+
currentNode[part] ||= makeDir(stripLeadingAndTrailingSlashes(path + "/" + part));
|
|
156
|
+
currentNode = currentNode[part];
|
|
157
|
+
} else {
|
|
158
|
+
currentNode[part] = doc;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
return treeRoot;
|
|
163
|
+
}
|
|
164
|
+
function linkFromRoute(route, attrs) {
|
|
165
|
+
return makeSidebarLink(
|
|
166
|
+
slugToPathname(route.slug),
|
|
167
|
+
route.entry.data.sidebar.label || route.entry.data.title,
|
|
168
|
+
route.entry.data.sidebar.badge,
|
|
169
|
+
{ ...attrs, ...route.entry.data.sidebar.attrs }
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
function getOrder(routeOrDir) {
|
|
173
|
+
return isDir(routeOrDir) ? Math.min(...Object.values(routeOrDir).flatMap(getOrder)) : (
|
|
174
|
+
// If no order value is found, set it to the largest number possible.
|
|
175
|
+
routeOrDir.entry.data.sidebar.order ?? Number.MAX_VALUE
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
function sortDirEntries(dir) {
|
|
179
|
+
const collator = new Intl.Collator(localeToLang(void 0));
|
|
180
|
+
return dir.sort(([_keyA, a], [_keyB, b]) => {
|
|
181
|
+
const [aOrder, bOrder] = [getOrder(a), getOrder(b)];
|
|
182
|
+
if (aOrder !== bOrder) return aOrder < bOrder ? -1 : 1;
|
|
183
|
+
return collator.compare(isDir(a) ? a[SlugKey] : a.slug, isDir(b) ? b[SlugKey] : b.slug);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function groupFromDir(dir, fullPath, dirName, currentPathname, locale, collapsed, attrs) {
|
|
187
|
+
const entries = sortDirEntries(Object.entries(dir)).map(
|
|
188
|
+
([key, dirOrRoute]) => dirToItem(dirOrRoute, `${fullPath}/${key}`, key, currentPathname, locale, collapsed, attrs)
|
|
189
|
+
);
|
|
190
|
+
return {
|
|
191
|
+
type: "group",
|
|
192
|
+
label: dirName,
|
|
193
|
+
entries,
|
|
194
|
+
collapsed,
|
|
195
|
+
badge: void 0
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function dirToItem(dirOrRoute, fullPath, dirName, currentPathname, locale, collapsed, attrs) {
|
|
199
|
+
return isDir(dirOrRoute) ? groupFromDir(dirOrRoute, fullPath, dirName, currentPathname, locale, collapsed, attrs) : linkFromRoute(dirOrRoute, attrs);
|
|
200
|
+
}
|
|
201
|
+
function sidebarFromDir(tree, currentPathname, locale, collapsed, attrs) {
|
|
202
|
+
return sortDirEntries(Object.entries(tree)).map(
|
|
203
|
+
([key, dirOrRoute]) => dirToItem(dirOrRoute, key, key, currentPathname, locale, collapsed, attrs)
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
const intermediateSidebars = /* @__PURE__ */ new Map();
|
|
207
|
+
function getSidebar(pathname, locale) {
|
|
208
|
+
let intermediateSidebar = intermediateSidebars.get(locale);
|
|
209
|
+
if (!intermediateSidebar) {
|
|
210
|
+
intermediateSidebar = getIntermediateSidebarFromConfig(config.sidebar, pathname, locale);
|
|
211
|
+
intermediateSidebars.set(locale, intermediateSidebar);
|
|
212
|
+
}
|
|
213
|
+
return getSidebarFromIntermediateSidebar(intermediateSidebar, pathname);
|
|
214
|
+
}
|
|
215
|
+
function getSidebarFromConfig(sidebarConfig, pathname, locale) {
|
|
216
|
+
const intermediateSidebar = getIntermediateSidebarFromConfig(sidebarConfig, pathname, locale);
|
|
217
|
+
return getSidebarFromIntermediateSidebar(intermediateSidebar, pathname);
|
|
218
|
+
}
|
|
219
|
+
function getIntermediateSidebarFromConfig(sidebarConfig, pathname, locale) {
|
|
220
|
+
const routes2 = getLocaleRoutes(locale);
|
|
221
|
+
if (sidebarConfig) {
|
|
222
|
+
return sidebarConfig.map((group) => configItemToEntry(group, pathname, locale, routes2));
|
|
223
|
+
} else {
|
|
224
|
+
const tree = treeify(routes2, locale, locale || "");
|
|
225
|
+
return sidebarFromDir(tree, pathname, locale, false);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function getSidebarFromIntermediateSidebar(intermediateSidebar, pathname) {
|
|
229
|
+
const sidebar = structuredClone(intermediateSidebar);
|
|
230
|
+
setIntermediateSidebarCurrentEntry(sidebar, pathname);
|
|
231
|
+
return sidebar;
|
|
232
|
+
}
|
|
233
|
+
function setIntermediateSidebarCurrentEntry(intermediateSidebar, pathname) {
|
|
234
|
+
for (const entry of intermediateSidebar) {
|
|
235
|
+
if (entry.type === "link" && pathsMatch(encodeURI(entry.href), pathname)) {
|
|
236
|
+
entry.isCurrent = true;
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
if (entry.type === "group" && setIntermediateSidebarCurrentEntry(entry.entries, pathname)) {
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
function getSidebarHash(sidebar) {
|
|
246
|
+
let hash = 0;
|
|
247
|
+
const sidebarIdentity = recursivelyBuildSidebarIdentity(sidebar);
|
|
248
|
+
for (let i = 0; i < sidebarIdentity.length; i++) {
|
|
249
|
+
const char = sidebarIdentity.charCodeAt(i);
|
|
250
|
+
hash = (hash << 5) - hash + char;
|
|
251
|
+
}
|
|
252
|
+
return (hash >>> 0).toString(36).padStart(7, "0");
|
|
253
|
+
}
|
|
254
|
+
function recursivelyBuildSidebarIdentity(sidebar) {
|
|
255
|
+
return sidebar.flatMap(
|
|
256
|
+
(entry) => entry.type === "group" ? entry.label + recursivelyBuildSidebarIdentity(entry.entries) : entry.label + entry.href
|
|
257
|
+
).join("");
|
|
258
|
+
}
|
|
259
|
+
function flattenSidebar(sidebar) {
|
|
260
|
+
return sidebar.flatMap(
|
|
261
|
+
(entry) => entry.type === "group" ? flattenSidebar(entry.entries) : entry
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
function getPrevNextLinks(sidebar, paginationEnabled, config2) {
|
|
265
|
+
const entries = flattenSidebar(sidebar);
|
|
266
|
+
const currentIndex = entries.findIndex((entry) => entry.isCurrent);
|
|
267
|
+
const prev = applyPrevNextLinkConfig(entries[currentIndex - 1], paginationEnabled, config2.prev);
|
|
268
|
+
const next = applyPrevNextLinkConfig(
|
|
269
|
+
currentIndex > -1 ? entries[currentIndex + 1] : void 0,
|
|
270
|
+
paginationEnabled,
|
|
271
|
+
config2.next
|
|
272
|
+
);
|
|
273
|
+
return { prev, next };
|
|
274
|
+
}
|
|
275
|
+
function applyPrevNextLinkConfig(link, paginationEnabled, config2) {
|
|
276
|
+
if (config2 === false) return void 0;
|
|
277
|
+
else if (config2 === true) return link;
|
|
278
|
+
else if (typeof config2 === "string" && link) {
|
|
279
|
+
return { ...link, label: config2 };
|
|
280
|
+
} else if (typeof config2 === "object") {
|
|
281
|
+
if (link) {
|
|
282
|
+
return {
|
|
283
|
+
...link,
|
|
284
|
+
label: config2.label ?? link.label,
|
|
285
|
+
href: config2.link ?? link.href,
|
|
286
|
+
// Explicitly remove sidebar link attributes for prev/next links.
|
|
287
|
+
attrs: {}
|
|
288
|
+
};
|
|
289
|
+
} else if (config2.link && config2.label) {
|
|
290
|
+
return makeLink({ href: config2.link, label: config2.label });
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return paginationEnabled ? link : void 0;
|
|
294
|
+
}
|
|
295
|
+
function getSidebarBadge(config2, locale, itemLabel) {
|
|
296
|
+
if (!config2) return;
|
|
297
|
+
if (typeof config2 === "string") {
|
|
298
|
+
return { variant: "default", text: config2 };
|
|
299
|
+
}
|
|
300
|
+
return { ...config2, text: getSidebarBadgeText(config2.text, locale, itemLabel) };
|
|
301
|
+
}
|
|
302
|
+
function getSidebarBadgeText(text, locale, itemLabel) {
|
|
303
|
+
if (typeof text === "string") return text;
|
|
304
|
+
const defaultLang = config.defaultLocale?.lang || config.defaultLocale?.locale || BuiltInDefaultLocale.lang;
|
|
305
|
+
const defaultText = text[defaultLang];
|
|
306
|
+
if (!defaultText) {
|
|
307
|
+
throw new AstroError(
|
|
308
|
+
`The badge text for "${itemLabel}" must have a key for the default language "${defaultLang}".`,
|
|
309
|
+
"Update the Starlight config to include a badge text for the default language.\nLearn more about sidebar badges internationalization at https://starlight.astro.build/guides/sidebar/#internationalization-with-badges"
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
return pickLang(text, localeToLang(locale)) || defaultText;
|
|
313
|
+
}
|
|
314
|
+
export {
|
|
315
|
+
flattenSidebar,
|
|
316
|
+
getPrevNextLinks,
|
|
317
|
+
getSidebar,
|
|
318
|
+
getSidebarFromConfig,
|
|
319
|
+
getSidebarHash
|
|
320
|
+
};
|