@kamod-ch/preactpress 1.0.0 → 1.0.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 +87 -49
- package/bin/preactpress.mjs +5 -5
- package/dist/client/app.d.ts +1 -1
- package/dist/client/app.d.ts.map +1 -1
- package/dist/client/app.js +34 -38
- package/dist/client/app.js.map +1 -1
- package/dist/client/entry-client.js +11 -12
- package/dist/client/entry-client.js.map +1 -1
- package/dist/client/entry-ssr.d.ts +2 -2
- package/dist/client/entry-ssr.d.ts.map +1 -1
- package/dist/client/entry-ssr.js +16 -16
- package/dist/client/entry-ssr.js.map +1 -1
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/loadPage.d.ts +1 -1
- package/dist/client/loadPage.d.ts.map +1 -1
- package/dist/client/loadPage.js +12 -12
- package/dist/client/loadPage.js.map +1 -1
- package/dist/client/prefetchLinks.js +4 -4
- package/dist/client/prefetchLinks.js.map +1 -1
- package/dist/client/theme-default/AlgoliaSearch.d.ts +3 -3
- package/dist/client/theme-default/AlgoliaSearch.d.ts.map +1 -1
- package/dist/client/theme-default/AlgoliaSearch.js +15 -15
- package/dist/client/theme-default/AlgoliaSearch.js.map +1 -1
- package/dist/client/theme-default/Features.d.ts +2 -2
- package/dist/client/theme-default/Features.d.ts.map +1 -1
- package/dist/client/theme-default/Features.js +10 -8
- package/dist/client/theme-default/Features.js.map +1 -1
- package/dist/client/theme-default/Hero.d.ts +2 -2
- package/dist/client/theme-default/Hero.d.ts.map +1 -1
- package/dist/client/theme-default/Hero.js +9 -7
- package/dist/client/theme-default/Hero.js.map +1 -1
- package/dist/client/theme-default/Layout.d.ts +3 -3
- package/dist/client/theme-default/Layout.d.ts.map +1 -1
- package/dist/client/theme-default/Layout.js +56 -99
- package/dist/client/theme-default/Layout.js.map +1 -1
- package/dist/client/theme-default/Logo.d.ts +2 -2
- package/dist/client/theme-default/Logo.d.ts.map +1 -1
- package/dist/client/theme-default/Logo.js +8 -8
- package/dist/client/theme-default/Logo.js.map +1 -1
- package/dist/client/theme-default/NavLinks.d.ts +2 -2
- package/dist/client/theme-default/NavLinks.d.ts.map +1 -1
- package/dist/client/theme-default/NavLinks.js +3 -3
- package/dist/client/theme-default/NavLinks.js.map +1 -1
- package/dist/client/theme-default/SidebarNav.d.ts +2 -2
- package/dist/client/theme-default/SidebarNav.d.ts.map +1 -1
- package/dist/client/theme-default/SidebarNav.js +3 -3
- package/dist/client/theme-default/SidebarNav.js.map +1 -1
- package/dist/client/theme-default/SocialLinks.d.ts +2 -2
- package/dist/client/theme-default/SocialLinks.d.ts.map +1 -1
- package/dist/client/theme-default/SocialLinks.js +1 -1
- package/dist/client/theme-default/SocialLinks.js.map +1 -1
- package/dist/client/theme-default/ThemeToggle.d.ts +2 -3
- package/dist/client/theme-default/ThemeToggle.d.ts.map +1 -1
- package/dist/client/theme-default/ThemeToggle.js +2 -30
- package/dist/client/theme-default/ThemeToggle.js.map +1 -1
- package/dist/client/theme-default/index.d.ts +1 -1
- package/dist/client/theme-default/index.d.ts.map +1 -1
- package/dist/client/theme-default/index.js +1 -1
- package/dist/client/theme-default/index.js.map +1 -1
- package/dist/client/theme-utils.d.ts +24 -0
- package/dist/client/theme-utils.d.ts.map +1 -0
- package/dist/client/theme-utils.js +107 -0
- package/dist/client/theme-utils.js.map +1 -0
- package/dist/client/types.d.ts +5 -5
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/usePageHead.d.ts +2 -2
- package/dist/client/usePageHead.d.ts.map +1 -1
- package/dist/client/usePageHead.js +61 -56
- package/dist/client/usePageHead.js.map +1 -1
- package/dist/client/useSiteSearch.d.ts.map +1 -1
- package/dist/client/useSiteSearch.js +8 -8
- package/dist/client/useSiteSearch.js.map +1 -1
- package/dist/node/build.d.ts +1 -1
- package/dist/node/build.d.ts.map +1 -1
- package/dist/node/build.js +105 -96
- package/dist/node/build.js.map +1 -1
- package/dist/node/buildCache.d.ts.map +1 -1
- package/dist/node/buildCache.js +7 -7
- package/dist/node/buildCache.js.map +1 -1
- package/dist/node/check.d.ts +1 -1
- package/dist/node/check.d.ts.map +1 -1
- package/dist/node/check.js +52 -52
- package/dist/node/check.js.map +1 -1
- package/dist/node/cli.js +61 -64
- package/dist/node/cli.js.map +1 -1
- package/dist/node/config-helpers.d.ts +4 -4
- package/dist/node/config-helpers.d.ts.map +1 -1
- package/dist/node/config-helpers.js +1 -1
- package/dist/node/config-helpers.js.map +1 -1
- package/dist/node/config.d.ts +4 -4
- package/dist/node/config.d.ts.map +1 -1
- package/dist/node/config.js +37 -40
- package/dist/node/config.js.map +1 -1
- package/dist/node/content.d.ts +4 -4
- package/dist/node/content.d.ts.map +1 -1
- package/dist/node/content.js +28 -28
- package/dist/node/content.js.map +1 -1
- package/dist/node/createContentLoader.d.ts +1 -1
- package/dist/node/createContentLoader.d.ts.map +1 -1
- package/dist/node/createContentLoader.js +3 -3
- package/dist/node/createContentLoader.js.map +1 -1
- package/dist/node/devCss.d.ts +1 -1
- package/dist/node/devCss.d.ts.map +1 -1
- package/dist/node/devCss.js +5 -6
- package/dist/node/devCss.js.map +1 -1
- package/dist/node/devSsr.d.ts +3 -3
- package/dist/node/devSsr.d.ts.map +1 -1
- package/dist/node/devSsr.js +32 -32
- package/dist/node/devSsr.js.map +1 -1
- package/dist/node/dynamicRoutes.d.ts +2 -2
- package/dist/node/dynamicRoutes.d.ts.map +1 -1
- package/dist/node/dynamicRoutes.js +24 -24
- package/dist/node/dynamicRoutes.js.map +1 -1
- package/dist/node/favicon.d.ts +2 -2
- package/dist/node/favicon.d.ts.map +1 -1
- package/dist/node/favicon.js +26 -24
- package/dist/node/favicon.js.map +1 -1
- package/dist/node/feed.d.ts +2 -2
- package/dist/node/feed.d.ts.map +1 -1
- package/dist/node/feed.js +18 -16
- package/dist/node/feed.js.map +1 -1
- package/dist/node/hooks.d.ts +2 -2
- package/dist/node/hooks.d.ts.map +1 -1
- package/dist/node/hooks.js +1 -1
- package/dist/node/hooks.js.map +1 -1
- package/dist/node/html.d.ts +8 -8
- package/dist/node/html.d.ts.map +1 -1
- package/dist/node/html.js +75 -64
- package/dist/node/html.js.map +1 -1
- package/dist/node/index.d.ts +11 -11
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +8 -8
- package/dist/node/index.js.map +1 -1
- package/dist/node/init.d.ts +2 -0
- package/dist/node/init.d.ts.map +1 -1
- package/dist/node/init.js +59 -27
- package/dist/node/init.js.map +1 -1
- package/dist/node/lastUpdated.d.ts +2 -2
- package/dist/node/lastUpdated.d.ts.map +1 -1
- package/dist/node/lastUpdated.js +7 -4
- package/dist/node/lastUpdated.js.map +1 -1
- package/dist/node/loadSiteModule.js +2 -2
- package/dist/node/loadSiteModule.js.map +1 -1
- package/dist/node/markdown.d.ts +2 -2
- package/dist/node/markdown.d.ts.map +1 -1
- package/dist/node/markdown.js +110 -110
- package/dist/node/markdown.js.map +1 -1
- package/dist/node/markdownHeadings.d.ts +1 -1
- package/dist/node/markdownHeadings.d.ts.map +1 -1
- package/dist/node/markdownHeadings.js +11 -11
- package/dist/node/markdownHeadings.js.map +1 -1
- package/dist/node/markdownInclude.d.ts.map +1 -1
- package/dist/node/markdownInclude.js +11 -11
- package/dist/node/markdownInclude.js.map +1 -1
- package/dist/node/markdownSnippets.d.ts.map +1 -1
- package/dist/node/markdownSnippets.js +34 -34
- package/dist/node/markdownSnippets.js.map +1 -1
- package/dist/node/mdx.d.ts +1 -1
- package/dist/node/mdx.d.ts.map +1 -1
- package/dist/node/mdx.js +4 -4
- package/dist/node/mdx.js.map +1 -1
- package/dist/node/packageRoot.d.ts.map +1 -1
- package/dist/node/packageRoot.js +4 -4
- package/dist/node/packageRoot.js.map +1 -1
- package/dist/node/pageDataLoaders.d.ts +2 -2
- package/dist/node/pageDataLoaders.d.ts.map +1 -1
- package/dist/node/pageDataLoaders.js +24 -20
- package/dist/node/pageDataLoaders.js.map +1 -1
- package/dist/node/paths.d.ts.map +1 -1
- package/dist/node/paths.js +4 -4
- package/dist/node/paths.js.map +1 -1
- package/dist/node/plugin.d.ts +3 -3
- package/dist/node/plugin.d.ts.map +1 -1
- package/dist/node/plugin.js +66 -66
- package/dist/node/plugin.js.map +1 -1
- package/dist/node/resolveDeps.js +10 -10
- package/dist/node/resolveDeps.js.map +1 -1
- package/dist/node/serve.d.ts.map +1 -1
- package/dist/node/serve.js +13 -15
- package/dist/node/serve.js.map +1 -1
- package/dist/node/server.d.ts +3 -3
- package/dist/node/server.d.ts.map +1 -1
- package/dist/node/server.js +28 -25
- package/dist/node/server.js.map +1 -1
- package/dist/node/siteConfig.d.ts +12 -12
- package/dist/node/siteConfig.d.ts.map +1 -1
- package/dist/node/tagIndex.d.ts +5 -5
- package/dist/node/tagIndex.d.ts.map +1 -1
- package/dist/node/tagIndex.js +10 -10
- package/dist/node/tagIndex.js.map +1 -1
- package/dist/shared/contentChunk.d.ts.map +1 -1
- package/dist/shared/contentChunk.js +6 -6
- package/dist/shared/contentChunk.js.map +1 -1
- package/dist/shared/contentSchema.d.ts.map +1 -1
- package/dist/shared/contentSchema.js +11 -11
- package/dist/shared/contentSchema.js.map +1 -1
- package/dist/shared/deadLinks.d.ts.map +1 -1
- package/dist/shared/deadLinks.js +6 -6
- package/dist/shared/deadLinks.js.map +1 -1
- package/dist/shared/escapeHtml.js +4 -4
- package/dist/shared/escapeHtml.js.map +1 -1
- package/dist/shared/index.d.ts +14 -14
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +14 -14
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/locale.d.ts +1 -1
- package/dist/shared/locale.d.ts.map +1 -1
- package/dist/shared/locale.js +10 -10
- package/dist/shared/locale.js.map +1 -1
- package/dist/shared/pageChrome.d.ts +4 -4
- package/dist/shared/pageChrome.d.ts.map +1 -1
- package/dist/shared/pageChrome.js +21 -21
- package/dist/shared/pageChrome.js.map +1 -1
- package/dist/shared/pageHead.d.ts +1 -1
- package/dist/shared/pageHead.d.ts.map +1 -1
- package/dist/shared/pageHead.js +4 -4
- package/dist/shared/pageHead.js.map +1 -1
- package/dist/shared/pageMeta.d.ts +5 -5
- package/dist/shared/pageMeta.d.ts.map +1 -1
- package/dist/shared/pageMeta.js +15 -17
- package/dist/shared/pageMeta.js.map +1 -1
- package/dist/shared/rewrites.d.ts +1 -1
- package/dist/shared/rewrites.d.ts.map +1 -1
- package/dist/shared/rewrites.js +2 -2
- package/dist/shared/rewrites.js.map +1 -1
- package/dist/shared/route.js +5 -5
- package/dist/shared/route.js.map +1 -1
- package/dist/shared/search.d.ts +3 -3
- package/dist/shared/search.d.ts.map +1 -1
- package/dist/shared/search.js +14 -14
- package/dist/shared/search.js.map +1 -1
- package/dist/shared/sidebar.d.ts +1 -1
- package/dist/shared/sidebar.d.ts.map +1 -1
- package/dist/shared/sidebar.js +4 -4
- package/dist/shared/sidebar.js.map +1 -1
- package/dist/shared/slug.d.ts +1 -1
- package/dist/shared/slug.d.ts.map +1 -1
- package/dist/shared/slug.js +5 -5
- package/dist/shared/slug.js.map +1 -1
- package/dist/shared/socialIcons.d.ts.map +1 -1
- package/dist/shared/socialIcons.js +4 -4
- package/dist/shared/socialIcons.js.map +1 -1
- package/dist/shared/tags.js +8 -8
- package/dist/shared/tags.js.map +1 -1
- package/dist/shared/theme.d.ts +1 -1
- package/dist/shared/theme.d.ts.map +1 -1
- package/dist/shared/theme.js +16 -10
- package/dist/shared/theme.js.map +1 -1
- package/dist/shared/themeLabels.d.ts +1 -1
- package/dist/shared/themeLabels.d.ts.map +1 -1
- package/dist/shared/themeLabels.js +26 -26
- package/dist/shared/themeLabels.js.map +1 -1
- package/dist/shared/url.d.ts.map +1 -1
- package/dist/shared/url.js +3 -3
- package/dist/shared/url.js.map +1 -1
- package/package.json +33 -9
- package/src/client/app.tsx +89 -92
- package/src/client/entry-client.tsx +17 -19
- package/src/client/entry-ssr.tsx +33 -33
- package/src/client/index.ts +16 -2
- package/src/client/loadPage.ts +37 -38
- package/src/client/prefetchLinks.ts +30 -30
- package/src/client/theme-default/AlgoliaSearch.tsx +46 -46
- package/src/client/theme-default/Features.tsx +27 -21
- package/src/client/theme-default/Hero.tsx +22 -18
- package/src/client/theme-default/Layout.tsx +189 -244
- package/src/client/theme-default/Logo.tsx +30 -40
- package/src/client/theme-default/NavLinks.tsx +21 -21
- package/src/client/theme-default/SidebarNav.tsx +29 -29
- package/src/client/theme-default/SocialLinks.tsx +11 -11
- package/src/client/theme-default/ThemeToggle.tsx +2 -78
- package/src/client/theme-default/index.ts +1 -1
- package/src/client/theme-default/styles.css +30 -21
- package/src/client/theme-utils.tsx +184 -0
- package/src/client/types.ts +30 -24
- package/src/client/usePageHead.ts +128 -128
- package/src/client/useSiteSearch.ts +34 -34
- package/src/client/virtual.d.ts +76 -76
- package/src/shared/contentChunk.ts +6 -6
- package/src/shared/contentSchema.ts +52 -49
- package/src/shared/deadLinks.ts +16 -16
- package/src/shared/escapeHtml.ts +5 -5
- package/src/shared/index.ts +21 -25
- package/src/shared/locale.ts +46 -46
- package/src/shared/pageChrome.ts +123 -123
- package/src/shared/pageHead.ts +16 -16
- package/src/shared/pageMeta.ts +79 -79
- package/src/shared/rewrites.ts +14 -16
- package/src/shared/route.ts +7 -7
- package/src/shared/search.ts +52 -52
- package/src/shared/sidebar.ts +28 -28
- package/src/shared/slug.ts +13 -13
- package/src/shared/socialIcons.ts +12 -14
- package/src/shared/tags.ts +20 -20
- package/src/shared/theme.ts +22 -13
- package/src/shared/themeLabels.ts +45 -45
- package/src/shared/url.ts +6 -10
- package/templates/default/.preactpress/config.ts +17 -17
- package/templates/default/README.md +16 -16
- package/templates/default/guide/first-five-minutes.md +21 -21
- package/templates/default/index.html +1 -1
- package/templates/default/index.md +9 -9
- package/templates/default/package.json +1 -1
- package/templates/default/pnpm-lock.yaml +5 -5
- package/templates/docs/.preactpress/config.ts +76 -56
- package/templates/docs/README.md +6 -6
- package/templates/docs/components/BenefitsGrid.tsx +45 -0
- package/templates/docs/components/CliBlock.tsx +38 -0
- package/templates/docs/components/ComparisonTable.tsx +60 -0
- package/templates/docs/components/CopyableCommand.tsx +86 -0
- package/templates/docs/components/Counter.tsx +7 -5
- package/templates/docs/components/MarketingHero.tsx +63 -0
- package/templates/docs/components/MdxDemo.tsx +96 -0
- package/templates/docs/components/References.tsx +62 -0
- package/templates/docs/components/TemplateGallery.tsx +46 -0
- package/templates/docs/components/marketing.css +992 -0
- package/templates/docs/examples/algolia-docsearch.md +33 -0
- package/templates/docs/examples/content-loader.data.ts +11 -0
- package/templates/docs/examples/content-loader.md +29 -0
- package/templates/docs/examples/dynamic-routes.md +16 -0
- package/templates/docs/examples/static-assets.md +13 -0
- package/templates/docs/guide/advanced.md +4 -4
- package/templates/docs/guide/commands.md +10 -10
- package/templates/docs/guide/configuration.md +43 -43
- package/templates/docs/guide/creating-pages.md +60 -39
- package/templates/docs/guide/custom-themes.md +9 -9
- package/templates/docs/guide/deploy.md +29 -29
- package/templates/docs/guide/first-five-minutes.md +22 -22
- package/templates/docs/guide/getting-started.md +29 -31
- package/templates/docs/guide/markdown-and-mdx.md +1 -1
- package/templates/docs/guide/routing.md +40 -40
- package/templates/docs/guide/what-is-preactpress.md +18 -18
- package/templates/docs/index.html +1 -1
- package/templates/docs/index.mdx +25 -0
- package/templates/docs/interactive.mdx +1 -1
- package/templates/docs/markdown-examples.md +73 -21
- package/templates/docs/package.json +1 -1
- package/templates/docs/packages/[pkg].md +15 -0
- package/templates/docs/packages/[pkg].paths.ts +20 -0
- package/templates/docs/parts/include-body.md +1 -0
- package/templates/docs/pnpm-lock.yaml +5 -5
- package/templates/docs/public/preactpress-example.txt +1 -0
- package/templates/docs/snippets/greet.ts +1 -1
- package/templates/hono/.preactpress/config.ts +65 -65
- package/templates/hono/.preactpress/theme/CodeSnippet.tsx +15 -15
- package/templates/hono/.preactpress/theme/FeatureGrid.tsx +7 -7
- package/templates/hono/.preactpress/theme/Hero.tsx +13 -13
- package/templates/hono/.preactpress/theme/Layout.tsx +122 -164
- package/templates/hono/.preactpress/theme/Logo.tsx +6 -6
- package/templates/hono/.preactpress/theme/ThemeToggle.tsx +3 -70
- package/templates/hono/.preactpress/theme/hono.css +31 -14
- package/templates/hono/README.md +17 -15
- package/templates/hono/components/Counter.tsx +7 -5
- package/templates/hono/de/guide/configuration.md +18 -20
- package/templates/hono/de/guide/deploy.md +29 -29
- package/templates/hono/de/guide/first-five-minutes.md +21 -21
- package/templates/hono/de/guide/getting-started.md +29 -29
- package/templates/hono/de/guide/routing.md +26 -25
- package/templates/hono/de/guide/seiten-erstellen.md +39 -39
- package/templates/hono/de/guide/what-is-preactpress.md +18 -18
- package/templates/hono/de/index.mdx +20 -17
- package/templates/hono/de/interactive.mdx +1 -1
- package/templates/hono/de/markdown-examples.md +6 -6
- package/templates/hono/de/parts/include-body.md +1 -0
- package/templates/hono/de/snippets/greet.ts +1 -1
- package/templates/hono/guide/configuration.md +25 -25
- package/templates/hono/guide/creating-pages.md +39 -39
- package/templates/hono/guide/deploy.md +29 -29
- package/templates/hono/guide/first-five-minutes.md +21 -21
- package/templates/hono/guide/getting-started.md +29 -29
- package/templates/hono/guide/routing.md +40 -40
- package/templates/hono/guide/what-is-preactpress.md +18 -18
- package/templates/hono/index.html +1 -1
- package/templates/hono/index.mdx +21 -17
- package/templates/hono/interactive.mdx +1 -1
- package/templates/hono/markdown-examples.md +6 -6
- package/templates/hono/package.json +1 -1
- package/templates/hono/parts/include-body.md +1 -0
- package/templates/hono/pnpm-lock.yaml +5 -5
- package/templates/hono/snippets/greet.ts +1 -1
- package/templates/magazine/.preactpress/config.ts +19 -19
- package/templates/magazine/.preactpress/theme/Layout.tsx +69 -172
- package/templates/magazine/.preactpress/theme/TeaserGrid.tsx +14 -14
- package/templates/magazine/.preactpress/theme/ThemeToggle.tsx +4 -70
- package/templates/magazine/.preactpress/theme/magazine.css +13 -8
- package/templates/magazine/README.md +30 -0
- package/templates/magazine/article-markets.md +2 -2
- package/templates/magazine/article-tech.mdx +10 -10
- package/templates/magazine/index.data.ts +9 -9
- package/templates/magazine/index.html +5 -1
- package/templates/magazine/index.mdx +1 -1
- package/templates/magazine/package.json +1 -1
- package/templates/magazine/pnpm-lock.yaml +2917 -0
- package/templates/docs/about.md +0 -10
- package/templates/docs/dist/404.html +0 -29
- package/templates/docs/dist/about/index.html +0 -32
- package/templates/docs/dist/assets/esm-DzlBxN5p.js +0 -110
- package/templates/docs/dist/assets/interactive-64o6YwrR.js +0 -9
- package/templates/docs/dist/assets/interactive-BedCloEw.js +0 -9
- package/templates/docs/dist/assets/main-BVLeh8GO.js +0 -1
- package/templates/docs/dist/assets/main-CreUBb3N.js +0 -1
- package/templates/docs/dist/assets/main-oodK-zZy.css +0 -2
- package/templates/docs/dist/de/guide/getting-started/index.html +0 -36
- package/templates/docs/dist/de/guide/what-is-preactpress/index.html +0 -38
- package/templates/docs/dist/de/index.html +0 -29
- package/templates/docs/dist/favicon-32.png +0 -0
- package/templates/docs/dist/favicon.png +0 -0
- package/templates/docs/dist/favicon.svg +0 -28
- package/templates/docs/dist/guide/advanced/index.html +0 -53
- package/templates/docs/dist/guide/commands/index.html +0 -89
- package/templates/docs/dist/guide/configuration/index.html +0 -196
- package/templates/docs/dist/guide/creating-pages/index.html +0 -234
- package/templates/docs/dist/guide/custom-themes/index.html +0 -52
- package/templates/docs/dist/guide/default-theme/index.html +0 -53
- package/templates/docs/dist/guide/deploy/index.html +0 -195
- package/templates/docs/dist/guide/first-five-minutes/index.html +0 -99
- package/templates/docs/dist/guide/getting-started/index.html +0 -173
- package/templates/docs/dist/guide/markdown-and-mdx/index.html +0 -59
- package/templates/docs/dist/guide/routing/index.html +0 -192
- package/templates/docs/dist/guide/what-is-preactpress/index.html +0 -141
- package/templates/docs/dist/index.html +0 -30
- package/templates/docs/dist/interactive/index.html +0 -37
- package/templates/docs/dist/markdown-examples/index.html +0 -231
- package/templates/docs/dist/preactpress-content/404.json +0 -8
- package/templates/docs/dist/preactpress-content/_index.json +0 -50
- package/templates/docs/dist/preactpress-content/about.json +0 -15
- package/templates/docs/dist/preactpress-content/de.json +0 -45
- package/templates/docs/dist/preactpress-content/de__guide__getting-started.json +0 -26
- package/templates/docs/dist/preactpress-content/de__guide__what-is-preactpress.json +0 -21
- package/templates/docs/dist/preactpress-content/guide__advanced.json +0 -46
- package/templates/docs/dist/preactpress-content/guide__commands.json +0 -26
- package/templates/docs/dist/preactpress-content/guide__configuration.json +0 -51
- package/templates/docs/dist/preactpress-content/guide__creating-pages.json +0 -71
- package/templates/docs/dist/preactpress-content/guide__custom-themes.json +0 -15
- package/templates/docs/dist/preactpress-content/guide__default-theme.json +0 -36
- package/templates/docs/dist/preactpress-content/guide__deploy.json +0 -56
- package/templates/docs/dist/preactpress-content/guide__first-five-minutes.json +0 -36
- package/templates/docs/dist/preactpress-content/guide__getting-started.json +0 -51
- package/templates/docs/dist/preactpress-content/guide__markdown-and-mdx.json +0 -31
- package/templates/docs/dist/preactpress-content/guide__routing.json +0 -71
- package/templates/docs/dist/preactpress-content/guide__what-is-preactpress.json +0 -51
- package/templates/docs/dist/preactpress-content/markdown-examples.json +0 -71
- package/templates/docs/dist/preactpress-content/tags__markdown.json +0 -16
- package/templates/docs/dist/preactpress-search.json +0 -166
- package/templates/docs/dist/preactpress-theme.js +0 -1
- package/templates/docs/dist/tags/markdown/index.html +0 -32
- package/templates/docs/index.md +0 -28
- package/templates/hono/dist/404.html +0 -29
- package/templates/hono/dist/README/index.html +0 -104
- package/templates/hono/dist/about/index.html +0 -32
- package/templates/hono/dist/assets/Counter-CCEByS-J.js +0 -1
- package/templates/hono/dist/assets/Hero--o6WMNvm.js +0 -2
- package/templates/hono/dist/assets/de-D5r6Ye70.js +0 -10
- package/templates/hono/dist/assets/hono-BXWYYdyv.js +0 -10
- package/templates/hono/dist/assets/interactive-Bxo-WBpC.js +0 -9
- package/templates/hono/dist/assets/interactive-BznI4IQ3.js +0 -9
- package/templates/hono/dist/assets/main-Bqi-VFEk.js +0 -2
- package/templates/hono/dist/assets/main-DIIN7FO0.css +0 -1
- package/templates/hono/dist/de/about/index.html +0 -32
- package/templates/hono/dist/de/guide/commands/index.html +0 -41
- package/templates/hono/dist/de/guide/configuration/index.html +0 -105
- package/templates/hono/dist/de/guide/deploy/index.html +0 -195
- package/templates/hono/dist/de/guide/first-five-minutes/index.html +0 -99
- package/templates/hono/dist/de/guide/getting-started/index.html +0 -173
- package/templates/hono/dist/de/guide/routing/index.html +0 -165
- package/templates/hono/dist/de/guide/seiten-erstellen/index.html +0 -234
- package/templates/hono/dist/de/guide/what-is-preactpress/index.html +0 -141
- package/templates/hono/dist/de/index.html +0 -30
- package/templates/hono/dist/de/interactive/index.html +0 -37
- package/templates/hono/dist/de/markdown-examples/index.html +0 -97
- package/templates/hono/dist/de/parts/include-body/index.html +0 -36
- package/templates/hono/dist/de/tags/markdown/index.html +0 -32
- package/templates/hono/dist/favicon-32.png +0 -0
- package/templates/hono/dist/favicon.png +0 -0
- package/templates/hono/dist/favicon.svg +0 -28
- package/templates/hono/dist/guide/commands/index.html +0 -41
- package/templates/hono/dist/guide/configuration/index.html +0 -158
- package/templates/hono/dist/guide/creating-pages/index.html +0 -234
- package/templates/hono/dist/guide/deploy/index.html +0 -195
- package/templates/hono/dist/guide/first-five-minutes/index.html +0 -99
- package/templates/hono/dist/guide/getting-started/index.html +0 -173
- package/templates/hono/dist/guide/routing/index.html +0 -165
- package/templates/hono/dist/guide/what-is-preactpress/index.html +0 -141
- package/templates/hono/dist/index.html +0 -30
- package/templates/hono/dist/interactive/index.html +0 -37
- package/templates/hono/dist/markdown-examples/index.html +0 -105
- package/templates/hono/dist/partials/shared-note/index.html +0 -30
- package/templates/hono/dist/parts/include-body/index.html +0 -36
- package/templates/hono/dist/preactpress-content/404.json +0 -8
- package/templates/hono/dist/preactpress-content/README.json +0 -26
- package/templates/hono/dist/preactpress-content/about.json +0 -15
- package/templates/hono/dist/preactpress-content/de__about.json +0 -15
- package/templates/hono/dist/preactpress-content/de__guide__commands.json +0 -36
- package/templates/hono/dist/preactpress-content/de__guide__configuration.json +0 -41
- package/templates/hono/dist/preactpress-content/de__guide__deploy.json +0 -56
- package/templates/hono/dist/preactpress-content/de__guide__first-five-minutes.json +0 -36
- package/templates/hono/dist/preactpress-content/de__guide__getting-started.json +0 -51
- package/templates/hono/dist/preactpress-content/de__guide__routing.json +0 -61
- package/templates/hono/dist/preactpress-content/de__guide__seiten-erstellen.json +0 -71
- package/templates/hono/dist/preactpress-content/de__guide__what-is-preactpress.json +0 -51
- package/templates/hono/dist/preactpress-content/de__markdown-examples.json +0 -131
- package/templates/hono/dist/preactpress-content/de__parts__include-body.json +0 -16
- package/templates/hono/dist/preactpress-content/de__tags__markdown.json +0 -16
- package/templates/hono/dist/preactpress-content/guide__commands.json +0 -36
- package/templates/hono/dist/preactpress-content/guide__configuration.json +0 -51
- package/templates/hono/dist/preactpress-content/guide__creating-pages.json +0 -71
- package/templates/hono/dist/preactpress-content/guide__deploy.json +0 -56
- package/templates/hono/dist/preactpress-content/guide__first-five-minutes.json +0 -36
- package/templates/hono/dist/preactpress-content/guide__getting-started.json +0 -51
- package/templates/hono/dist/preactpress-content/guide__routing.json +0 -61
- package/templates/hono/dist/preactpress-content/guide__what-is-preactpress.json +0 -51
- package/templates/hono/dist/preactpress-content/markdown-examples.json +0 -141
- package/templates/hono/dist/preactpress-content/partials__shared-note.json +0 -10
- package/templates/hono/dist/preactpress-content/parts__include-body.json +0 -16
- package/templates/hono/dist/preactpress-content/tags__markdown.json +0 -16
- package/templates/hono/dist/preactpress-search.json +0 -242
- package/templates/hono/dist/preactpress-theme.js +0 -1
- package/templates/hono/dist/tags/markdown/index.html +0 -32
package/src/client/app.tsx
CHANGED
|
@@ -1,105 +1,101 @@
|
|
|
1
|
-
import { useEffect, useState } from
|
|
2
|
-
import Layout from
|
|
3
|
-
import { pagesMeta, routes } from
|
|
4
|
-
import { i18n, mpa, site, themeConfig } from
|
|
5
|
-
import type { PageView } from
|
|
6
|
-
import type { ResolvedLocale } from
|
|
7
|
-
import { usePageHead } from
|
|
8
|
-
import { normalizeRoute, routeFromPathname } from
|
|
9
|
-
import { loadPage, prefetchPage, seedPage } from
|
|
10
|
-
import { setupViewportPrefetch } from
|
|
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
11
|
import {
|
|
12
12
|
localeFromRoute,
|
|
13
13
|
localizedRouteForLocale,
|
|
14
14
|
siteForRoute,
|
|
15
|
-
themeConfigForRoute
|
|
16
|
-
} from
|
|
15
|
+
themeConfigForRoute,
|
|
16
|
+
} from "../shared/locale.js";
|
|
17
17
|
|
|
18
18
|
function routeFromLocation(): string {
|
|
19
|
-
return routeFromPathname(window.location.pathname, site.base)
|
|
19
|
+
return routeFromPathname(window.location.pathname, site.base);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
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 ===
|
|
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
26
|
if (base && url.pathname !== base && !url.pathname.startsWith(`${base}/`)) {
|
|
27
|
-
return undefined
|
|
27
|
+
return undefined;
|
|
28
28
|
}
|
|
29
|
-
const path = base ? url.pathname.slice(base.length) ||
|
|
30
|
-
return normalizeRoute(path)
|
|
29
|
+
const path = base ? url.pathname.slice(base.length) || "/" : url.pathname;
|
|
30
|
+
return normalizeRoute(path);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function anchorFromEvent(event: MouseEvent): HTMLAnchorElement | null {
|
|
34
|
-
const target = event.target
|
|
34
|
+
const target = event.target;
|
|
35
35
|
const element =
|
|
36
|
-
target instanceof Element
|
|
37
|
-
|
|
38
|
-
: target instanceof Text
|
|
39
|
-
? target.parentElement
|
|
40
|
-
: null
|
|
41
|
-
return element?.closest('a[href]') ?? null
|
|
36
|
+
target instanceof Element ? target : target instanceof Text ? target.parentElement : null;
|
|
37
|
+
return element?.closest("a[href]") ?? null;
|
|
42
38
|
}
|
|
43
39
|
|
|
44
40
|
function loadingPage(route: string): PageView {
|
|
45
|
-
const meta = pagesMeta[route]
|
|
41
|
+
const meta = pagesMeta[route];
|
|
46
42
|
return {
|
|
47
|
-
kind:
|
|
48
|
-
html:
|
|
43
|
+
kind: "markdown",
|
|
44
|
+
html: "<p>Loading...</p>",
|
|
49
45
|
title: meta?.title,
|
|
50
46
|
description: meta?.description,
|
|
51
47
|
tags: meta?.tags,
|
|
52
48
|
image: meta?.image,
|
|
53
49
|
pageType: meta?.pageType,
|
|
54
50
|
meta: meta?.meta ?? {},
|
|
55
|
-
headings: meta?.headings ?? []
|
|
56
|
-
}
|
|
51
|
+
headings: meta?.headings ?? [],
|
|
52
|
+
};
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
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)
|
|
56
|
+
const [currentRoute, setCurrentRoute] = useState(() => normalizeRoute(routePath));
|
|
57
|
+
const [page, setPage] = useState<PageView>(() => initialPage ?? loadingPage(routePath));
|
|
58
|
+
const availableRoutes = new Set(routes);
|
|
59
|
+
const activeLocale = localeFromRoute(currentRoute, i18n);
|
|
60
|
+
const activeSite = siteForRoute(site, currentRoute, i18n);
|
|
61
|
+
const activeThemeConfig = themeConfigForRoute(themeConfig, currentRoute, i18n);
|
|
66
62
|
|
|
67
63
|
useEffect(() => {
|
|
68
|
-
if (initialPage) seedPage(normalizeRoute(routePath), initialPage)
|
|
69
|
-
}, [initialPage, routePath])
|
|
64
|
+
if (initialPage) seedPage(normalizeRoute(routePath), initialPage);
|
|
65
|
+
}, [initialPage, routePath]);
|
|
70
66
|
|
|
71
67
|
useEffect(() => {
|
|
72
|
-
let cancelled = false
|
|
73
|
-
setPage(loadingPage(currentRoute))
|
|
68
|
+
let cancelled = false;
|
|
69
|
+
setPage(loadingPage(currentRoute));
|
|
74
70
|
void loadPage(currentRoute, site.base)
|
|
75
71
|
.then((loaded) => {
|
|
76
|
-
if (!cancelled) setPage(loaded)
|
|
72
|
+
if (!cancelled) setPage(loaded);
|
|
77
73
|
})
|
|
78
74
|
.catch(() => {
|
|
79
75
|
if (!cancelled) {
|
|
80
76
|
setPage({
|
|
81
|
-
kind:
|
|
82
|
-
html:
|
|
83
|
-
title:
|
|
77
|
+
kind: "markdown",
|
|
78
|
+
html: "<p>Page not found.</p>",
|
|
79
|
+
title: "404",
|
|
84
80
|
description: activeSite.description,
|
|
85
81
|
meta: {},
|
|
86
|
-
headings: []
|
|
87
|
-
})
|
|
82
|
+
headings: [],
|
|
83
|
+
});
|
|
88
84
|
}
|
|
89
|
-
})
|
|
85
|
+
});
|
|
90
86
|
return () => {
|
|
91
|
-
cancelled = true
|
|
92
|
-
}
|
|
93
|
-
}, [activeSite.description, currentRoute])
|
|
87
|
+
cancelled = true;
|
|
88
|
+
};
|
|
89
|
+
}, [activeSite.description, currentRoute]);
|
|
94
90
|
|
|
95
91
|
useEffect(() => {
|
|
96
|
-
const prefetch = (route: string) => prefetchPage(route, site.base)
|
|
97
|
-
const stopViewportPrefetch = setupViewportPrefetch(routeFromHref, prefetch)
|
|
92
|
+
const prefetch = (route: string) => prefetchPage(route, site.base);
|
|
93
|
+
const stopViewportPrefetch = setupViewportPrefetch(routeFromHref, prefetch);
|
|
98
94
|
if (mpa) {
|
|
99
|
-
return () => stopViewportPrefetch()
|
|
95
|
+
return () => stopViewportPrefetch();
|
|
100
96
|
}
|
|
101
97
|
|
|
102
|
-
const onPopState = () => setCurrentRoute(routeFromLocation())
|
|
98
|
+
const onPopState = () => setCurrentRoute(routeFromLocation());
|
|
103
99
|
const onClick = (event: MouseEvent) => {
|
|
104
100
|
if (
|
|
105
101
|
event.defaultPrevented ||
|
|
@@ -109,44 +105,44 @@ export function App({ routePath, initialPage }: { routePath: string; initialPage
|
|
|
109
105
|
event.ctrlKey ||
|
|
110
106
|
event.shiftKey
|
|
111
107
|
) {
|
|
112
|
-
return
|
|
108
|
+
return;
|
|
113
109
|
}
|
|
114
|
-
const link = anchorFromEvent(event)
|
|
115
|
-
if (!link || link.target || link.hasAttribute(
|
|
116
|
-
const route = routeFromHref(link.href)
|
|
117
|
-
if (!route) return
|
|
118
|
-
const url = new URL(link.href)
|
|
110
|
+
const link = anchorFromEvent(event);
|
|
111
|
+
if (!link || link.target || link.hasAttribute("download")) return;
|
|
112
|
+
const route = routeFromHref(link.href);
|
|
113
|
+
if (!route) return;
|
|
114
|
+
const url = new URL(link.href);
|
|
119
115
|
if (url.hash && route === currentRoute) {
|
|
120
|
-
document.getElementById(url.hash.slice(1))?.scrollIntoView()
|
|
121
|
-
return
|
|
116
|
+
document.getElementById(url.hash.slice(1))?.scrollIntoView();
|
|
117
|
+
return;
|
|
122
118
|
}
|
|
123
|
-
event.preventDefault()
|
|
124
|
-
window.history.pushState({},
|
|
125
|
-
setCurrentRoute(route)
|
|
126
|
-
window.scrollTo({ top: 0 })
|
|
127
|
-
}
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
window.history.pushState({}, "", url);
|
|
121
|
+
setCurrentRoute(route);
|
|
122
|
+
window.scrollTo({ top: 0 });
|
|
123
|
+
};
|
|
128
124
|
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(
|
|
135
|
-
document.addEventListener(
|
|
136
|
-
document.addEventListener(
|
|
125
|
+
const link = anchorFromEvent(event);
|
|
126
|
+
if (!link) return;
|
|
127
|
+
const route = routeFromHref(link.href);
|
|
128
|
+
if (route) prefetch(route);
|
|
129
|
+
};
|
|
130
|
+
window.addEventListener("popstate", onPopState);
|
|
131
|
+
document.addEventListener("click", onClick);
|
|
132
|
+
document.addEventListener("mouseenter", onMouseEnter, true);
|
|
137
133
|
return () => {
|
|
138
|
-
stopViewportPrefetch()
|
|
139
|
-
window.removeEventListener(
|
|
140
|
-
document.removeEventListener(
|
|
141
|
-
document.removeEventListener(
|
|
142
|
-
}
|
|
143
|
-
}, [currentRoute, mpa])
|
|
134
|
+
stopViewportPrefetch();
|
|
135
|
+
window.removeEventListener("popstate", onPopState);
|
|
136
|
+
document.removeEventListener("click", onClick);
|
|
137
|
+
document.removeEventListener("mouseenter", onMouseEnter, true);
|
|
138
|
+
};
|
|
139
|
+
}, [currentRoute, mpa]);
|
|
144
140
|
|
|
145
141
|
useEffect(() => {
|
|
146
142
|
if (currentRoute !== normalizeRoute(routePath)) {
|
|
147
|
-
document.getElementById(
|
|
143
|
+
document.getElementById("content")?.focus();
|
|
148
144
|
}
|
|
149
|
-
}, [currentRoute, routePath])
|
|
145
|
+
}, [currentRoute, routePath]);
|
|
150
146
|
|
|
151
147
|
usePageHead({
|
|
152
148
|
site,
|
|
@@ -154,7 +150,7 @@ export function App({ routePath, initialPage }: { routePath: string; initialPage
|
|
|
154
150
|
routes: availableRoutes,
|
|
155
151
|
route: currentRoute,
|
|
156
152
|
page:
|
|
157
|
-
page?.kind ===
|
|
153
|
+
page?.kind === "markdown"
|
|
158
154
|
? {
|
|
159
155
|
meta: page.meta,
|
|
160
156
|
title: page.title,
|
|
@@ -162,8 +158,8 @@ export function App({ routePath, initialPage }: { routePath: string; initialPage
|
|
|
162
158
|
tags: page.tags,
|
|
163
159
|
image: page.image,
|
|
164
160
|
pageType: page.pageType,
|
|
165
|
-
kind:
|
|
166
|
-
html: page.html
|
|
161
|
+
kind: "markdown",
|
|
162
|
+
html: page.html,
|
|
167
163
|
}
|
|
168
164
|
: page
|
|
169
165
|
? {
|
|
@@ -173,10 +169,10 @@ export function App({ routePath, initialPage }: { routePath: string; initialPage
|
|
|
173
169
|
tags: page.tags,
|
|
174
170
|
image: page.image,
|
|
175
171
|
pageType: page.pageType,
|
|
176
|
-
kind:
|
|
172
|
+
kind: "mdx",
|
|
177
173
|
}
|
|
178
|
-
: undefined
|
|
179
|
-
})
|
|
174
|
+
: undefined,
|
|
175
|
+
});
|
|
180
176
|
|
|
181
177
|
return (
|
|
182
178
|
<Layout
|
|
@@ -188,7 +184,8 @@ export function App({ routePath, initialPage }: { routePath: string; initialPage
|
|
|
188
184
|
locale={activeLocale}
|
|
189
185
|
locales={i18n?.locales}
|
|
190
186
|
localizeRoute={(locale: ResolvedLocale) =>
|
|
191
|
-
localizedRouteForLocale(currentRoute, locale, i18n, availableRoutes)
|
|
187
|
+
localizedRouteForLocale(currentRoute, locale, i18n, availableRoutes)
|
|
188
|
+
}
|
|
192
189
|
/>
|
|
193
|
-
)
|
|
190
|
+
);
|
|
194
191
|
}
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import { hydrate } from
|
|
2
|
-
import { App } from
|
|
3
|
-
import type { PageView } from
|
|
4
|
-
import { loadPage, seedPage } from
|
|
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
5
|
|
|
6
6
|
function currentRoute(): string {
|
|
7
|
-
const base = (import.meta.env.BASE_URL ||
|
|
8
|
-
let p = window.location.pathname
|
|
9
|
-
if (base && p.startsWith(base)) p = p.slice(base.length) ||
|
|
10
|
-
if (!p.startsWith(
|
|
11
|
-
return (p.replace(/\/$/,
|
|
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
12
|
}
|
|
13
13
|
|
|
14
|
-
const el = document.getElementById(
|
|
14
|
+
const el = document.getElementById("app");
|
|
15
15
|
if (el) {
|
|
16
16
|
void (async () => {
|
|
17
|
-
const initial =
|
|
18
|
-
|
|
19
|
-
currentRoute()
|
|
20
|
-
const dataEl = document.getElementById('__PREACTPRESS_PAGE_DATA__')
|
|
17
|
+
const initial = el.getAttribute("data-preactpress-route") ?? currentRoute();
|
|
18
|
+
const dataEl = document.getElementById("__PREACTPRESS_PAGE_DATA__");
|
|
21
19
|
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
|
-
})()
|
|
20
|
+
? (JSON.parse(dataEl.textContent) as PageView)
|
|
21
|
+
: await loadPage(initial, import.meta.env.BASE_URL || "/");
|
|
22
|
+
seedPage(initial, initialPage);
|
|
23
|
+
hydrate(<App routePath={initial} initialPage={initialPage} />, el);
|
|
24
|
+
})();
|
|
27
25
|
}
|
package/src/client/entry-ssr.tsx
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { renderToString } from
|
|
2
|
-
import { App } from
|
|
3
|
-
import { pages } from
|
|
4
|
-
import { i18n, site } from
|
|
5
|
-
import { resolvePageHeadMeta, titleTemplateFromMeta } from
|
|
6
|
-
import type { PageView } from
|
|
7
|
-
import { siteForRoute } from
|
|
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
8
|
|
|
9
9
|
export interface RenderResult {
|
|
10
|
-
body: string
|
|
11
|
-
title: string
|
|
12
|
-
description: string
|
|
13
|
-
tags: string[]
|
|
14
|
-
image?: string
|
|
15
|
-
pageType:
|
|
16
|
-
page: PageView
|
|
10
|
+
body: string;
|
|
11
|
+
title: string;
|
|
12
|
+
description: string;
|
|
13
|
+
tags: string[];
|
|
14
|
+
image?: string;
|
|
15
|
+
pageType: "website" | "article";
|
|
16
|
+
page: PageView;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function resolveRoutePage(routePath: string): PageView {
|
|
20
|
-
const activeSite = siteForRoute(site, routePath, i18n)
|
|
20
|
+
const activeSite = siteForRoute(site, routePath, i18n);
|
|
21
21
|
return (
|
|
22
22
|
pages[routePath] ??
|
|
23
|
-
pages[
|
|
24
|
-
kind:
|
|
25
|
-
html:
|
|
26
|
-
title:
|
|
23
|
+
pages["/404"] ?? {
|
|
24
|
+
kind: "markdown" as const,
|
|
25
|
+
html: "",
|
|
26
|
+
title: "Not found",
|
|
27
27
|
description: activeSite.description,
|
|
28
28
|
meta: {},
|
|
29
|
-
headings: []
|
|
29
|
+
headings: [],
|
|
30
30
|
}
|
|
31
|
-
)
|
|
31
|
+
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function renderResult(routePath: string, page: PageView): RenderResult {
|
|
35
|
-
const body = renderToString(<App routePath={routePath} initialPage={page} />)
|
|
36
|
-
const activeSite = siteForRoute(site, routePath, i18n)
|
|
35
|
+
const body = renderToString(<App routePath={routePath} initialPage={page} />);
|
|
36
|
+
const activeSite = siteForRoute(site, routePath, i18n);
|
|
37
37
|
const head = resolvePageHeadMeta(
|
|
38
|
-
page.kind ===
|
|
38
|
+
page.kind === "markdown"
|
|
39
39
|
? {
|
|
40
40
|
title: page.title,
|
|
41
41
|
titleTemplate: titleTemplateFromMeta(page.meta),
|
|
@@ -43,8 +43,8 @@ function renderResult(routePath: string, page: PageView): RenderResult {
|
|
|
43
43
|
tags: page.tags,
|
|
44
44
|
image: page.image,
|
|
45
45
|
pageType: page.pageType,
|
|
46
|
-
kind:
|
|
47
|
-
html: page.html
|
|
46
|
+
kind: "markdown",
|
|
47
|
+
html: page.html,
|
|
48
48
|
}
|
|
49
49
|
: {
|
|
50
50
|
title: page.title,
|
|
@@ -53,10 +53,10 @@ function renderResult(routePath: string, page: PageView): RenderResult {
|
|
|
53
53
|
tags: page.tags,
|
|
54
54
|
image: page.image,
|
|
55
55
|
pageType: page.pageType,
|
|
56
|
-
kind:
|
|
56
|
+
kind: "mdx",
|
|
57
57
|
},
|
|
58
|
-
activeSite
|
|
59
|
-
)
|
|
58
|
+
activeSite,
|
|
59
|
+
);
|
|
60
60
|
return {
|
|
61
61
|
body,
|
|
62
62
|
title: head.title,
|
|
@@ -64,14 +64,14 @@ function renderResult(routePath: string, page: PageView): RenderResult {
|
|
|
64
64
|
tags: head.tags,
|
|
65
65
|
image: head.image,
|
|
66
66
|
pageType: head.pageType,
|
|
67
|
-
page
|
|
68
|
-
}
|
|
67
|
+
page,
|
|
68
|
+
};
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function renderFromPage(routePath: string, page: PageView): RenderResult {
|
|
72
|
-
return renderResult(routePath, page)
|
|
72
|
+
return renderResult(routePath, page);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export function render(routePath: string): RenderResult {
|
|
76
|
-
return renderFromPage(routePath, resolveRoutePage(routePath))
|
|
76
|
+
return renderFromPage(routePath, resolveRoutePage(routePath));
|
|
77
77
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
export type { HtmlPageView, LayoutProps, MdxPageView, PageView } from
|
|
2
|
-
export {
|
|
1
|
+
export type { HtmlPageView, LayoutProps, MdxPageView, PageView } from "./types.js";
|
|
2
|
+
export {
|
|
3
|
+
ThemeToggle,
|
|
4
|
+
childText,
|
|
5
|
+
classNames,
|
|
6
|
+
createMdxHeadingComponents,
|
|
7
|
+
isActive,
|
|
8
|
+
normalizeLink,
|
|
9
|
+
slugifyHeading,
|
|
10
|
+
toggleStoredTheme,
|
|
11
|
+
useStoredThemeSync,
|
|
12
|
+
withBase,
|
|
13
|
+
type MdxHeadingOptions,
|
|
14
|
+
type ThemeToggleProps,
|
|
15
|
+
} from "./theme-utils.js";
|
|
16
|
+
export { usePageHead } from "./usePageHead.js";
|
package/src/client/loadPage.ts
CHANGED
|
@@ -1,68 +1,67 @@
|
|
|
1
|
-
import { mdxLoaders, pagesMeta } from
|
|
2
|
-
import type { HtmlPageView, PageView } from
|
|
3
|
-
import { contentChunkPath } from
|
|
4
|
-
import { publicUrl } from
|
|
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
5
|
|
|
6
|
-
const cache = new Map<string, PageView>()
|
|
6
|
+
const cache = new Map<string, PageView>();
|
|
7
7
|
|
|
8
8
|
function fallbackPage(): PageView {
|
|
9
9
|
return (
|
|
10
|
-
cache.get(
|
|
10
|
+
cache.get("/404") ??
|
|
11
11
|
({
|
|
12
|
-
kind:
|
|
13
|
-
html:
|
|
14
|
-
title:
|
|
12
|
+
kind: "markdown",
|
|
13
|
+
html: "<p>Page not found.</p>",
|
|
14
|
+
title: "404",
|
|
15
15
|
description: undefined,
|
|
16
16
|
meta: {},
|
|
17
|
-
headings: []
|
|
17
|
+
headings: [],
|
|
18
18
|
} satisfies HtmlPageView)
|
|
19
|
-
)
|
|
19
|
+
);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function seedPage(route: string, page: PageView | undefined): void {
|
|
23
|
-
if (page) cache.set(route, page)
|
|
23
|
+
if (page) cache.set(route, page);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async function loadMarkdownPage(route: string, base: string): Promise<PageView> {
|
|
27
|
-
const meta = pagesMeta[route]
|
|
28
|
-
const url =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const data = (await res.json()) as HtmlPageView
|
|
27
|
+
const meta = pagesMeta[route];
|
|
28
|
+
const url = import.meta.env.DEV
|
|
29
|
+
? publicUrl(base, `/__preactpress/page.json?route=${encodeURIComponent(route)}`)
|
|
30
|
+
: publicUrl(base, contentChunkPath(route));
|
|
31
|
+
const res = await fetch(url, { credentials: "same-origin" });
|
|
32
|
+
if (!res.ok) throw new Error(`Failed to load page ${route}`);
|
|
33
|
+
const data = (await res.json()) as HtmlPageView;
|
|
35
34
|
return {
|
|
36
35
|
...meta,
|
|
37
36
|
...data,
|
|
38
|
-
kind:
|
|
39
|
-
}
|
|
37
|
+
kind: "markdown",
|
|
38
|
+
};
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
export async function loadPage(route: string, base: string): Promise<PageView> {
|
|
43
|
-
const cached = cache.get(route)
|
|
44
|
-
if (cached) return cached
|
|
42
|
+
const cached = cache.get(route);
|
|
43
|
+
if (cached) return cached;
|
|
45
44
|
|
|
46
|
-
const meta = pagesMeta[route]
|
|
47
|
-
if (!meta) return fallbackPage()
|
|
45
|
+
const meta = pagesMeta[route];
|
|
46
|
+
if (!meta) return fallbackPage();
|
|
48
47
|
|
|
49
|
-
if (meta.kind ===
|
|
50
|
-
const loader = mdxLoaders[route]
|
|
51
|
-
if (!loader) return fallbackPage()
|
|
52
|
-
const mod = await loader()
|
|
53
|
-
const page = { ...meta, kind:
|
|
54
|
-
cache.set(route, page)
|
|
55
|
-
return page
|
|
48
|
+
if (meta.kind === "mdx") {
|
|
49
|
+
const loader = mdxLoaders[route];
|
|
50
|
+
if (!loader) return fallbackPage();
|
|
51
|
+
const mod = await loader();
|
|
52
|
+
const page = { ...meta, kind: "mdx" as const, Component: mod.default };
|
|
53
|
+
cache.set(route, page);
|
|
54
|
+
return page;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
const page = await loadMarkdownPage(route, base)
|
|
59
|
-
cache.set(route, page)
|
|
60
|
-
return page
|
|
57
|
+
const page = await loadMarkdownPage(route, base);
|
|
58
|
+
cache.set(route, page);
|
|
59
|
+
return page;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
export function prefetchPage(route: string, base: string): void {
|
|
64
|
-
if (cache.has(route)) return
|
|
63
|
+
if (cache.has(route)) return;
|
|
65
64
|
void loadPage(route, base).catch(() => {
|
|
66
65
|
/* Prefetch failures should not affect navigation. */
|
|
67
|
-
})
|
|
66
|
+
});
|
|
68
67
|
}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
const PREFETCH_MARGIN =
|
|
1
|
+
const PREFETCH_MARGIN = "200px";
|
|
2
2
|
|
|
3
3
|
function scheduleIdle(task: () => void): void {
|
|
4
|
-
if (typeof requestIdleCallback ===
|
|
5
|
-
requestIdleCallback(() => task(), { timeout: 2000 })
|
|
6
|
-
return
|
|
4
|
+
if (typeof requestIdleCallback === "function") {
|
|
5
|
+
requestIdleCallback(() => task(), { timeout: 2000 });
|
|
6
|
+
return;
|
|
7
7
|
}
|
|
8
|
-
setTimeout(task, 1)
|
|
8
|
+
setTimeout(task, 1);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function setupViewportPrefetch(
|
|
12
12
|
routeFromHref: (href: string) => string | undefined,
|
|
13
|
-
prefetch: (route: string) => void
|
|
13
|
+
prefetch: (route: string) => void,
|
|
14
14
|
): () => void {
|
|
15
|
-
if (typeof IntersectionObserver ===
|
|
15
|
+
if (typeof IntersectionObserver === "undefined") return () => {};
|
|
16
16
|
|
|
17
|
-
const seen = new WeakSet<HTMLAnchorElement>()
|
|
17
|
+
const seen = new WeakSet<HTMLAnchorElement>();
|
|
18
18
|
const observer = new IntersectionObserver(
|
|
19
19
|
(entries) => {
|
|
20
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)
|
|
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
29
|
}
|
|
30
30
|
},
|
|
31
|
-
{ rootMargin: PREFETCH_MARGIN }
|
|
32
|
-
)
|
|
31
|
+
{ rootMargin: PREFETCH_MARGIN },
|
|
32
|
+
);
|
|
33
33
|
|
|
34
34
|
const observe = (root: ParentNode): void => {
|
|
35
|
-
for (const link of Array.from(root.querySelectorAll(
|
|
35
|
+
for (const link of Array.from(root.querySelectorAll("a[href]"))) {
|
|
36
36
|
if (link instanceof HTMLAnchorElement && !seen.has(link)) {
|
|
37
|
-
observer.observe(link)
|
|
37
|
+
observer.observe(link);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
|
|
42
|
-
observe(document)
|
|
42
|
+
observe(document);
|
|
43
43
|
const mutation = new MutationObserver((records) => {
|
|
44
44
|
for (const record of records) {
|
|
45
45
|
for (const node of Array.from(record.addedNodes)) {
|
|
46
46
|
if (node instanceof HTMLAnchorElement) {
|
|
47
|
-
if (!seen.has(node)) observer.observe(node)
|
|
48
|
-
continue
|
|
47
|
+
if (!seen.has(node)) observer.observe(node);
|
|
48
|
+
continue;
|
|
49
49
|
}
|
|
50
|
-
if (node instanceof Element) observe(node)
|
|
50
|
+
if (node instanceof Element) observe(node);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
})
|
|
54
|
-
mutation.observe(document.body, { childList: true, subtree: true })
|
|
53
|
+
});
|
|
54
|
+
mutation.observe(document.body, { childList: true, subtree: true });
|
|
55
55
|
|
|
56
56
|
return () => {
|
|
57
|
-
observer.disconnect()
|
|
58
|
-
mutation.disconnect()
|
|
59
|
-
}
|
|
57
|
+
observer.disconnect();
|
|
58
|
+
mutation.disconnect();
|
|
59
|
+
};
|
|
60
60
|
}
|