@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,52 @@
|
|
|
1
|
+
function ensureLeadingSlash(href) {
|
|
2
|
+
if (href[0] !== "/") href = "/" + href;
|
|
3
|
+
return href;
|
|
4
|
+
}
|
|
5
|
+
function ensureTrailingSlash(href) {
|
|
6
|
+
if (href[href.length - 1] !== "/") href += "/";
|
|
7
|
+
return href;
|
|
8
|
+
}
|
|
9
|
+
function ensureLeadingAndTrailingSlashes(href) {
|
|
10
|
+
href = ensureLeadingSlash(href);
|
|
11
|
+
href = ensureTrailingSlash(href);
|
|
12
|
+
return href;
|
|
13
|
+
}
|
|
14
|
+
function stripLeadingSlash(href) {
|
|
15
|
+
if (href[0] === "/") href = href.slice(1);
|
|
16
|
+
return href;
|
|
17
|
+
}
|
|
18
|
+
function stripTrailingSlash(href) {
|
|
19
|
+
if (href[href.length - 1] === "/") href = href.slice(0, -1);
|
|
20
|
+
return href;
|
|
21
|
+
}
|
|
22
|
+
function stripLeadingAndTrailingSlashes(href) {
|
|
23
|
+
href = stripLeadingSlash(href);
|
|
24
|
+
href = stripTrailingSlash(href);
|
|
25
|
+
return href;
|
|
26
|
+
}
|
|
27
|
+
function stripHtmlExtension(path) {
|
|
28
|
+
const pathWithoutTrailingSlash = stripTrailingSlash(path);
|
|
29
|
+
return pathWithoutTrailingSlash.endsWith(".html") ? pathWithoutTrailingSlash.slice(0, -5) : path;
|
|
30
|
+
}
|
|
31
|
+
function ensureHtmlExtension(path) {
|
|
32
|
+
path = stripLeadingAndTrailingSlashes(path);
|
|
33
|
+
if (!path.endsWith(".html")) {
|
|
34
|
+
path = path ? path + ".html" : "/index.html";
|
|
35
|
+
}
|
|
36
|
+
return ensureLeadingSlash(path);
|
|
37
|
+
}
|
|
38
|
+
function stripExtension(path) {
|
|
39
|
+
const periodIndex = path.lastIndexOf(".");
|
|
40
|
+
return path.slice(0, periodIndex > -1 ? periodIndex : void 0);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
ensureHtmlExtension,
|
|
44
|
+
ensureLeadingAndTrailingSlashes,
|
|
45
|
+
ensureLeadingSlash,
|
|
46
|
+
ensureTrailingSlash,
|
|
47
|
+
stripExtension,
|
|
48
|
+
stripHtmlExtension,
|
|
49
|
+
stripLeadingAndTrailingSlashes,
|
|
50
|
+
stripLeadingSlash,
|
|
51
|
+
stripTrailingSlash
|
|
52
|
+
};
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { AstroError } from "astro/errors";
|
|
2
|
+
import { z } from "astro/zod";
|
|
3
|
+
import { parseWithFriendlyErrors } from "../utils/error-map.js";
|
|
4
|
+
import {
|
|
5
|
+
StarlightConfigSchema
|
|
6
|
+
} from "../utils/user-config.js";
|
|
7
|
+
import { createTranslationSystemFromFs } from "./translations-fs.js";
|
|
8
|
+
import { absolutePathToLang as getAbsolutePathFromLang } from "../integrations/shared/absolutePathToLang.js";
|
|
9
|
+
import { getCollectionPosixPath } from "./collection-fs.js";
|
|
10
|
+
async function runPlugins(starlightUserConfig, pluginsUserConfig, context) {
|
|
11
|
+
let userConfig = starlightUserConfig;
|
|
12
|
+
let starlightConfig = parseWithFriendlyErrors(
|
|
13
|
+
StarlightConfigSchema,
|
|
14
|
+
userConfig,
|
|
15
|
+
"Invalid config passed to starlight integration"
|
|
16
|
+
);
|
|
17
|
+
const pluginsConfig = parseWithFriendlyErrors(
|
|
18
|
+
starlightPluginsConfigSchema,
|
|
19
|
+
pluginsUserConfig,
|
|
20
|
+
"Invalid plugins config passed to starlight integration"
|
|
21
|
+
);
|
|
22
|
+
const pluginTranslations = {};
|
|
23
|
+
const routeMiddlewareConfigs = [];
|
|
24
|
+
for (const {
|
|
25
|
+
hooks: { "i18n:setup": i18nSetup }
|
|
26
|
+
} of pluginsConfig) {
|
|
27
|
+
if (i18nSetup) {
|
|
28
|
+
await i18nSetup({
|
|
29
|
+
injectTranslations(translations) {
|
|
30
|
+
for (const [locale, localeTranslations] of Object.entries(translations)) {
|
|
31
|
+
pluginTranslations[locale] ??= {};
|
|
32
|
+
Object.assign(pluginTranslations[locale], localeTranslations);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const useTranslations = await createTranslationSystemFromFs(
|
|
39
|
+
starlightConfig,
|
|
40
|
+
context.config,
|
|
41
|
+
pluginTranslations
|
|
42
|
+
);
|
|
43
|
+
function absolutePathToLang(path) {
|
|
44
|
+
return getAbsolutePathFromLang(path, {
|
|
45
|
+
docsPath: getCollectionPosixPath("docs", context.config.srcDir),
|
|
46
|
+
starlightConfig
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const integrations = [];
|
|
50
|
+
for (const {
|
|
51
|
+
name,
|
|
52
|
+
hooks: { "config:setup": configSetup, setup: deprecatedSetup }
|
|
53
|
+
} of pluginsConfig) {
|
|
54
|
+
const setup = configSetup ?? deprecatedSetup;
|
|
55
|
+
await setup({
|
|
56
|
+
config: pluginsUserConfig ? { ...userConfig, plugins: pluginsUserConfig } : userConfig,
|
|
57
|
+
updateConfig(newConfig) {
|
|
58
|
+
if ("plugins" in newConfig) {
|
|
59
|
+
throw new AstroError(
|
|
60
|
+
`The \`${name}\` plugin tried to update the \`plugins\` config key which is not supported.`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if ("routeMiddleware" in newConfig) {
|
|
64
|
+
throw new AstroError(
|
|
65
|
+
`The \`${name}\` plugin tried to update the \`routeMiddleware\` config key which is not supported.`,
|
|
66
|
+
"Use the `addRouteMiddleware()` utility instead.\nSee https://starlight.astro.build/reference/plugins/#addroutemiddleware for more details."
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const mergedUserConfig = { ...userConfig, ...newConfig };
|
|
70
|
+
const mergedConfig = parseWithFriendlyErrors(
|
|
71
|
+
StarlightConfigSchema,
|
|
72
|
+
mergedUserConfig,
|
|
73
|
+
`Invalid config update provided by the '${name}' plugin`
|
|
74
|
+
);
|
|
75
|
+
userConfig = mergedUserConfig;
|
|
76
|
+
starlightConfig = mergedConfig;
|
|
77
|
+
},
|
|
78
|
+
addIntegration(integration) {
|
|
79
|
+
integrations.push(integration);
|
|
80
|
+
},
|
|
81
|
+
addRouteMiddleware(middlewareConfig) {
|
|
82
|
+
routeMiddlewareConfigs.push(middlewareConfig);
|
|
83
|
+
},
|
|
84
|
+
astroConfig: {
|
|
85
|
+
...context.config,
|
|
86
|
+
integrations: [...context.config.integrations, ...integrations]
|
|
87
|
+
},
|
|
88
|
+
command: context.command,
|
|
89
|
+
isRestart: context.isRestart,
|
|
90
|
+
logger: context.logger.fork(name),
|
|
91
|
+
useTranslations,
|
|
92
|
+
absolutePathToLang
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
applyPluginMiddleware(routeMiddlewareConfigs, starlightConfig);
|
|
96
|
+
return { integrations, starlightConfig, pluginTranslations, useTranslations, absolutePathToLang };
|
|
97
|
+
}
|
|
98
|
+
function applyPluginMiddleware(routeMiddlewareConfigs, starlightConfig) {
|
|
99
|
+
const middlewareBuckets = routeMiddlewareConfigs.reduce(
|
|
100
|
+
(buckets, { entrypoint, order = "default" }) => {
|
|
101
|
+
buckets[order].push(entrypoint);
|
|
102
|
+
return buckets;
|
|
103
|
+
},
|
|
104
|
+
{ pre: [], default: [], post: [] }
|
|
105
|
+
);
|
|
106
|
+
starlightConfig.routeMiddleware.unshift(...middlewareBuckets.pre);
|
|
107
|
+
starlightConfig.routeMiddleware.push(...middlewareBuckets.default, ...middlewareBuckets.post);
|
|
108
|
+
}
|
|
109
|
+
function injectPluginTranslationsTypes(translations, injectTypes) {
|
|
110
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
111
|
+
for (const localeTranslations of Object.values(translations)) {
|
|
112
|
+
for (const key of Object.keys(localeTranslations)) {
|
|
113
|
+
allKeys.add(key);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (allKeys.size === 0) return;
|
|
117
|
+
injectTypes({
|
|
118
|
+
filename: "i18n-plugins.d.ts",
|
|
119
|
+
content: `declare namespace StarlightApp {
|
|
120
|
+
type PluginUIStringKeys = {
|
|
121
|
+
${[...allKeys].map((key) => `'${key}': string;`).join("\n ")}
|
|
122
|
+
};
|
|
123
|
+
interface I18n extends PluginUIStringKeys {}
|
|
124
|
+
}`
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const astroIntegrationSchema = z.object({
|
|
128
|
+
name: z.string(),
|
|
129
|
+
hooks: z.object({}).passthrough().default({})
|
|
130
|
+
});
|
|
131
|
+
const routeMiddlewareConfigSchema = z.object({
|
|
132
|
+
entrypoint: z.string(),
|
|
133
|
+
order: z.enum(["pre", "post", "default"]).default("default")
|
|
134
|
+
});
|
|
135
|
+
const baseStarlightPluginSchema = z.object({
|
|
136
|
+
/** Name of the Starlight plugin. */
|
|
137
|
+
name: z.string()
|
|
138
|
+
});
|
|
139
|
+
const configSetupHookSchema = z.function(
|
|
140
|
+
z.tuple([
|
|
141
|
+
z.object({
|
|
142
|
+
/**
|
|
143
|
+
* A read-only copy of the user-supplied Starlight configuration.
|
|
144
|
+
*
|
|
145
|
+
* Note that this configuration may have been updated by other plugins configured
|
|
146
|
+
* before this one.
|
|
147
|
+
*/
|
|
148
|
+
config: z.any(),
|
|
149
|
+
/**
|
|
150
|
+
* A callback function to update the user-supplied Starlight configuration.
|
|
151
|
+
*
|
|
152
|
+
* You only need to provide the configuration values that you want to update but no deep
|
|
153
|
+
* merge is performed.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* {
|
|
157
|
+
* name: 'My Starlight Plugin',
|
|
158
|
+
* hooks: {
|
|
159
|
+
* 'config:setup'({ updateConfig }) {
|
|
160
|
+
* updateConfig({
|
|
161
|
+
* description: 'Custom description',
|
|
162
|
+
* });
|
|
163
|
+
* }
|
|
164
|
+
* }
|
|
165
|
+
* }
|
|
166
|
+
*/
|
|
167
|
+
updateConfig: z.function(
|
|
168
|
+
z.tuple([
|
|
169
|
+
z.record(z.any())
|
|
170
|
+
]),
|
|
171
|
+
z.void()
|
|
172
|
+
),
|
|
173
|
+
/**
|
|
174
|
+
* A callback function to add an Astro integration required by this plugin.
|
|
175
|
+
*
|
|
176
|
+
* @see https://docs.astro.build/en/reference/integrations-reference/
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* {
|
|
180
|
+
* name: 'My Starlight Plugin',
|
|
181
|
+
* hooks: {
|
|
182
|
+
* 'config:setup'({ addIntegration }) {
|
|
183
|
+
* addIntegration({
|
|
184
|
+
* name: 'My Plugin Astro Integration',
|
|
185
|
+
* hooks: {
|
|
186
|
+
* 'astro:config:setup': () => {
|
|
187
|
+
* // …
|
|
188
|
+
* },
|
|
189
|
+
* },
|
|
190
|
+
* });
|
|
191
|
+
* }
|
|
192
|
+
* }
|
|
193
|
+
* }
|
|
194
|
+
*/
|
|
195
|
+
addIntegration: z.function(z.tuple([astroIntegrationSchema]), z.void()),
|
|
196
|
+
/**
|
|
197
|
+
* A callback function to register additional route middleware handlers.
|
|
198
|
+
*
|
|
199
|
+
* If the order of execution is important, a plugin can use the `order` option to enforce
|
|
200
|
+
* running first or last.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* {
|
|
204
|
+
* name: 'My Starlight Plugin',
|
|
205
|
+
* hooks: {
|
|
206
|
+
* setup({ addRouteMiddleware }) {
|
|
207
|
+
* addRouteMiddleware({ entrypoint: '@me/my-plugin/route-middleware' });
|
|
208
|
+
* },
|
|
209
|
+
* },
|
|
210
|
+
* }
|
|
211
|
+
*/
|
|
212
|
+
addRouteMiddleware: z.function(z.tuple([routeMiddlewareConfigSchema]), z.void()),
|
|
213
|
+
/**
|
|
214
|
+
* A read-only copy of the user-supplied Astro configuration.
|
|
215
|
+
*
|
|
216
|
+
* Note that this configuration is resolved before any other integrations have run.
|
|
217
|
+
*
|
|
218
|
+
* @see https://docs.astro.build/en/reference/integrations-reference/#config-option
|
|
219
|
+
*/
|
|
220
|
+
astroConfig: z.any(),
|
|
221
|
+
/**
|
|
222
|
+
* The command used to run Starlight.
|
|
223
|
+
*
|
|
224
|
+
* @see https://docs.astro.build/en/reference/integrations-reference/#command-option
|
|
225
|
+
*/
|
|
226
|
+
command: z.any(),
|
|
227
|
+
/**
|
|
228
|
+
* `false` when the dev server starts, `true` when a reload is triggered.
|
|
229
|
+
*
|
|
230
|
+
* @see https://docs.astro.build/en/reference/integrations-reference/#isrestart-option
|
|
231
|
+
*/
|
|
232
|
+
isRestart: z.any(),
|
|
233
|
+
/**
|
|
234
|
+
* An instance of the Astro integration logger with all logged messages prefixed with the
|
|
235
|
+
* plugin name.
|
|
236
|
+
*
|
|
237
|
+
* @see https://docs.astro.build/en/reference/integrations-reference/#astrointegrationlogger
|
|
238
|
+
*/
|
|
239
|
+
logger: z.any(),
|
|
240
|
+
/**
|
|
241
|
+
* A callback function to generate a utility function to access UI strings for a given
|
|
242
|
+
* language.
|
|
243
|
+
*
|
|
244
|
+
* @see https://starlight.astro.build/guides/i18n/#using-ui-translations
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* {
|
|
248
|
+
* name: 'My Starlight Plugin',
|
|
249
|
+
* hooks: {
|
|
250
|
+
* 'config:setup'({ useTranslations, logger }) {
|
|
251
|
+
* const t = useTranslations('en');
|
|
252
|
+
* logger.info(t('builtWithStarlight.label'));
|
|
253
|
+
* // ^ Logs 'Built with Starlight' to the console.
|
|
254
|
+
* }
|
|
255
|
+
* }
|
|
256
|
+
* }
|
|
257
|
+
*/
|
|
258
|
+
useTranslations: z.any(),
|
|
259
|
+
/**
|
|
260
|
+
* A callback function to get the language for a given absolute file path. The returned
|
|
261
|
+
* language can be used with the `useTranslations` helper to get UI strings for that
|
|
262
|
+
* language.
|
|
263
|
+
*
|
|
264
|
+
* This can be particularly useful in remark or rehype plugins to get the language for
|
|
265
|
+
* the current file being processed and use it to get the appropriate UI strings for that
|
|
266
|
+
* language.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* {
|
|
270
|
+
* name: 'My Starlight Plugin',
|
|
271
|
+
* hooks: {
|
|
272
|
+
* 'config:setup'({ absolutePathToLang, useTranslations, logger }) {
|
|
273
|
+
* const lang = absolutePathToLang('/absolute/path/to/project/src/content/docs/fr/index.mdx');
|
|
274
|
+
* const t = useTranslations(lang);
|
|
275
|
+
* logger.info(t('aside.tip'));
|
|
276
|
+
* // ^ Logs 'Astuce' to the console.
|
|
277
|
+
* }
|
|
278
|
+
* }
|
|
279
|
+
* }
|
|
280
|
+
*/
|
|
281
|
+
absolutePathToLang: z.function(z.tuple([z.string()]), z.string())
|
|
282
|
+
})
|
|
283
|
+
]),
|
|
284
|
+
z.union([z.void(), z.promise(z.void())])
|
|
285
|
+
).optional();
|
|
286
|
+
const starlightPluginSchema = baseStarlightPluginSchema.extend({
|
|
287
|
+
/** The different hooks available to the plugin. */
|
|
288
|
+
hooks: z.object({
|
|
289
|
+
/**
|
|
290
|
+
* Plugin internationalization setup function allowing to inject translations strings for the
|
|
291
|
+
* plugin in various locales. These translations will be available in the `config:setup` hook
|
|
292
|
+
* and plugin UI.
|
|
293
|
+
*/
|
|
294
|
+
"i18n:setup": z.function(
|
|
295
|
+
z.tuple([
|
|
296
|
+
z.object({
|
|
297
|
+
/**
|
|
298
|
+
* A callback function to add or update translations strings.
|
|
299
|
+
*
|
|
300
|
+
* @see https://starlight.astro.build/guides/i18n/#extend-translation-schema
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* {
|
|
304
|
+
* name: 'My Starlight Plugin',
|
|
305
|
+
* hooks: {
|
|
306
|
+
* 'i18n:setup'({ injectTranslations }) {
|
|
307
|
+
* injectTranslations({
|
|
308
|
+
* en: {
|
|
309
|
+
* 'myPlugin.doThing': 'Do the thing',
|
|
310
|
+
* },
|
|
311
|
+
* fr: {
|
|
312
|
+
* 'myPlugin.doThing': 'Faire le truc',
|
|
313
|
+
* },
|
|
314
|
+
* });
|
|
315
|
+
* }
|
|
316
|
+
* }
|
|
317
|
+
* }
|
|
318
|
+
*/
|
|
319
|
+
injectTranslations: z.function(
|
|
320
|
+
z.tuple([z.record(z.string(), z.record(z.string(), z.string()))]),
|
|
321
|
+
z.void()
|
|
322
|
+
)
|
|
323
|
+
})
|
|
324
|
+
]),
|
|
325
|
+
z.union([z.void(), z.promise(z.void())])
|
|
326
|
+
).optional(),
|
|
327
|
+
/**
|
|
328
|
+
* Plugin configuration setup function called with an object containing various values that
|
|
329
|
+
* can be used by the plugin to interact with Starlight.
|
|
330
|
+
*/
|
|
331
|
+
"config:setup": configSetupHookSchema,
|
|
332
|
+
/**
|
|
333
|
+
* @deprecated Use the `config:setup` hook instead as `setup` will be removed in a future
|
|
334
|
+
* version.
|
|
335
|
+
*/
|
|
336
|
+
setup: configSetupHookSchema
|
|
337
|
+
})
|
|
338
|
+
}).superRefine((plugin, ctx) => {
|
|
339
|
+
if (!plugin.hooks["config:setup"] && !plugin.hooks.setup) {
|
|
340
|
+
ctx.addIssue({
|
|
341
|
+
code: z.ZodIssueCode.custom,
|
|
342
|
+
message: "A plugin must define at least a `config:setup` hook."
|
|
343
|
+
});
|
|
344
|
+
} else if (plugin.hooks["config:setup"] && plugin.hooks.setup) {
|
|
345
|
+
ctx.addIssue({
|
|
346
|
+
code: z.ZodIssueCode.custom,
|
|
347
|
+
message: "A plugin cannot define both a `config:setup` and `setup` hook. As `setup` is deprecated and will be removed in a future version, consider using `config:setup` instead."
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
const starlightPluginsConfigSchema = z.array(starlightPluginSchema).default([]);
|
|
352
|
+
export {
|
|
353
|
+
injectPluginTranslationsTypes,
|
|
354
|
+
runPlugins
|
|
355
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import project from "virtual:starlight/project-context";
|
|
2
|
+
import config from "virtual:starlight/user-config";
|
|
3
|
+
import { generateToC } from "../generateToC.js";
|
|
4
|
+
import { getNewestCommitDate } from "virtual:starlight/git-info";
|
|
5
|
+
import { getPrevNextLinks, getSidebar } from "../navigation.js";
|
|
6
|
+
import { ensureTrailingSlash } from "../path.js";
|
|
7
|
+
import { getRouteBySlugParam, normalizeCollectionEntry } from "../routing.js";
|
|
8
|
+
import { formatPath } from "../format-path.js";
|
|
9
|
+
import { useTranslations } from "../translations.js";
|
|
10
|
+
import { BuiltInDefaultLocale } from "../i18n.js";
|
|
11
|
+
import { getEntry } from "astro:content";
|
|
12
|
+
import { getCollectionPathFromRoot } from "../collection.js";
|
|
13
|
+
import { getHead } from "../head.js";
|
|
14
|
+
async function getRoute(context) {
|
|
15
|
+
return "slug" in context.params && getRouteBySlugParam(context.params.slug) || await get404Route(context.locals);
|
|
16
|
+
}
|
|
17
|
+
function useRouteData(context, route, { Content, headings }) {
|
|
18
|
+
const routeData = generateRouteData({ props: { ...route, headings }, context });
|
|
19
|
+
return { ...routeData, Content };
|
|
20
|
+
}
|
|
21
|
+
function generateRouteData({
|
|
22
|
+
props,
|
|
23
|
+
context
|
|
24
|
+
}) {
|
|
25
|
+
const { entry, locale, lang } = props;
|
|
26
|
+
const sidebar = getSidebar(context.url.pathname, locale);
|
|
27
|
+
const siteTitle = getSiteTitle(lang);
|
|
28
|
+
return {
|
|
29
|
+
...props,
|
|
30
|
+
siteTitle,
|
|
31
|
+
siteTitleHref: getSiteTitleHref(locale),
|
|
32
|
+
sidebar,
|
|
33
|
+
hasSidebar: entry.data.template !== "splash",
|
|
34
|
+
pagination: getPrevNextLinks(sidebar, config.pagination, entry.data),
|
|
35
|
+
toc: getToC(props),
|
|
36
|
+
lastUpdated: getLastUpdated(props),
|
|
37
|
+
editUrl: getEditUrl(props),
|
|
38
|
+
head: getHead(props, context, siteTitle)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function getToC({ entry, lang, headings }) {
|
|
42
|
+
const tocConfig = entry.data.template === "splash" ? false : entry.data.tableOfContents !== void 0 ? entry.data.tableOfContents : config.tableOfContents;
|
|
43
|
+
if (!tocConfig) return;
|
|
44
|
+
const t = useTranslations(lang);
|
|
45
|
+
return {
|
|
46
|
+
...tocConfig,
|
|
47
|
+
items: generateToC(headings, { ...tocConfig, title: t("tableOfContents.overview") })
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function getLastUpdated({ entry }) {
|
|
51
|
+
const { lastUpdated: frontmatterLastUpdated } = entry.data;
|
|
52
|
+
const { lastUpdated: configLastUpdated } = config;
|
|
53
|
+
if (frontmatterLastUpdated ?? configLastUpdated) {
|
|
54
|
+
try {
|
|
55
|
+
return frontmatterLastUpdated instanceof Date ? frontmatterLastUpdated : getNewestCommitDate(entry.filePath);
|
|
56
|
+
} catch {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
function getEditUrl({ entry }) {
|
|
63
|
+
const { editUrl } = entry.data;
|
|
64
|
+
if (editUrl === false) return;
|
|
65
|
+
let url;
|
|
66
|
+
if (typeof editUrl === "string") {
|
|
67
|
+
url = editUrl;
|
|
68
|
+
} else if (config.editLink.baseUrl) {
|
|
69
|
+
url = ensureTrailingSlash(config.editLink.baseUrl) + entry.filePath;
|
|
70
|
+
}
|
|
71
|
+
return url ? new URL(url) : void 0;
|
|
72
|
+
}
|
|
73
|
+
function getSiteTitle(lang) {
|
|
74
|
+
const defaultLang = config.defaultLocale.lang;
|
|
75
|
+
if (lang && config.title[lang]) {
|
|
76
|
+
return config.title[lang];
|
|
77
|
+
}
|
|
78
|
+
return config.title[defaultLang];
|
|
79
|
+
}
|
|
80
|
+
function getSiteTitleHref(locale) {
|
|
81
|
+
return formatPath(locale || "/");
|
|
82
|
+
}
|
|
83
|
+
async function get404Route(locals) {
|
|
84
|
+
const { lang = BuiltInDefaultLocale.lang, dir = BuiltInDefaultLocale.dir } = config.defaultLocale || {};
|
|
85
|
+
let locale = config.defaultLocale?.locale;
|
|
86
|
+
if (locale === "root") locale = void 0;
|
|
87
|
+
const entryMeta = { dir, lang, locale };
|
|
88
|
+
const fallbackEntry = {
|
|
89
|
+
slug: "404",
|
|
90
|
+
id: "404",
|
|
91
|
+
body: "",
|
|
92
|
+
collection: "docs",
|
|
93
|
+
data: {
|
|
94
|
+
title: "404",
|
|
95
|
+
template: "splash",
|
|
96
|
+
editUrl: false,
|
|
97
|
+
head: [],
|
|
98
|
+
hero: { tagline: locals.t("404.text"), actions: [] },
|
|
99
|
+
pagefind: false,
|
|
100
|
+
sidebar: { hidden: false, attrs: {} },
|
|
101
|
+
draft: false
|
|
102
|
+
},
|
|
103
|
+
filePath: `${getCollectionPathFromRoot("docs", project)}/404.md`
|
|
104
|
+
};
|
|
105
|
+
const userEntry = await getEntry("docs", "404");
|
|
106
|
+
const entry = userEntry ? normalizeCollectionEntry(userEntry) : fallbackEntry;
|
|
107
|
+
return { ...entryMeta, entryMeta, entry, id: entry.id, slug: entry.slug };
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
generateRouteData,
|
|
111
|
+
getRoute,
|
|
112
|
+
getSiteTitle,
|
|
113
|
+
getSiteTitleHref,
|
|
114
|
+
getToC,
|
|
115
|
+
useRouteData
|
|
116
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { getCollection } from "astro:content";
|
|
2
|
+
import config from "virtual:starlight/user-config";
|
|
3
|
+
import project from "virtual:starlight/project-context";
|
|
4
|
+
import { getCollectionPathFromRoot } from "../collection.js";
|
|
5
|
+
import { localizedId, localizedSlug, slugToLocaleData, slugToParam } from "../slugs.js";
|
|
6
|
+
import { validateLogoImports } from "../validateLogoImports.js";
|
|
7
|
+
import { BuiltInDefaultLocale } from "../i18n.js";
|
|
8
|
+
validateLogoImports();
|
|
9
|
+
const normalizeIndexSlug = (slug) => slug === "index" ? "" : slug;
|
|
10
|
+
function normalizeCollectionEntry(entry) {
|
|
11
|
+
const slug = normalizeIndexSlug(entry.slug ?? entry.id);
|
|
12
|
+
return {
|
|
13
|
+
...entry,
|
|
14
|
+
// In a collection with a loader, the `id` is a slug and should be normalized.
|
|
15
|
+
id: entry.slug ? entry.id : slug,
|
|
16
|
+
// In a legacy collection, the `filePath` property doesn't exist.
|
|
17
|
+
filePath: entry.filePath ?? `${getCollectionPathFromRoot("docs", project)}/${entry.id}`,
|
|
18
|
+
// In a collection with a loader, the `slug` property is replaced by the `id`.
|
|
19
|
+
slug: normalizeIndexSlug(entry.slug ?? entry.id)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const docs = (await getCollection("docs", ({ data }) => {
|
|
23
|
+
return import.meta.env.MODE !== "production" || data.draft === false;
|
|
24
|
+
}) ?? []).map(normalizeCollectionEntry);
|
|
25
|
+
function getRoutes() {
|
|
26
|
+
const routes2 = docs.map((entry) => ({
|
|
27
|
+
entry,
|
|
28
|
+
slug: entry.slug,
|
|
29
|
+
id: entry.id,
|
|
30
|
+
entryMeta: slugToLocaleData(entry.slug),
|
|
31
|
+
...slugToLocaleData(entry.slug)
|
|
32
|
+
}));
|
|
33
|
+
if (config.isMultilingual) {
|
|
34
|
+
const defaultLocaleDocs = getLocaleDocs(
|
|
35
|
+
config.defaultLocale?.locale === "root" ? void 0 : config.defaultLocale?.locale
|
|
36
|
+
);
|
|
37
|
+
for (const key in config.locales) {
|
|
38
|
+
if (key === config.defaultLocale.locale) continue;
|
|
39
|
+
const localeConfig = config.locales[key];
|
|
40
|
+
if (!localeConfig) continue;
|
|
41
|
+
const locale = key === "root" ? void 0 : key;
|
|
42
|
+
const localeDocs = getLocaleDocs(locale);
|
|
43
|
+
for (const fallback of defaultLocaleDocs) {
|
|
44
|
+
const slug = localizedSlug(fallback.slug, locale);
|
|
45
|
+
const id = project.legacyCollections ? localizedId(fallback.id, locale) : slug;
|
|
46
|
+
const doesNotNeedFallback = localeDocs.some((doc) => doc.slug === slug);
|
|
47
|
+
if (doesNotNeedFallback) continue;
|
|
48
|
+
routes2.push({
|
|
49
|
+
entry: fallback,
|
|
50
|
+
slug,
|
|
51
|
+
id,
|
|
52
|
+
isFallback: true,
|
|
53
|
+
lang: localeConfig.lang || BuiltInDefaultLocale.lang,
|
|
54
|
+
locale,
|
|
55
|
+
dir: localeConfig.dir,
|
|
56
|
+
entryMeta: slugToLocaleData(fallback.slug)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return routes2;
|
|
62
|
+
}
|
|
63
|
+
const routes = getRoutes();
|
|
64
|
+
function getParamRouteMapping() {
|
|
65
|
+
const map = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const route of routes) {
|
|
67
|
+
map.set(slugToParam(route.slug), route);
|
|
68
|
+
}
|
|
69
|
+
return map;
|
|
70
|
+
}
|
|
71
|
+
const routesBySlugParam = getParamRouteMapping();
|
|
72
|
+
function getRouteBySlugParam(slugParam) {
|
|
73
|
+
return routesBySlugParam.get(slugParam?.replace(/\/$/, "") || void 0);
|
|
74
|
+
}
|
|
75
|
+
function getPaths() {
|
|
76
|
+
return routes.map((route) => ({
|
|
77
|
+
params: { slug: slugToParam(route.slug) },
|
|
78
|
+
props: route
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
const paths = getPaths();
|
|
82
|
+
function getLocaleRoutes(locale) {
|
|
83
|
+
return filterByLocale(routes, locale);
|
|
84
|
+
}
|
|
85
|
+
function getLocaleDocs(locale) {
|
|
86
|
+
return filterByLocale(docs, locale);
|
|
87
|
+
}
|
|
88
|
+
function filterByLocale(items, locale) {
|
|
89
|
+
if (config.locales) {
|
|
90
|
+
if (locale && locale in config.locales) {
|
|
91
|
+
return items.filter((i) => i.slug === locale || i.slug.startsWith(locale + "/"));
|
|
92
|
+
} else if (config.locales.root) {
|
|
93
|
+
const langKeys = Object.keys(config.locales).filter((k) => k !== "root");
|
|
94
|
+
const isLangIndex = new RegExp(`^(${langKeys.join("|")})$`);
|
|
95
|
+
const isLangDir = new RegExp(`^(${langKeys.join("|")})/`);
|
|
96
|
+
return items.filter((i) => !isLangIndex.test(i.slug) && !isLangDir.test(i.slug));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return items;
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
getLocaleRoutes,
|
|
103
|
+
getRouteBySlugParam,
|
|
104
|
+
normalizeCollectionEntry,
|
|
105
|
+
paths,
|
|
106
|
+
routes
|
|
107
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { klona } from "klona/lite";
|
|
2
|
+
import { routeMiddleware } from "virtual:starlight/route-middleware";
|
|
3
|
+
async function attachRouteDataAndRunMiddleware(context, routeData) {
|
|
4
|
+
context.locals.starlightRoute = klona(routeData);
|
|
5
|
+
const runner = new MiddlewareRunner(context, routeMiddleware);
|
|
6
|
+
await runner.run();
|
|
7
|
+
}
|
|
8
|
+
class MiddlewareRunnerStep {
|
|
9
|
+
#callback;
|
|
10
|
+
constructor(callback) {
|
|
11
|
+
this.#callback = callback;
|
|
12
|
+
}
|
|
13
|
+
async run(context, next) {
|
|
14
|
+
if (this.#callback) {
|
|
15
|
+
await this.#callback(context, next);
|
|
16
|
+
this.#callback = null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
class MiddlewareRunner {
|
|
21
|
+
#context;
|
|
22
|
+
#steps;
|
|
23
|
+
constructor(context, stack = []) {
|
|
24
|
+
this.#context = context;
|
|
25
|
+
this.#steps = stack.map((callback) => new MiddlewareRunnerStep(callback));
|
|
26
|
+
}
|
|
27
|
+
async #stepThrough(steps) {
|
|
28
|
+
let currentStep;
|
|
29
|
+
while (steps.length > 0) {
|
|
30
|
+
[currentStep, ...steps] = steps;
|
|
31
|
+
await currentStep.run(this.#context, async () => this.#stepThrough(steps));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async run() {
|
|
35
|
+
await this.#stepThrough(this.#steps);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
attachRouteDataAndRunMiddleware
|
|
40
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './routing/index.js';
|