@kamod-ch/preactpress 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/assets/favicon-32.png +0 -0
- package/assets/favicon.png +0 -0
- package/assets/favicon.svg +28 -0
- package/assets/logo-dark.svg +5 -0
- package/assets/logo-light.svg +5 -0
- package/assets/logo.svg +5 -0
- package/bin/preactpress.mjs +13 -0
- package/dist/client/app.d.ts +6 -0
- package/dist/client/app.d.ts.map +1 -0
- package/dist/client/app.js +168 -0
- package/dist/client/app.js.map +1 -0
- package/dist/client/entry-client.d.ts +2 -0
- package/dist/client/entry-client.d.ts.map +1 -0
- package/dist/client/entry-client.js +27 -0
- package/dist/client/entry-client.js.map +1 -0
- package/dist/client/entry-ssr.d.ts +14 -0
- package/dist/client/entry-ssr.d.ts.map +1 -0
- package/dist/client/entry-ssr.js +59 -0
- package/dist/client/entry-ssr.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/loadPage.d.ts +5 -0
- package/dist/client/loadPage.d.ts.map +1 -0
- package/dist/client/loadPage.js +62 -0
- package/dist/client/loadPage.js.map +1 -0
- package/dist/client/prefetchLinks.d.ts +2 -0
- package/dist/client/prefetchLinks.d.ts.map +1 -0
- package/dist/client/prefetchLinks.js +55 -0
- package/dist/client/prefetchLinks.js.map +1 -0
- package/dist/client/theme-default/AlgoliaSearch.d.ts +12 -0
- package/dist/client/theme-default/AlgoliaSearch.d.ts.map +1 -0
- package/dist/client/theme-default/AlgoliaSearch.js +66 -0
- package/dist/client/theme-default/AlgoliaSearch.js.map +1 -0
- package/dist/client/theme-default/Features.d.ts +9 -0
- package/dist/client/theme-default/Features.d.ts.map +1 -0
- package/dist/client/theme-default/Features.js +25 -0
- package/dist/client/theme-default/Features.js.map +1 -0
- package/dist/client/theme-default/Hero.d.ts +9 -0
- package/dist/client/theme-default/Hero.d.ts.map +1 -0
- package/dist/client/theme-default/Hero.js +23 -0
- package/dist/client/theme-default/Hero.js.map +1 -0
- package/dist/client/theme-default/Layout.d.ts +6 -0
- package/dist/client/theme-default/Layout.d.ts.map +1 -0
- package/dist/client/theme-default/Layout.js +224 -0
- package/dist/client/theme-default/Layout.js.map +1 -0
- package/dist/client/theme-default/Logo.d.ts +16 -0
- package/dist/client/theme-default/Logo.d.ts.map +1 -0
- package/dist/client/theme-default/Logo.js +30 -0
- package/dist/client/theme-default/Logo.js.map +1 -0
- package/dist/client/theme-default/NavLinks.d.ts +12 -0
- package/dist/client/theme-default/NavLinks.d.ts.map +1 -0
- package/dist/client/theme-default/NavLinks.js +18 -0
- package/dist/client/theme-default/NavLinks.js.map +1 -0
- package/dist/client/theme-default/SidebarNav.d.ts +12 -0
- package/dist/client/theme-default/SidebarNav.d.ts.map +1 -0
- package/dist/client/theme-default/SidebarNav.js +21 -0
- package/dist/client/theme-default/SidebarNav.js.map +1 -0
- package/dist/client/theme-default/SocialLinks.d.ts +8 -0
- package/dist/client/theme-default/SocialLinks.d.ts.map +1 -0
- package/dist/client/theme-default/SocialLinks.js +13 -0
- package/dist/client/theme-default/SocialLinks.js.map +1 -0
- package/dist/client/theme-default/ThemeToggle.d.ts +4 -0
- package/dist/client/theme-default/ThemeToggle.d.ts.map +1 -0
- package/dist/client/theme-default/ThemeToggle.js +31 -0
- package/dist/client/theme-default/ThemeToggle.js.map +1 -0
- package/dist/client/theme-default/index.d.ts +2 -0
- package/dist/client/theme-default/index.d.ts.map +1 -0
- package/dist/client/theme-default/index.js +2 -0
- package/dist/client/theme-default/index.js.map +1 -0
- package/dist/client/types.d.ts +36 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/client/usePageHead.d.ts +10 -0
- package/dist/client/usePageHead.d.ts.map +1 -0
- package/dist/client/usePageHead.js +182 -0
- package/dist/client/usePageHead.js.map +1 -0
- package/dist/client/useSiteSearch.d.ts +10 -0
- package/dist/client/useSiteSearch.d.ts.map +1 -0
- package/dist/client/useSiteSearch.js +54 -0
- package/dist/client/useSiteSearch.js.map +1 -0
- package/dist/node/build.d.ts +15 -0
- package/dist/node/build.d.ts.map +1 -0
- package/dist/node/build.js +310 -0
- package/dist/node/build.js.map +1 -0
- package/dist/node/buildCache.d.ts +15 -0
- package/dist/node/buildCache.d.ts.map +1 -0
- package/dist/node/buildCache.js +41 -0
- package/dist/node/buildCache.js.map +1 -0
- package/dist/node/check.d.ts +11 -0
- package/dist/node/check.d.ts.map +1 -0
- package/dist/node/check.js +228 -0
- package/dist/node/check.js.map +1 -0
- package/dist/node/cli.d.ts +2 -0
- package/dist/node/cli.d.ts.map +1 -0
- package/dist/node/cli.js +157 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/config-helpers.d.ts +8 -0
- package/dist/node/config-helpers.d.ts.map +1 -0
- package/dist/node/config-helpers.js +5 -0
- package/dist/node/config-helpers.js.map +1 -0
- package/dist/node/config.d.ts +13 -0
- package/dist/node/config.d.ts.map +1 -0
- package/dist/node/config.js +167 -0
- package/dist/node/config.js.map +1 -0
- package/dist/node/content.d.ts +16 -0
- package/dist/node/content.d.ts.map +1 -0
- package/dist/node/content.js +72 -0
- package/dist/node/content.js.map +1 -0
- package/dist/node/createContentLoader.d.ts +19 -0
- package/dist/node/createContentLoader.d.ts.map +1 -0
- package/dist/node/createContentLoader.js +11 -0
- package/dist/node/createContentLoader.js.map +1 -0
- package/dist/node/devCss.d.ts +7 -0
- package/dist/node/devCss.d.ts.map +1 -0
- package/dist/node/devCss.js +70 -0
- package/dist/node/devCss.js.map +1 -0
- package/dist/node/devSsr.d.ts +6 -0
- package/dist/node/devSsr.d.ts.map +1 -0
- package/dist/node/devSsr.js +112 -0
- package/dist/node/devSsr.js.map +1 -0
- package/dist/node/dynamicRoutes.d.ts +21 -0
- package/dist/node/dynamicRoutes.d.ts.map +1 -0
- package/dist/node/dynamicRoutes.js +120 -0
- package/dist/node/dynamicRoutes.js.map +1 -0
- package/dist/node/favicon.d.ts +9 -0
- package/dist/node/favicon.d.ts.map +1 -0
- package/dist/node/favicon.js +71 -0
- package/dist/node/favicon.js.map +1 -0
- package/dist/node/feed.d.ts +7 -0
- package/dist/node/feed.d.ts.map +1 -0
- package/dist/node/feed.js +37 -0
- package/dist/node/feed.js.map +1 -0
- package/dist/node/hooks.d.ts +9 -0
- package/dist/node/hooks.d.ts.map +1 -0
- package/dist/node/hooks.js +20 -0
- package/dist/node/hooks.js.map +1 -0
- package/dist/node/html.d.ts +56 -0
- package/dist/node/html.d.ts.map +1 -0
- package/dist/node/html.js +222 -0
- package/dist/node/html.js.map +1 -0
- package/dist/node/index.d.ts +12 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +9 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/init.d.ts +12 -0
- package/dist/node/init.d.ts.map +1 -0
- package/dist/node/init.js +93 -0
- package/dist/node/init.js.map +1 -0
- package/dist/node/lastUpdated.d.ts +3 -0
- package/dist/node/lastUpdated.d.ts.map +1 -0
- package/dist/node/lastUpdated.js +24 -0
- package/dist/node/lastUpdated.js.map +1 -0
- package/dist/node/loadSiteModule.d.ts +2 -0
- package/dist/node/loadSiteModule.d.ts.map +1 -0
- package/dist/node/loadSiteModule.js +10 -0
- package/dist/node/loadSiteModule.js.map +1 -0
- package/dist/node/markdown.d.ts +31 -0
- package/dist/node/markdown.d.ts.map +1 -0
- package/dist/node/markdown.js +508 -0
- package/dist/node/markdown.js.map +1 -0
- package/dist/node/markdownHeadings.d.ts +12 -0
- package/dist/node/markdownHeadings.d.ts.map +1 -0
- package/dist/node/markdownHeadings.js +70 -0
- package/dist/node/markdownHeadings.js.map +1 -0
- package/dist/node/markdownInclude.d.ts +6 -0
- package/dist/node/markdownInclude.d.ts.map +1 -0
- package/dist/node/markdownInclude.js +74 -0
- package/dist/node/markdownInclude.js.map +1 -0
- package/dist/node/markdownSnippets.d.ts +32 -0
- package/dist/node/markdownSnippets.d.ts.map +1 -0
- package/dist/node/markdownSnippets.js +172 -0
- package/dist/node/markdownSnippets.js.map +1 -0
- package/dist/node/mdx.d.ts +3 -0
- package/dist/node/mdx.d.ts.map +1 -0
- package/dist/node/mdx.js +9 -0
- package/dist/node/mdx.js.map +1 -0
- package/dist/node/packageRoot.d.ts +4 -0
- package/dist/node/packageRoot.d.ts.map +1 -0
- package/dist/node/packageRoot.js +7 -0
- package/dist/node/packageRoot.js.map +1 -0
- package/dist/node/pageDataLoaders.d.ts +6 -0
- package/dist/node/pageDataLoaders.d.ts.map +1 -0
- package/dist/node/pageDataLoaders.js +68 -0
- package/dist/node/pageDataLoaders.js.map +1 -0
- package/dist/node/paths.d.ts +5 -0
- package/dist/node/paths.d.ts.map +1 -0
- package/dist/node/paths.js +12 -0
- package/dist/node/paths.js.map +1 -0
- package/dist/node/plugin.d.ts +7 -0
- package/dist/node/plugin.d.ts.map +1 -0
- package/dist/node/plugin.js +282 -0
- package/dist/node/plugin.js.map +1 -0
- package/dist/node/resolveDeps.d.ts +5 -0
- package/dist/node/resolveDeps.d.ts.map +1 -0
- package/dist/node/resolveDeps.js +25 -0
- package/dist/node/resolveDeps.js.map +1 -0
- package/dist/node/serve.d.ts +6 -0
- package/dist/node/serve.d.ts.map +1 -0
- package/dist/node/serve.js +41 -0
- package/dist/node/serve.js.map +1 -0
- package/dist/node/server.d.ts +7 -0
- package/dist/node/server.d.ts.map +1 -0
- package/dist/node/server.js +55 -0
- package/dist/node/server.js.map +1 -0
- package/dist/node/siteConfig.d.ts +206 -0
- package/dist/node/siteConfig.d.ts.map +1 -0
- package/dist/node/siteConfig.js +2 -0
- package/dist/node/siteConfig.js.map +1 -0
- package/dist/node/tagIndex.d.ts +27 -0
- package/dist/node/tagIndex.d.ts.map +1 -0
- package/dist/node/tagIndex.js +84 -0
- package/dist/node/tagIndex.js.map +1 -0
- package/dist/shared/contentChunk.d.ts +4 -0
- package/dist/shared/contentChunk.d.ts.map +1 -0
- package/dist/shared/contentChunk.js +14 -0
- package/dist/shared/contentChunk.js.map +1 -0
- package/dist/shared/contentSchema.d.ts +43 -0
- package/dist/shared/contentSchema.d.ts.map +1 -0
- package/dist/shared/contentSchema.js +44 -0
- package/dist/shared/contentSchema.js.map +1 -0
- package/dist/shared/deadLinks.d.ts +9 -0
- package/dist/shared/deadLinks.d.ts.map +1 -0
- package/dist/shared/deadLinks.js +27 -0
- package/dist/shared/deadLinks.js.map +1 -0
- package/dist/shared/escapeHtml.d.ts +3 -0
- package/dist/shared/escapeHtml.d.ts.map +1 -0
- package/dist/shared/escapeHtml.js +11 -0
- package/dist/shared/escapeHtml.js.map +1 -0
- package/dist/shared/index.d.ts +15 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +15 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/locale.d.ts +11 -0
- package/dist/shared/locale.d.ts.map +1 -0
- package/dist/shared/locale.js +84 -0
- package/dist/shared/locale.js.map +1 -0
- package/dist/shared/pageChrome.d.ts +80 -0
- package/dist/shared/pageChrome.d.ts.map +1 -0
- package/dist/shared/pageChrome.js +160 -0
- package/dist/shared/pageChrome.js.map +1 -0
- package/dist/shared/pageHead.d.ts +3 -0
- package/dist/shared/pageHead.d.ts.map +1 -0
- package/dist/shared/pageHead.js +28 -0
- package/dist/shared/pageHead.js.map +1 -0
- package/dist/shared/pageMeta.d.ts +60 -0
- package/dist/shared/pageMeta.d.ts.map +1 -0
- package/dist/shared/pageMeta.js +72 -0
- package/dist/shared/pageMeta.js.map +1 -0
- package/dist/shared/rewrites.d.ts +5 -0
- package/dist/shared/rewrites.d.ts.map +1 -0
- package/dist/shared/rewrites.js +23 -0
- package/dist/shared/rewrites.js.map +1 -0
- package/dist/shared/route.d.ts +5 -0
- package/dist/shared/route.d.ts.map +1 -0
- package/dist/shared/route.js +15 -0
- package/dist/shared/route.js.map +1 -0
- package/dist/shared/search.d.ts +39 -0
- package/dist/shared/search.d.ts.map +1 -0
- package/dist/shared/search.js +63 -0
- package/dist/shared/search.js.map +1 -0
- package/dist/shared/sidebar.d.ts +18 -0
- package/dist/shared/sidebar.d.ts.map +1 -0
- package/dist/shared/sidebar.js +51 -0
- package/dist/shared/sidebar.js.map +1 -0
- package/dist/shared/slug.d.ts +4 -0
- package/dist/shared/slug.d.ts.map +1 -0
- package/dist/shared/slug.js +21 -0
- package/dist/shared/slug.js.map +1 -0
- package/dist/shared/socialIcons.d.ts +13 -0
- package/dist/shared/socialIcons.d.ts.map +1 -0
- package/dist/shared/socialIcons.js +27 -0
- package/dist/shared/socialIcons.js.map +1 -0
- package/dist/shared/tags.d.ts +6 -0
- package/dist/shared/tags.d.ts.map +1 -0
- package/dist/shared/tags.js +39 -0
- package/dist/shared/tags.js.map +1 -0
- package/dist/shared/theme.d.ts +8 -0
- package/dist/shared/theme.d.ts.map +1 -0
- package/dist/shared/theme.js +25 -0
- package/dist/shared/theme.js.map +1 -0
- package/dist/shared/themeLabels.d.ts +18 -0
- package/dist/shared/themeLabels.d.ts.map +1 -0
- package/dist/shared/themeLabels.js +51 -0
- package/dist/shared/themeLabels.js.map +1 -0
- package/dist/shared/url.d.ts +7 -0
- package/dist/shared/url.d.ts.map +1 -0
- package/dist/shared/url.js +10 -0
- package/dist/shared/url.js.map +1 -0
- package/package.json +108 -0
- package/src/client/app.tsx +194 -0
- package/src/client/entry-client.tsx +27 -0
- package/src/client/entry-ssr.tsx +77 -0
- package/src/client/index.ts +2 -0
- package/src/client/loadPage.ts +68 -0
- package/src/client/prefetchLinks.ts +60 -0
- package/src/client/theme-default/AlgoliaSearch.tsx +89 -0
- package/src/client/theme-default/Features.tsx +75 -0
- package/src/client/theme-default/Hero.tsx +60 -0
- package/src/client/theme-default/Layout.tsx +525 -0
- package/src/client/theme-default/Logo.tsx +104 -0
- package/src/client/theme-default/NavLinks.tsx +65 -0
- package/src/client/theme-default/SidebarNav.tsx +103 -0
- package/src/client/theme-default/SocialLinks.tsx +41 -0
- package/src/client/theme-default/ThemeToggle.tsx +79 -0
- package/src/client/theme-default/index.ts +1 -0
- package/src/client/theme-default/styles.css +1450 -0
- package/src/client/types.ts +37 -0
- package/src/client/usePageHead.ts +212 -0
- package/src/client/useSiteSearch.ts +57 -0
- package/src/client/virtual.d.ts +103 -0
- package/src/shared/contentChunk.ts +14 -0
- package/src/shared/contentSchema.ts +85 -0
- package/src/shared/deadLinks.ts +33 -0
- package/src/shared/escapeHtml.ts +11 -0
- package/src/shared/index.ts +83 -0
- package/src/shared/locale.ts +116 -0
- package/src/shared/pageChrome.ts +244 -0
- package/src/shared/pageHead.ts +26 -0
- package/src/shared/pageMeta.ts +136 -0
- package/src/shared/rewrites.ts +35 -0
- package/src/shared/route.ts +14 -0
- package/src/shared/search.ts +105 -0
- package/src/shared/sidebar.ts +67 -0
- package/src/shared/slug.ts +23 -0
- package/src/shared/socialIcons.ts +44 -0
- package/src/shared/tags.ts +36 -0
- package/src/shared/theme.ts +26 -0
- package/src/shared/themeLabels.ts +72 -0
- package/src/shared/url.ts +14 -0
- package/templates/default/.preactpress/config.ts +31 -0
- package/templates/default/README.md +45 -0
- package/templates/default/about.md +11 -0
- package/templates/default/guide/first-five-minutes.md +83 -0
- package/templates/default/index.html +18 -0
- package/templates/default/index.md +55 -0
- package/templates/default/package.json +15 -0
- package/templates/default/pnpm-lock.yaml +2917 -0
- package/templates/docs/.preactpress/config.ts +94 -0
- package/templates/docs/README.md +21 -0
- package/templates/docs/about.md +10 -0
- package/templates/docs/components/Counter.tsx +25 -0
- package/templates/docs/de/guide/getting-started.md +19 -0
- package/templates/docs/de/guide/what-is-preactpress.md +15 -0
- package/templates/docs/de/index.md +23 -0
- package/templates/docs/dist/404.html +29 -0
- package/templates/docs/dist/about/index.html +32 -0
- package/templates/docs/dist/assets/esm-DzlBxN5p.js +110 -0
- package/templates/docs/dist/assets/interactive-64o6YwrR.js +9 -0
- package/templates/docs/dist/assets/interactive-BedCloEw.js +9 -0
- package/templates/docs/dist/assets/main-BVLeh8GO.js +1 -0
- package/templates/docs/dist/assets/main-CreUBb3N.js +1 -0
- package/templates/docs/dist/assets/main-oodK-zZy.css +2 -0
- package/templates/docs/dist/de/guide/getting-started/index.html +36 -0
- package/templates/docs/dist/de/guide/what-is-preactpress/index.html +38 -0
- package/templates/docs/dist/de/index.html +29 -0
- package/templates/docs/dist/favicon-32.png +0 -0
- package/templates/docs/dist/favicon.png +0 -0
- package/templates/docs/dist/favicon.svg +28 -0
- package/templates/docs/dist/guide/advanced/index.html +53 -0
- package/templates/docs/dist/guide/commands/index.html +89 -0
- package/templates/docs/dist/guide/configuration/index.html +196 -0
- package/templates/docs/dist/guide/creating-pages/index.html +234 -0
- package/templates/docs/dist/guide/custom-themes/index.html +52 -0
- package/templates/docs/dist/guide/default-theme/index.html +53 -0
- package/templates/docs/dist/guide/deploy/index.html +195 -0
- package/templates/docs/dist/guide/first-five-minutes/index.html +99 -0
- package/templates/docs/dist/guide/getting-started/index.html +173 -0
- package/templates/docs/dist/guide/markdown-and-mdx/index.html +59 -0
- package/templates/docs/dist/guide/routing/index.html +192 -0
- package/templates/docs/dist/guide/what-is-preactpress/index.html +141 -0
- package/templates/docs/dist/index.html +30 -0
- package/templates/docs/dist/interactive/index.html +37 -0
- package/templates/docs/dist/markdown-examples/index.html +231 -0
- package/templates/docs/dist/preactpress-content/404.json +8 -0
- package/templates/docs/dist/preactpress-content/_index.json +50 -0
- package/templates/docs/dist/preactpress-content/about.json +15 -0
- package/templates/docs/dist/preactpress-content/de.json +45 -0
- package/templates/docs/dist/preactpress-content/de__guide__getting-started.json +26 -0
- package/templates/docs/dist/preactpress-content/de__guide__what-is-preactpress.json +21 -0
- package/templates/docs/dist/preactpress-content/guide__advanced.json +46 -0
- package/templates/docs/dist/preactpress-content/guide__commands.json +26 -0
- package/templates/docs/dist/preactpress-content/guide__configuration.json +51 -0
- package/templates/docs/dist/preactpress-content/guide__creating-pages.json +71 -0
- package/templates/docs/dist/preactpress-content/guide__custom-themes.json +15 -0
- package/templates/docs/dist/preactpress-content/guide__default-theme.json +36 -0
- package/templates/docs/dist/preactpress-content/guide__deploy.json +56 -0
- package/templates/docs/dist/preactpress-content/guide__first-five-minutes.json +36 -0
- package/templates/docs/dist/preactpress-content/guide__getting-started.json +51 -0
- package/templates/docs/dist/preactpress-content/guide__markdown-and-mdx.json +31 -0
- package/templates/docs/dist/preactpress-content/guide__routing.json +71 -0
- package/templates/docs/dist/preactpress-content/guide__what-is-preactpress.json +51 -0
- package/templates/docs/dist/preactpress-content/markdown-examples.json +71 -0
- package/templates/docs/dist/preactpress-content/tags__markdown.json +16 -0
- package/templates/docs/dist/preactpress-search.json +166 -0
- package/templates/docs/dist/preactpress-theme.js +1 -0
- package/templates/docs/dist/tags/markdown/index.html +32 -0
- package/templates/docs/guide/advanced.md +44 -0
- package/templates/docs/guide/commands.md +41 -0
- package/templates/docs/guide/configuration.md +130 -0
- package/templates/docs/guide/creating-pages.md +171 -0
- package/templates/docs/guide/custom-themes.md +39 -0
- package/templates/docs/guide/default-theme.md +41 -0
- package/templates/docs/guide/deploy.md +197 -0
- package/templates/docs/guide/first-five-minutes.md +82 -0
- package/templates/docs/guide/getting-started.md +146 -0
- package/templates/docs/guide/markdown-and-mdx.md +59 -0
- package/templates/docs/guide/routing.md +263 -0
- package/templates/docs/guide/what-is-preactpress.md +87 -0
- package/templates/docs/index.html +18 -0
- package/templates/docs/index.md +28 -0
- package/templates/docs/interactive.mdx +32 -0
- package/templates/docs/markdown-examples.md +72 -0
- package/templates/docs/package.json +15 -0
- package/templates/docs/partials/shared-note.md +3 -0
- package/templates/docs/parts/include-body.md +9 -0
- package/templates/docs/pnpm-lock.yaml +2917 -0
- package/templates/docs/snippets/greet.ts +3 -0
- package/templates/hono/.preactpress/config.ts +100 -0
- package/templates/hono/.preactpress/theme/CodeSnippet.tsx +41 -0
- package/templates/hono/.preactpress/theme/FeatureGrid.tsx +27 -0
- package/templates/hono/.preactpress/theme/Hero.tsx +45 -0
- package/templates/hono/.preactpress/theme/Layout.tsx +388 -0
- package/templates/hono/.preactpress/theme/Logo.tsx +26 -0
- package/templates/hono/.preactpress/theme/ThemeToggle.tsx +72 -0
- package/templates/hono/.preactpress/theme/hono.css +1058 -0
- package/templates/hono/README.md +41 -0
- package/templates/hono/about.md +10 -0
- package/templates/hono/components/Counter.tsx +25 -0
- package/templates/hono/de/about.md +10 -0
- package/templates/hono/de/guide/commands.md +44 -0
- package/templates/hono/de/guide/configuration.md +64 -0
- package/templates/hono/de/guide/deploy.md +197 -0
- package/templates/hono/de/guide/first-five-minutes.md +82 -0
- package/templates/hono/de/guide/getting-started.md +146 -0
- package/templates/hono/de/guide/routing.md +220 -0
- package/templates/hono/de/guide/seiten-erstellen.md +171 -0
- package/templates/hono/de/guide/what-is-preactpress.md +87 -0
- package/templates/hono/de/index.mdx +51 -0
- package/templates/hono/de/interactive.mdx +32 -0
- package/templates/hono/de/markdown-examples.md +142 -0
- package/templates/hono/de/parts/include-body.md +9 -0
- package/templates/hono/de/snippets/greet.ts +3 -0
- package/templates/hono/dist/404.html +29 -0
- package/templates/hono/dist/README/index.html +104 -0
- package/templates/hono/dist/about/index.html +32 -0
- package/templates/hono/dist/assets/Counter-CCEByS-J.js +1 -0
- package/templates/hono/dist/assets/Hero--o6WMNvm.js +2 -0
- package/templates/hono/dist/assets/de-D5r6Ye70.js +10 -0
- package/templates/hono/dist/assets/hono-BXWYYdyv.js +10 -0
- package/templates/hono/dist/assets/interactive-Bxo-WBpC.js +9 -0
- package/templates/hono/dist/assets/interactive-BznI4IQ3.js +9 -0
- package/templates/hono/dist/assets/main-Bqi-VFEk.js +2 -0
- package/templates/hono/dist/assets/main-DIIN7FO0.css +1 -0
- package/templates/hono/dist/de/about/index.html +32 -0
- package/templates/hono/dist/de/guide/commands/index.html +41 -0
- package/templates/hono/dist/de/guide/configuration/index.html +105 -0
- package/templates/hono/dist/de/guide/deploy/index.html +195 -0
- package/templates/hono/dist/de/guide/first-five-minutes/index.html +99 -0
- package/templates/hono/dist/de/guide/getting-started/index.html +173 -0
- package/templates/hono/dist/de/guide/routing/index.html +165 -0
- package/templates/hono/dist/de/guide/seiten-erstellen/index.html +234 -0
- package/templates/hono/dist/de/guide/what-is-preactpress/index.html +141 -0
- package/templates/hono/dist/de/index.html +30 -0
- package/templates/hono/dist/de/interactive/index.html +37 -0
- package/templates/hono/dist/de/markdown-examples/index.html +97 -0
- package/templates/hono/dist/de/parts/include-body/index.html +36 -0
- package/templates/hono/dist/de/tags/markdown/index.html +32 -0
- package/templates/hono/dist/favicon-32.png +0 -0
- package/templates/hono/dist/favicon.png +0 -0
- package/templates/hono/dist/favicon.svg +28 -0
- package/templates/hono/dist/guide/commands/index.html +41 -0
- package/templates/hono/dist/guide/configuration/index.html +158 -0
- package/templates/hono/dist/guide/creating-pages/index.html +234 -0
- package/templates/hono/dist/guide/deploy/index.html +195 -0
- package/templates/hono/dist/guide/first-five-minutes/index.html +99 -0
- package/templates/hono/dist/guide/getting-started/index.html +173 -0
- package/templates/hono/dist/guide/routing/index.html +165 -0
- package/templates/hono/dist/guide/what-is-preactpress/index.html +141 -0
- package/templates/hono/dist/index.html +30 -0
- package/templates/hono/dist/interactive/index.html +37 -0
- package/templates/hono/dist/markdown-examples/index.html +105 -0
- package/templates/hono/dist/partials/shared-note/index.html +30 -0
- package/templates/hono/dist/parts/include-body/index.html +36 -0
- package/templates/hono/dist/preactpress-content/404.json +8 -0
- package/templates/hono/dist/preactpress-content/README.json +26 -0
- package/templates/hono/dist/preactpress-content/about.json +15 -0
- package/templates/hono/dist/preactpress-content/de__about.json +15 -0
- package/templates/hono/dist/preactpress-content/de__guide__commands.json +36 -0
- package/templates/hono/dist/preactpress-content/de__guide__configuration.json +41 -0
- package/templates/hono/dist/preactpress-content/de__guide__deploy.json +56 -0
- package/templates/hono/dist/preactpress-content/de__guide__first-five-minutes.json +36 -0
- package/templates/hono/dist/preactpress-content/de__guide__getting-started.json +51 -0
- package/templates/hono/dist/preactpress-content/de__guide__routing.json +61 -0
- package/templates/hono/dist/preactpress-content/de__guide__seiten-erstellen.json +71 -0
- package/templates/hono/dist/preactpress-content/de__guide__what-is-preactpress.json +51 -0
- package/templates/hono/dist/preactpress-content/de__markdown-examples.json +131 -0
- package/templates/hono/dist/preactpress-content/de__parts__include-body.json +16 -0
- package/templates/hono/dist/preactpress-content/de__tags__markdown.json +16 -0
- package/templates/hono/dist/preactpress-content/guide__commands.json +36 -0
- package/templates/hono/dist/preactpress-content/guide__configuration.json +51 -0
- package/templates/hono/dist/preactpress-content/guide__creating-pages.json +71 -0
- package/templates/hono/dist/preactpress-content/guide__deploy.json +56 -0
- package/templates/hono/dist/preactpress-content/guide__first-five-minutes.json +36 -0
- package/templates/hono/dist/preactpress-content/guide__getting-started.json +51 -0
- package/templates/hono/dist/preactpress-content/guide__routing.json +61 -0
- package/templates/hono/dist/preactpress-content/guide__what-is-preactpress.json +51 -0
- package/templates/hono/dist/preactpress-content/markdown-examples.json +141 -0
- package/templates/hono/dist/preactpress-content/partials__shared-note.json +10 -0
- package/templates/hono/dist/preactpress-content/parts__include-body.json +16 -0
- package/templates/hono/dist/preactpress-content/tags__markdown.json +16 -0
- package/templates/hono/dist/preactpress-search.json +242 -0
- package/templates/hono/dist/preactpress-theme.js +1 -0
- package/templates/hono/dist/tags/markdown/index.html +32 -0
- package/templates/hono/guide/commands.md +44 -0
- package/templates/hono/guide/configuration.md +177 -0
- package/templates/hono/guide/creating-pages.md +171 -0
- package/templates/hono/guide/deploy.md +197 -0
- package/templates/hono/guide/first-five-minutes.md +82 -0
- package/templates/hono/guide/getting-started.md +146 -0
- package/templates/hono/guide/routing.md +263 -0
- package/templates/hono/guide/what-is-preactpress.md +87 -0
- package/templates/hono/index.html +18 -0
- package/templates/hono/index.mdx +51 -0
- package/templates/hono/interactive.mdx +32 -0
- package/templates/hono/markdown-examples.md +160 -0
- package/templates/hono/package.json +15 -0
- package/templates/hono/partials/shared-note.md +3 -0
- package/templates/hono/parts/include-body.md +9 -0
- package/templates/hono/pnpm-lock.yaml +2917 -0
- package/templates/hono/snippets/greet.ts +3 -0
- package/templates/magazine/.preactpress/config.ts +36 -0
- package/templates/magazine/.preactpress/theme/Layout.tsx +319 -0
- package/templates/magazine/.preactpress/theme/TeaserGrid.tsx +39 -0
- package/templates/magazine/.preactpress/theme/ThemeToggle.tsx +73 -0
- package/templates/magazine/.preactpress/theme/magazine.css +587 -0
- package/templates/magazine/article-markets.md +24 -0
- package/templates/magazine/article-tech.mdx +35 -0
- package/templates/magazine/index.data.ts +19 -0
- package/templates/magazine/index.html +14 -0
- package/templates/magazine/index.mdx +13 -0
- package/templates/magazine/package.json +15 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { useEffect, useState } from 'preact/hooks'
|
|
2
|
+
import Layout from 'virtual:preactpress-layout'
|
|
3
|
+
import { pagesMeta, routes } from 'virtual:preactpress-pages'
|
|
4
|
+
import { i18n, mpa, site, themeConfig } from 'virtual:preactpress-site'
|
|
5
|
+
import type { PageView } from './types.js'
|
|
6
|
+
import type { ResolvedLocale } from '../node/siteConfig.js'
|
|
7
|
+
import { usePageHead } from './usePageHead.js'
|
|
8
|
+
import { normalizeRoute, routeFromPathname } from '../shared/route.js'
|
|
9
|
+
import { loadPage, prefetchPage, seedPage } from './loadPage.js'
|
|
10
|
+
import { setupViewportPrefetch } from './prefetchLinks.js'
|
|
11
|
+
import {
|
|
12
|
+
localeFromRoute,
|
|
13
|
+
localizedRouteForLocale,
|
|
14
|
+
siteForRoute,
|
|
15
|
+
themeConfigForRoute
|
|
16
|
+
} from '../shared/locale.js'
|
|
17
|
+
|
|
18
|
+
function routeFromLocation(): string {
|
|
19
|
+
return routeFromPathname(window.location.pathname, site.base)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function routeFromHref(href: string): string | undefined {
|
|
23
|
+
const url = new URL(href, window.location.href)
|
|
24
|
+
if (url.origin !== window.location.origin) return undefined
|
|
25
|
+
const base = site.base === '/' ? '' : site.base.replace(/\/$/, '')
|
|
26
|
+
if (base && url.pathname !== base && !url.pathname.startsWith(`${base}/`)) {
|
|
27
|
+
return undefined
|
|
28
|
+
}
|
|
29
|
+
const path = base ? url.pathname.slice(base.length) || '/' : url.pathname
|
|
30
|
+
return normalizeRoute(path)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function anchorFromEvent(event: MouseEvent): HTMLAnchorElement | null {
|
|
34
|
+
const target = event.target
|
|
35
|
+
const element =
|
|
36
|
+
target instanceof Element
|
|
37
|
+
? target
|
|
38
|
+
: target instanceof Text
|
|
39
|
+
? target.parentElement
|
|
40
|
+
: null
|
|
41
|
+
return element?.closest('a[href]') ?? null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function loadingPage(route: string): PageView {
|
|
45
|
+
const meta = pagesMeta[route]
|
|
46
|
+
return {
|
|
47
|
+
kind: 'markdown',
|
|
48
|
+
html: '<p>Loading...</p>',
|
|
49
|
+
title: meta?.title,
|
|
50
|
+
description: meta?.description,
|
|
51
|
+
tags: meta?.tags,
|
|
52
|
+
image: meta?.image,
|
|
53
|
+
pageType: meta?.pageType,
|
|
54
|
+
meta: meta?.meta ?? {},
|
|
55
|
+
headings: meta?.headings ?? []
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function App({ routePath, initialPage }: { routePath: string; initialPage?: PageView }) {
|
|
60
|
+
const [currentRoute, setCurrentRoute] = useState(() => normalizeRoute(routePath))
|
|
61
|
+
const [page, setPage] = useState<PageView>(() => initialPage ?? loadingPage(routePath))
|
|
62
|
+
const availableRoutes = new Set(routes)
|
|
63
|
+
const activeLocale = localeFromRoute(currentRoute, i18n)
|
|
64
|
+
const activeSite = siteForRoute(site, currentRoute, i18n)
|
|
65
|
+
const activeThemeConfig = themeConfigForRoute(themeConfig, currentRoute, i18n)
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (initialPage) seedPage(normalizeRoute(routePath), initialPage)
|
|
69
|
+
}, [initialPage, routePath])
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
let cancelled = false
|
|
73
|
+
setPage(loadingPage(currentRoute))
|
|
74
|
+
void loadPage(currentRoute, site.base)
|
|
75
|
+
.then((loaded) => {
|
|
76
|
+
if (!cancelled) setPage(loaded)
|
|
77
|
+
})
|
|
78
|
+
.catch(() => {
|
|
79
|
+
if (!cancelled) {
|
|
80
|
+
setPage({
|
|
81
|
+
kind: 'markdown',
|
|
82
|
+
html: '<p>Page not found.</p>',
|
|
83
|
+
title: '404',
|
|
84
|
+
description: activeSite.description,
|
|
85
|
+
meta: {},
|
|
86
|
+
headings: []
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
return () => {
|
|
91
|
+
cancelled = true
|
|
92
|
+
}
|
|
93
|
+
}, [activeSite.description, currentRoute])
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const prefetch = (route: string) => prefetchPage(route, site.base)
|
|
97
|
+
const stopViewportPrefetch = setupViewportPrefetch(routeFromHref, prefetch)
|
|
98
|
+
if (mpa) {
|
|
99
|
+
return () => stopViewportPrefetch()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const onPopState = () => setCurrentRoute(routeFromLocation())
|
|
103
|
+
const onClick = (event: MouseEvent) => {
|
|
104
|
+
if (
|
|
105
|
+
event.defaultPrevented ||
|
|
106
|
+
event.button !== 0 ||
|
|
107
|
+
event.metaKey ||
|
|
108
|
+
event.altKey ||
|
|
109
|
+
event.ctrlKey ||
|
|
110
|
+
event.shiftKey
|
|
111
|
+
) {
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
const link = anchorFromEvent(event)
|
|
115
|
+
if (!link || link.target || link.hasAttribute('download')) return
|
|
116
|
+
const route = routeFromHref(link.href)
|
|
117
|
+
if (!route) return
|
|
118
|
+
const url = new URL(link.href)
|
|
119
|
+
if (url.hash && route === currentRoute) {
|
|
120
|
+
document.getElementById(url.hash.slice(1))?.scrollIntoView()
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
event.preventDefault()
|
|
124
|
+
window.history.pushState({}, '', url)
|
|
125
|
+
setCurrentRoute(route)
|
|
126
|
+
window.scrollTo({ top: 0 })
|
|
127
|
+
}
|
|
128
|
+
const onMouseEnter = (event: MouseEvent) => {
|
|
129
|
+
const link = anchorFromEvent(event)
|
|
130
|
+
if (!link) return
|
|
131
|
+
const route = routeFromHref(link.href)
|
|
132
|
+
if (route) prefetch(route)
|
|
133
|
+
}
|
|
134
|
+
window.addEventListener('popstate', onPopState)
|
|
135
|
+
document.addEventListener('click', onClick)
|
|
136
|
+
document.addEventListener('mouseenter', onMouseEnter, true)
|
|
137
|
+
return () => {
|
|
138
|
+
stopViewportPrefetch()
|
|
139
|
+
window.removeEventListener('popstate', onPopState)
|
|
140
|
+
document.removeEventListener('click', onClick)
|
|
141
|
+
document.removeEventListener('mouseenter', onMouseEnter, true)
|
|
142
|
+
}
|
|
143
|
+
}, [currentRoute, mpa])
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (currentRoute !== normalizeRoute(routePath)) {
|
|
147
|
+
document.getElementById('content')?.focus()
|
|
148
|
+
}
|
|
149
|
+
}, [currentRoute, routePath])
|
|
150
|
+
|
|
151
|
+
usePageHead({
|
|
152
|
+
site,
|
|
153
|
+
i18n,
|
|
154
|
+
routes: availableRoutes,
|
|
155
|
+
route: currentRoute,
|
|
156
|
+
page:
|
|
157
|
+
page?.kind === 'markdown'
|
|
158
|
+
? {
|
|
159
|
+
meta: page.meta,
|
|
160
|
+
title: page.title,
|
|
161
|
+
description: page.description,
|
|
162
|
+
tags: page.tags,
|
|
163
|
+
image: page.image,
|
|
164
|
+
pageType: page.pageType,
|
|
165
|
+
kind: 'markdown',
|
|
166
|
+
html: page.html
|
|
167
|
+
}
|
|
168
|
+
: page
|
|
169
|
+
? {
|
|
170
|
+
meta: page.meta,
|
|
171
|
+
title: page.title,
|
|
172
|
+
description: page.description,
|
|
173
|
+
tags: page.tags,
|
|
174
|
+
image: page.image,
|
|
175
|
+
pageType: page.pageType,
|
|
176
|
+
kind: 'mdx'
|
|
177
|
+
}
|
|
178
|
+
: undefined
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<Layout
|
|
183
|
+
site={activeSite}
|
|
184
|
+
themeConfig={activeThemeConfig}
|
|
185
|
+
routePath={currentRoute}
|
|
186
|
+
page={page}
|
|
187
|
+
i18n={i18n}
|
|
188
|
+
locale={activeLocale}
|
|
189
|
+
locales={i18n?.locales}
|
|
190
|
+
localizeRoute={(locale: ResolvedLocale) =>
|
|
191
|
+
localizedRouteForLocale(currentRoute, locale, i18n, availableRoutes)}
|
|
192
|
+
/>
|
|
193
|
+
)
|
|
194
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { hydrate } from 'preact'
|
|
2
|
+
import { App } from './app.js'
|
|
3
|
+
import type { PageView } from './types.js'
|
|
4
|
+
import { loadPage, seedPage } from './loadPage.js'
|
|
5
|
+
|
|
6
|
+
function currentRoute(): string {
|
|
7
|
+
const base = (import.meta.env.BASE_URL || '/').replace(/\/$/, '') || ''
|
|
8
|
+
let p = window.location.pathname
|
|
9
|
+
if (base && p.startsWith(base)) p = p.slice(base.length) || '/'
|
|
10
|
+
if (!p.startsWith('/')) p = `/${p}`
|
|
11
|
+
return (p.replace(/\/$/, '') || '/') as string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const el = document.getElementById('app')
|
|
15
|
+
if (el) {
|
|
16
|
+
void (async () => {
|
|
17
|
+
const initial =
|
|
18
|
+
el.getAttribute('data-preactpress-route') ??
|
|
19
|
+
currentRoute()
|
|
20
|
+
const dataEl = document.getElementById('__PREACTPRESS_PAGE_DATA__')
|
|
21
|
+
const initialPage = dataEl?.textContent
|
|
22
|
+
? JSON.parse(dataEl.textContent) as PageView
|
|
23
|
+
: await loadPage(initial, import.meta.env.BASE_URL || '/')
|
|
24
|
+
seedPage(initial, initialPage)
|
|
25
|
+
hydrate(<App routePath={initial} initialPage={initialPage} />, el)
|
|
26
|
+
})()
|
|
27
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { renderToString } from 'preact-render-to-string'
|
|
2
|
+
import { App } from './app.js'
|
|
3
|
+
import { pages } from 'virtual:preactpress-pages'
|
|
4
|
+
import { i18n, site } from 'virtual:preactpress-site'
|
|
5
|
+
import { resolvePageHeadMeta, titleTemplateFromMeta } from '../shared/pageMeta.js'
|
|
6
|
+
import type { PageView } from './types.js'
|
|
7
|
+
import { siteForRoute } from '../shared/locale.js'
|
|
8
|
+
|
|
9
|
+
export interface RenderResult {
|
|
10
|
+
body: string
|
|
11
|
+
title: string
|
|
12
|
+
description: string
|
|
13
|
+
tags: string[]
|
|
14
|
+
image?: string
|
|
15
|
+
pageType: 'website' | 'article'
|
|
16
|
+
page: PageView
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function resolveRoutePage(routePath: string): PageView {
|
|
20
|
+
const activeSite = siteForRoute(site, routePath, i18n)
|
|
21
|
+
return (
|
|
22
|
+
pages[routePath] ??
|
|
23
|
+
pages['/404'] ?? {
|
|
24
|
+
kind: 'markdown' as const,
|
|
25
|
+
html: '',
|
|
26
|
+
title: 'Not found',
|
|
27
|
+
description: activeSite.description,
|
|
28
|
+
meta: {},
|
|
29
|
+
headings: []
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function renderResult(routePath: string, page: PageView): RenderResult {
|
|
35
|
+
const body = renderToString(<App routePath={routePath} initialPage={page} />)
|
|
36
|
+
const activeSite = siteForRoute(site, routePath, i18n)
|
|
37
|
+
const head = resolvePageHeadMeta(
|
|
38
|
+
page.kind === 'markdown'
|
|
39
|
+
? {
|
|
40
|
+
title: page.title,
|
|
41
|
+
titleTemplate: titleTemplateFromMeta(page.meta),
|
|
42
|
+
description: page.description,
|
|
43
|
+
tags: page.tags,
|
|
44
|
+
image: page.image,
|
|
45
|
+
pageType: page.pageType,
|
|
46
|
+
kind: 'markdown',
|
|
47
|
+
html: page.html
|
|
48
|
+
}
|
|
49
|
+
: {
|
|
50
|
+
title: page.title,
|
|
51
|
+
titleTemplate: titleTemplateFromMeta(page.meta),
|
|
52
|
+
description: page.description,
|
|
53
|
+
tags: page.tags,
|
|
54
|
+
image: page.image,
|
|
55
|
+
pageType: page.pageType,
|
|
56
|
+
kind: 'mdx'
|
|
57
|
+
},
|
|
58
|
+
activeSite
|
|
59
|
+
)
|
|
60
|
+
return {
|
|
61
|
+
body,
|
|
62
|
+
title: head.title,
|
|
63
|
+
description: head.description,
|
|
64
|
+
tags: head.tags,
|
|
65
|
+
image: head.image,
|
|
66
|
+
pageType: head.pageType,
|
|
67
|
+
page
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function renderFromPage(routePath: string, page: PageView): RenderResult {
|
|
72
|
+
return renderResult(routePath, page)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function render(routePath: string): RenderResult {
|
|
76
|
+
return renderFromPage(routePath, resolveRoutePage(routePath))
|
|
77
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { mdxLoaders, pagesMeta } from 'virtual:preactpress-pages'
|
|
2
|
+
import type { HtmlPageView, PageView } from './types.js'
|
|
3
|
+
import { contentChunkPath } from '../shared/contentChunk.js'
|
|
4
|
+
import { publicUrl } from '../shared/url.js'
|
|
5
|
+
|
|
6
|
+
const cache = new Map<string, PageView>()
|
|
7
|
+
|
|
8
|
+
function fallbackPage(): PageView {
|
|
9
|
+
return (
|
|
10
|
+
cache.get('/404') ??
|
|
11
|
+
({
|
|
12
|
+
kind: 'markdown',
|
|
13
|
+
html: '<p>Page not found.</p>',
|
|
14
|
+
title: '404',
|
|
15
|
+
description: undefined,
|
|
16
|
+
meta: {},
|
|
17
|
+
headings: []
|
|
18
|
+
} satisfies HtmlPageView)
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function seedPage(route: string, page: PageView | undefined): void {
|
|
23
|
+
if (page) cache.set(route, page)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function loadMarkdownPage(route: string, base: string): Promise<PageView> {
|
|
27
|
+
const meta = pagesMeta[route]
|
|
28
|
+
const url =
|
|
29
|
+
import.meta.env.DEV
|
|
30
|
+
? publicUrl(base, `/__preactpress/page.json?route=${encodeURIComponent(route)}`)
|
|
31
|
+
: publicUrl(base, contentChunkPath(route))
|
|
32
|
+
const res = await fetch(url, { credentials: 'same-origin' })
|
|
33
|
+
if (!res.ok) throw new Error(`Failed to load page ${route}`)
|
|
34
|
+
const data = (await res.json()) as HtmlPageView
|
|
35
|
+
return {
|
|
36
|
+
...meta,
|
|
37
|
+
...data,
|
|
38
|
+
kind: 'markdown'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function loadPage(route: string, base: string): Promise<PageView> {
|
|
43
|
+
const cached = cache.get(route)
|
|
44
|
+
if (cached) return cached
|
|
45
|
+
|
|
46
|
+
const meta = pagesMeta[route]
|
|
47
|
+
if (!meta) return fallbackPage()
|
|
48
|
+
|
|
49
|
+
if (meta.kind === 'mdx') {
|
|
50
|
+
const loader = mdxLoaders[route]
|
|
51
|
+
if (!loader) return fallbackPage()
|
|
52
|
+
const mod = await loader()
|
|
53
|
+
const page = { ...meta, kind: 'mdx' as const, Component: mod.default }
|
|
54
|
+
cache.set(route, page)
|
|
55
|
+
return page
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const page = await loadMarkdownPage(route, base)
|
|
59
|
+
cache.set(route, page)
|
|
60
|
+
return page
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function prefetchPage(route: string, base: string): void {
|
|
64
|
+
if (cache.has(route)) return
|
|
65
|
+
void loadPage(route, base).catch(() => {
|
|
66
|
+
/* Prefetch failures should not affect navigation. */
|
|
67
|
+
})
|
|
68
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const PREFETCH_MARGIN = '200px'
|
|
2
|
+
|
|
3
|
+
function scheduleIdle(task: () => void): void {
|
|
4
|
+
if (typeof requestIdleCallback === 'function') {
|
|
5
|
+
requestIdleCallback(() => task(), { timeout: 2000 })
|
|
6
|
+
return
|
|
7
|
+
}
|
|
8
|
+
setTimeout(task, 1)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function setupViewportPrefetch(
|
|
12
|
+
routeFromHref: (href: string) => string | undefined,
|
|
13
|
+
prefetch: (route: string) => void
|
|
14
|
+
): () => void {
|
|
15
|
+
if (typeof IntersectionObserver === 'undefined') return () => {}
|
|
16
|
+
|
|
17
|
+
const seen = new WeakSet<HTMLAnchorElement>()
|
|
18
|
+
const observer = new IntersectionObserver(
|
|
19
|
+
(entries) => {
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
if (!entry.isIntersecting) continue
|
|
22
|
+
const link = entry.target
|
|
23
|
+
if (!(link instanceof HTMLAnchorElement) || seen.has(link)) continue
|
|
24
|
+
const route = routeFromHref(link.href)
|
|
25
|
+
if (!route) continue
|
|
26
|
+
seen.add(link)
|
|
27
|
+
scheduleIdle(() => prefetch(route))
|
|
28
|
+
observer.unobserve(link)
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{ rootMargin: PREFETCH_MARGIN }
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
const observe = (root: ParentNode): void => {
|
|
35
|
+
for (const link of Array.from(root.querySelectorAll('a[href]'))) {
|
|
36
|
+
if (link instanceof HTMLAnchorElement && !seen.has(link)) {
|
|
37
|
+
observer.observe(link)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
observe(document)
|
|
43
|
+
const mutation = new MutationObserver((records) => {
|
|
44
|
+
for (const record of records) {
|
|
45
|
+
for (const node of Array.from(record.addedNodes)) {
|
|
46
|
+
if (node instanceof HTMLAnchorElement) {
|
|
47
|
+
if (!seen.has(node)) observer.observe(node)
|
|
48
|
+
continue
|
|
49
|
+
}
|
|
50
|
+
if (node instanceof Element) observe(node)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
mutation.observe(document.body, { childList: true, subtree: true })
|
|
55
|
+
|
|
56
|
+
return () => {
|
|
57
|
+
observer.disconnect()
|
|
58
|
+
mutation.disconnect()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { DocSearchInstance, DocSearchProps } from '@docsearch/js'
|
|
2
|
+
import type { FunctionalComponent } from 'preact'
|
|
3
|
+
import { useEffect, useRef } from 'preact/hooks'
|
|
4
|
+
import type { AlgoliaSearchOptions } from '../../shared/search.js'
|
|
5
|
+
import {
|
|
6
|
+
getRelativeDocSearchUrl,
|
|
7
|
+
navigateDocSearchResult,
|
|
8
|
+
validateAlgoliaCredentials
|
|
9
|
+
} from '../../shared/search.js'
|
|
10
|
+
import '@docsearch/css'
|
|
11
|
+
|
|
12
|
+
export interface AlgoliaSearchProps {
|
|
13
|
+
options: AlgoliaSearchOptions
|
|
14
|
+
base: string
|
|
15
|
+
cleanUrls?: boolean
|
|
16
|
+
containerId?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const AlgoliaSearch: FunctionalComponent<AlgoliaSearchProps> = ({
|
|
20
|
+
options,
|
|
21
|
+
base,
|
|
22
|
+
cleanUrls = true,
|
|
23
|
+
containerId = 'pp-docsearch'
|
|
24
|
+
}) => {
|
|
25
|
+
const initKey = useRef(0)
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const credentials = validateAlgoliaCredentials(options)
|
|
29
|
+
if (!credentials.valid) return
|
|
30
|
+
|
|
31
|
+
const currentInit = ++initKey.current
|
|
32
|
+
let destroy: (() => void) | undefined
|
|
33
|
+
let cancelled = false
|
|
34
|
+
|
|
35
|
+
void import('@docsearch/js').then((mod) => {
|
|
36
|
+
if (cancelled || currentInit !== initKey.current) return
|
|
37
|
+
const docsearch = mod.default as unknown as (props: DocSearchProps) => DocSearchInstance
|
|
38
|
+
const instance = docsearch({
|
|
39
|
+
container: `#${containerId}`,
|
|
40
|
+
appId: credentials.appId!,
|
|
41
|
+
apiKey: credentials.apiKey!,
|
|
42
|
+
indexName: credentials.indexName!,
|
|
43
|
+
placeholder: options.placeholder,
|
|
44
|
+
maxResultsPerGroup: options.maxResultsPerGroup,
|
|
45
|
+
disableUserPersonalization: options.disableUserPersonalization,
|
|
46
|
+
initialQuery: options.initialQuery,
|
|
47
|
+
recentSearchesLimit: options.recentSearchesLimit,
|
|
48
|
+
recentSearchesWithFavoritesLimit: options.recentSearchesWithFavoritesLimit,
|
|
49
|
+
insights: options.insights,
|
|
50
|
+
searchParameters: options.searchParameters,
|
|
51
|
+
navigator: {
|
|
52
|
+
navigate({ itemUrl }: { itemUrl: string }) {
|
|
53
|
+
navigateDocSearchResult(itemUrl, base)
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
transformItems: (items) =>
|
|
57
|
+
items.map((item) => ({
|
|
58
|
+
...item,
|
|
59
|
+
url: getRelativeDocSearchUrl(item.url, base, cleanUrls)
|
|
60
|
+
})),
|
|
61
|
+
keyboardShortcuts: {
|
|
62
|
+
'/': false,
|
|
63
|
+
'Ctrl/Cmd+K': false
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
destroy = () => instance.destroy()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return () => {
|
|
70
|
+
cancelled = true
|
|
71
|
+
destroy?.()
|
|
72
|
+
}
|
|
73
|
+
}, [base, cleanUrls, containerId, options])
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const appId = options.appId?.trim()
|
|
77
|
+
if (!appId || document.getElementById('pp-docsearch-preconnect')) return
|
|
78
|
+
const link = document.createElement('link')
|
|
79
|
+
link.id = 'pp-docsearch-preconnect'
|
|
80
|
+
link.rel = 'preconnect'
|
|
81
|
+
link.href = `https://${appId}-dsn.algolia.net`
|
|
82
|
+
link.crossOrigin = ''
|
|
83
|
+
document.head.appendChild(link)
|
|
84
|
+
}, [options.appId])
|
|
85
|
+
|
|
86
|
+
return <div id={containerId} class="pp-docsearch" />
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default AlgoliaSearch
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { FunctionalComponent } from 'preact'
|
|
2
|
+
import type { Feature, FeatureIcon } from '../../shared/pageChrome.js'
|
|
3
|
+
|
|
4
|
+
interface FeaturesProps {
|
|
5
|
+
features: Feature[]
|
|
6
|
+
base: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function withBase(base: string, link: string): string {
|
|
10
|
+
if (/^(?:[a-z]+:)?\/\//i.test(link) || /^(?:data|mailto|tel):/i.test(link) || link.startsWith('#')) {
|
|
11
|
+
return link
|
|
12
|
+
}
|
|
13
|
+
const b = base === '/' ? '' : base.replace(/\/$/, '')
|
|
14
|
+
const l = link.startsWith('/') ? link : `/${link}`
|
|
15
|
+
return `${b}${l}`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function renderIcon(icon: FeatureIcon | undefined, base: string) {
|
|
19
|
+
if (!icon) return null
|
|
20
|
+
if (typeof icon === 'string') return <span class="pp-home-feature-emoji">{icon}</span>
|
|
21
|
+
if ('src' in icon) {
|
|
22
|
+
return (
|
|
23
|
+
<img
|
|
24
|
+
src={withBase(base, icon.src)}
|
|
25
|
+
alt={icon.alt ?? ''}
|
|
26
|
+
width={icon.width}
|
|
27
|
+
height={icon.height}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
return (
|
|
32
|
+
<picture>
|
|
33
|
+
<source media="(prefers-color-scheme: dark)" srcSet={withBase(base, icon.dark)} />
|
|
34
|
+
<img
|
|
35
|
+
src={withBase(base, icon.light)}
|
|
36
|
+
alt={icon.alt ?? ''}
|
|
37
|
+
width={icon.width}
|
|
38
|
+
height={icon.height}
|
|
39
|
+
/>
|
|
40
|
+
</picture>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const Features: FunctionalComponent<FeaturesProps> = ({ features, base }) => (
|
|
45
|
+
<section class="pp-home-features">
|
|
46
|
+
{features.map((feature) => {
|
|
47
|
+
const content = (
|
|
48
|
+
<>
|
|
49
|
+
{feature.icon ? <div class="pp-home-feature-icon">{renderIcon(feature.icon, base)}</div> : null}
|
|
50
|
+
<h2>{feature.title}</h2>
|
|
51
|
+
<p>{feature.details}</p>
|
|
52
|
+
{feature.link && feature.linkText ? <span>{feature.linkText}</span> : null}
|
|
53
|
+
</>
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
return feature.link ? (
|
|
57
|
+
<a
|
|
58
|
+
key={`${feature.title}:${feature.link}`}
|
|
59
|
+
class="pp-home-feature"
|
|
60
|
+
href={withBase(base, feature.link)}
|
|
61
|
+
target={feature.target}
|
|
62
|
+
rel={feature.rel}
|
|
63
|
+
>
|
|
64
|
+
{content}
|
|
65
|
+
</a>
|
|
66
|
+
) : (
|
|
67
|
+
<div key={feature.title} class="pp-home-feature">
|
|
68
|
+
{content}
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
})}
|
|
72
|
+
</section>
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
export default Features
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { FunctionalComponent } from 'preact'
|
|
2
|
+
import type { Hero as HeroConfig, ThemeableImage } from '../../shared/pageChrome.js'
|
|
3
|
+
|
|
4
|
+
interface HeroProps {
|
|
5
|
+
hero: HeroConfig
|
|
6
|
+
base: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function withBase(base: string, link: string): string {
|
|
10
|
+
if (/^(?:[a-z]+:)?\/\//i.test(link) || /^(?:data|mailto|tel):/i.test(link) || link.startsWith('#')) {
|
|
11
|
+
return link
|
|
12
|
+
}
|
|
13
|
+
const b = base === '/' ? '' : base.replace(/\/$/, '')
|
|
14
|
+
const l = link.startsWith('/') ? link : `/${link}`
|
|
15
|
+
return `${b}${l}`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function renderImage(image: ThemeableImage | undefined, base: string) {
|
|
19
|
+
if (!image) return null
|
|
20
|
+
if (typeof image === 'string') {
|
|
21
|
+
return <img src={withBase(base, image)} alt="" />
|
|
22
|
+
}
|
|
23
|
+
if ('src' in image) {
|
|
24
|
+
return <img src={withBase(base, image.src)} alt={image.alt ?? ''} />
|
|
25
|
+
}
|
|
26
|
+
return (
|
|
27
|
+
<picture>
|
|
28
|
+
<source media="(prefers-color-scheme: dark)" srcSet={withBase(base, image.dark)} />
|
|
29
|
+
<img src={withBase(base, image.light)} alt={image.alt ?? ''} />
|
|
30
|
+
</picture>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const Hero: FunctionalComponent<HeroProps> = ({ hero, base }) => (
|
|
35
|
+
<section class="pp-home-hero">
|
|
36
|
+
<div class="pp-home-hero-copy">
|
|
37
|
+
{hero.name ? <p class="pp-home-hero-name">{hero.name}</p> : null}
|
|
38
|
+
{hero.text ? <h1 class="pp-home-hero-text">{hero.text}</h1> : null}
|
|
39
|
+
{hero.tagline ? <p class="pp-home-hero-tagline">{hero.tagline}</p> : null}
|
|
40
|
+
{hero.actions.length > 0 ? (
|
|
41
|
+
<div class="pp-home-hero-actions">
|
|
42
|
+
{hero.actions.map((action) => (
|
|
43
|
+
<a
|
|
44
|
+
key={`${action.text}:${action.link}`}
|
|
45
|
+
class={`pp-home-action pp-home-action-${action.theme}`}
|
|
46
|
+
href={withBase(base, action.link)}
|
|
47
|
+
target={action.target}
|
|
48
|
+
rel={action.rel}
|
|
49
|
+
>
|
|
50
|
+
{action.text}
|
|
51
|
+
</a>
|
|
52
|
+
))}
|
|
53
|
+
</div>
|
|
54
|
+
) : null}
|
|
55
|
+
</div>
|
|
56
|
+
{hero.image ? <div class="pp-home-hero-image">{renderImage(hero.image, base)}</div> : null}
|
|
57
|
+
</section>
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
export default Hero
|