@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
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { ComponentChildren, FunctionalComponent, JSX } from "preact";
|
|
2
|
+
import { useEffect } from "preact/hooks";
|
|
3
|
+
import {
|
|
4
|
+
PREACTPRESS_THEME_STORAGE_KEY,
|
|
5
|
+
applyTheme,
|
|
6
|
+
readStoredTheme,
|
|
7
|
+
type PreactpressStoredTheme,
|
|
8
|
+
} from "../shared/theme.js";
|
|
9
|
+
import { slugifySegment } from "../shared/slug.js";
|
|
10
|
+
|
|
11
|
+
export function withBase(base: string, link: string): string {
|
|
12
|
+
if (
|
|
13
|
+
/^(?:[a-z]+:)?\/\//i.test(link) ||
|
|
14
|
+
/^(?:data|mailto|tel):/i.test(link) ||
|
|
15
|
+
link.startsWith("#")
|
|
16
|
+
) {
|
|
17
|
+
return link;
|
|
18
|
+
}
|
|
19
|
+
const b = base === "/" ? "" : base.replace(/\/$/, "");
|
|
20
|
+
const l = link.startsWith("/") ? link : `/${link}`;
|
|
21
|
+
return `${b}${l}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function normalizeLink(link: string): string {
|
|
25
|
+
const clean = link.split(/[?#]/, 1)[0] || "/";
|
|
26
|
+
const prefixed = clean.startsWith("/") ? clean : `/${clean}`;
|
|
27
|
+
return prefixed.replace(/\/$/, "") || "/";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function isActive(routePath: string, link: string | undefined): boolean {
|
|
31
|
+
if (!link || /^(?:[a-z]+:)?\/\//i.test(link)) return false;
|
|
32
|
+
const route = normalizeLink(routePath);
|
|
33
|
+
const target = normalizeLink(link);
|
|
34
|
+
return route === target || (target !== "/" && route.startsWith(`${target}/`));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function classNames(...values: Array<string | undefined | false>): string {
|
|
38
|
+
return values.filter(Boolean).join(" ");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function childText(children: ComponentChildren): string {
|
|
42
|
+
if (children == null || typeof children === "boolean") return "";
|
|
43
|
+
if (typeof children === "string" || typeof children === "number") return String(children);
|
|
44
|
+
if (Array.isArray(children)) return children.map(childText).join("");
|
|
45
|
+
if (typeof children === "object" && "props" in children) {
|
|
46
|
+
return childText(children.props.children as ComponentChildren);
|
|
47
|
+
}
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function slugifyHeading(text: string): string {
|
|
52
|
+
return slugifySegment(text);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface MdxHeadingOptions {
|
|
56
|
+
headingClass: string;
|
|
57
|
+
anchorClass: string;
|
|
58
|
+
anchorLabel: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function createMdxHeadingComponents({
|
|
62
|
+
headingClass,
|
|
63
|
+
anchorClass,
|
|
64
|
+
anchorLabel,
|
|
65
|
+
}: MdxHeadingOptions) {
|
|
66
|
+
const used = new Map<string, number>();
|
|
67
|
+
const heading =
|
|
68
|
+
(Tag: "h2" | "h3") =>
|
|
69
|
+
({ children, ...props }: JSX.HTMLAttributes<HTMLHeadingElement>) => {
|
|
70
|
+
const base = slugifyHeading(childText(children));
|
|
71
|
+
const count = used.get(base) ?? 0;
|
|
72
|
+
used.set(base, count + 1);
|
|
73
|
+
const id = count === 0 ? base : `${base}-${count + 1}`;
|
|
74
|
+
return (
|
|
75
|
+
<Tag {...props} id={id} class={`${headingClass} ${props.class ?? ""}`.trim()}>
|
|
76
|
+
{children}
|
|
77
|
+
<a class={anchorClass} href={`#${id}`} aria-label={anchorLabel}>
|
|
78
|
+
#
|
|
79
|
+
</a>
|
|
80
|
+
</Tag>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
h2: heading("h2"),
|
|
86
|
+
h3: heading("h3"),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function toggleStoredTheme(): void {
|
|
91
|
+
const stored = readStoredTheme();
|
|
92
|
+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
93
|
+
const isDark = stored === "dark" || (stored === null && prefersDark);
|
|
94
|
+
const next: PreactpressStoredTheme = isDark ? "light" : "dark";
|
|
95
|
+
applyTheme(next);
|
|
96
|
+
try {
|
|
97
|
+
localStorage.setItem(PREACTPRESS_THEME_STORAGE_KEY, next);
|
|
98
|
+
} catch {
|
|
99
|
+
/* ignore quota / private mode */
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function useStoredThemeSync(): void {
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
function syncTheme(event?: StorageEvent): void {
|
|
106
|
+
if (event && event.key !== PREACTPRESS_THEME_STORAGE_KEY) return;
|
|
107
|
+
const value =
|
|
108
|
+
event?.newValue ??
|
|
109
|
+
(() => {
|
|
110
|
+
try {
|
|
111
|
+
return localStorage.getItem(PREACTPRESS_THEME_STORAGE_KEY);
|
|
112
|
+
} catch {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
})();
|
|
116
|
+
applyTheme(value === "light" || value === "dark" ? value : null);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function onSystemThemeChange(): void {
|
|
120
|
+
if (readStoredTheme() !== null) return;
|
|
121
|
+
applyTheme(null);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
syncTheme();
|
|
125
|
+
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
126
|
+
media.addEventListener("change", onSystemThemeChange);
|
|
127
|
+
window.addEventListener("storage", syncTheme);
|
|
128
|
+
return () => {
|
|
129
|
+
media.removeEventListener("change", onSystemThemeChange);
|
|
130
|
+
window.removeEventListener("storage", syncTheme);
|
|
131
|
+
};
|
|
132
|
+
}, []);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface ThemeToggleProps {
|
|
136
|
+
className?: string;
|
|
137
|
+
ariaLabel?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export const ThemeToggle: FunctionalComponent<ThemeToggleProps> = ({
|
|
141
|
+
className = "pp-theme-toggle",
|
|
142
|
+
ariaLabel = "Toggle light and dark theme",
|
|
143
|
+
}) => {
|
|
144
|
+
useStoredThemeSync();
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<button type="button" class={className} onClick={toggleStoredTheme} aria-label={ariaLabel}>
|
|
148
|
+
<span class={`${className}-moon`} aria-hidden="true">
|
|
149
|
+
<svg
|
|
150
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
151
|
+
width="18"
|
|
152
|
+
height="18"
|
|
153
|
+
fill="none"
|
|
154
|
+
stroke="currentColor"
|
|
155
|
+
strokeWidth="1.5"
|
|
156
|
+
viewBox="0 0 24 24"
|
|
157
|
+
>
|
|
158
|
+
<path
|
|
159
|
+
strokeLinecap="round"
|
|
160
|
+
strokeLinejoin="round"
|
|
161
|
+
d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"
|
|
162
|
+
/>
|
|
163
|
+
</svg>
|
|
164
|
+
</span>
|
|
165
|
+
<span class={`${className}-sun`} aria-hidden="true">
|
|
166
|
+
<svg
|
|
167
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
168
|
+
width="18"
|
|
169
|
+
height="18"
|
|
170
|
+
fill="none"
|
|
171
|
+
stroke="currentColor"
|
|
172
|
+
strokeWidth="1.5"
|
|
173
|
+
viewBox="0 0 24 24"
|
|
174
|
+
>
|
|
175
|
+
<path
|
|
176
|
+
strokeLinecap="round"
|
|
177
|
+
strokeLinejoin="round"
|
|
178
|
+
d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"
|
|
179
|
+
/>
|
|
180
|
+
</svg>
|
|
181
|
+
</span>
|
|
182
|
+
</button>
|
|
183
|
+
);
|
|
184
|
+
};
|
package/src/client/types.ts
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
import type { ComponentType } from
|
|
2
|
-
import type {
|
|
1
|
+
import type { ComponentType } from "preact";
|
|
2
|
+
import type {
|
|
3
|
+
OutlineItem,
|
|
4
|
+
ResolvedI18n,
|
|
5
|
+
ResolvedLocale,
|
|
6
|
+
SiteData,
|
|
7
|
+
ThemeConfig,
|
|
8
|
+
} from "../node/siteConfig.js";
|
|
3
9
|
|
|
4
10
|
interface BasePageView {
|
|
5
|
-
title?: string
|
|
6
|
-
description?: string
|
|
7
|
-
tags?: string[]
|
|
8
|
-
image?: string
|
|
9
|
-
pageType?:
|
|
10
|
-
meta: Record<string, unknown
|
|
11
|
-
headings: OutlineItem[]
|
|
12
|
-
relativePath?: string
|
|
13
|
-
lastUpdated?: string
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
tags?: string[];
|
|
14
|
+
image?: string;
|
|
15
|
+
pageType?: "website" | "article";
|
|
16
|
+
meta: Record<string, unknown>;
|
|
17
|
+
headings: OutlineItem[];
|
|
18
|
+
relativePath?: string;
|
|
19
|
+
lastUpdated?: string;
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
export interface HtmlPageView extends BasePageView {
|
|
17
|
-
kind:
|
|
18
|
-
html: string
|
|
23
|
+
kind: "markdown";
|
|
24
|
+
html: string;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export interface MdxPageView extends BasePageView {
|
|
22
|
-
kind:
|
|
23
|
-
Component: ComponentType<{ components?: Record<string, ComponentType<Record<string, unknown>>> }
|
|
28
|
+
kind: "mdx";
|
|
29
|
+
Component: ComponentType<{ components?: Record<string, ComponentType<Record<string, unknown>>> }>;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
export type PageView = HtmlPageView | MdxPageView
|
|
32
|
+
export type PageView = HtmlPageView | MdxPageView;
|
|
27
33
|
|
|
28
34
|
export interface LayoutProps {
|
|
29
|
-
site: SiteData
|
|
30
|
-
themeConfig: ThemeConfig
|
|
31
|
-
routePath: string
|
|
32
|
-
page?: PageView
|
|
33
|
-
i18n?: ResolvedI18n
|
|
34
|
-
locale?: ResolvedLocale
|
|
35
|
-
locales?: ResolvedLocale[]
|
|
36
|
-
localizeRoute?: (locale: ResolvedLocale) => string
|
|
35
|
+
site: SiteData;
|
|
36
|
+
themeConfig: ThemeConfig;
|
|
37
|
+
routePath: string;
|
|
38
|
+
page?: PageView;
|
|
39
|
+
i18n?: ResolvedI18n;
|
|
40
|
+
locale?: ResolvedLocale;
|
|
41
|
+
locales?: ResolvedLocale[];
|
|
42
|
+
localizeRoute?: (locale: ResolvedLocale) => string;
|
|
37
43
|
}
|
|
@@ -1,151 +1,138 @@
|
|
|
1
|
-
import { useEffect } from
|
|
2
|
-
import type { ResolvedI18n, SiteData } from
|
|
1
|
+
import { useEffect } from "preact/hooks";
|
|
2
|
+
import type { ResolvedI18n, SiteData } from "../node/siteConfig.js";
|
|
3
3
|
import {
|
|
4
4
|
resolvePageHeadMeta,
|
|
5
5
|
titleTemplateFromMeta,
|
|
6
|
-
type PageMetaInput
|
|
7
|
-
} from
|
|
8
|
-
import { headTagsFromMeta } from
|
|
9
|
-
import type { HeadTag } from
|
|
10
|
-
import { canonicalUrl, publicUrl } from
|
|
11
|
-
import { localizedRouteForLocale, siteForRoute } from
|
|
12
|
-
|
|
13
|
-
function upsertMeta(
|
|
14
|
-
|
|
15
|
-
key
|
|
16
|
-
content: string
|
|
17
|
-
): void {
|
|
18
|
-
if (!content) return
|
|
19
|
-
let el = document.head.querySelector(
|
|
20
|
-
`meta[${selector}="${key}"]`
|
|
21
|
-
) as HTMLMetaElement | null
|
|
6
|
+
type PageMetaInput,
|
|
7
|
+
} from "../shared/pageMeta.js";
|
|
8
|
+
import { headTagsFromMeta } from "../shared/pageHead.js";
|
|
9
|
+
import type { HeadTag } from "../node/siteConfig.js";
|
|
10
|
+
import { canonicalUrl, publicUrl } from "../shared/url.js";
|
|
11
|
+
import { localizedRouteForLocale, siteForRoute } from "../shared/locale.js";
|
|
12
|
+
|
|
13
|
+
function upsertMeta(selector: "name" | "property", key: string, content: string): void {
|
|
14
|
+
if (!content) return;
|
|
15
|
+
let el = document.head.querySelector(`meta[${selector}="${key}"]`) as HTMLMetaElement | null;
|
|
22
16
|
if (!el) {
|
|
23
|
-
el = document.createElement(
|
|
24
|
-
el.setAttribute(selector, key)
|
|
25
|
-
document.head.appendChild(el)
|
|
17
|
+
el = document.createElement("meta");
|
|
18
|
+
el.setAttribute(selector, key);
|
|
19
|
+
document.head.appendChild(el);
|
|
26
20
|
}
|
|
27
|
-
el.content = content
|
|
21
|
+
el.content = content;
|
|
28
22
|
}
|
|
29
23
|
|
|
30
|
-
function removeMeta(selector:
|
|
31
|
-
document.head
|
|
32
|
-
.querySelectorAll(`meta[${selector}="${key}"]`)
|
|
33
|
-
.forEach((el) => el.remove())
|
|
24
|
+
function removeMeta(selector: "name" | "property", key: string): void {
|
|
25
|
+
document.head.querySelectorAll(`meta[${selector}="${key}"]`).forEach((el) => el.remove());
|
|
34
26
|
}
|
|
35
27
|
|
|
36
|
-
function appendMeta(selector:
|
|
37
|
-
if (!content) return
|
|
38
|
-
const el = document.createElement(
|
|
39
|
-
el.setAttribute(selector, key)
|
|
40
|
-
el.content = content
|
|
41
|
-
document.head.appendChild(el)
|
|
28
|
+
function appendMeta(selector: "name" | "property", key: string, content: string): void {
|
|
29
|
+
if (!content) return;
|
|
30
|
+
const el = document.createElement("meta");
|
|
31
|
+
el.setAttribute(selector, key);
|
|
32
|
+
el.content = content;
|
|
33
|
+
document.head.appendChild(el);
|
|
42
34
|
}
|
|
43
35
|
|
|
44
36
|
function upsertCanonical(href: string): void {
|
|
45
|
-
if (!href) return
|
|
46
|
-
let el = document.head.querySelector('link[rel="canonical"]') as HTMLLinkElement | null
|
|
37
|
+
if (!href) return;
|
|
38
|
+
let el = document.head.querySelector('link[rel="canonical"]') as HTMLLinkElement | null;
|
|
47
39
|
if (!el) {
|
|
48
|
-
el = document.createElement(
|
|
49
|
-
el.rel =
|
|
50
|
-
document.head.appendChild(el)
|
|
40
|
+
el = document.createElement("link");
|
|
41
|
+
el.rel = "canonical";
|
|
42
|
+
document.head.appendChild(el);
|
|
51
43
|
}
|
|
52
|
-
el.href = href
|
|
44
|
+
el.href = href;
|
|
53
45
|
}
|
|
54
46
|
|
|
55
47
|
function removeCanonical(): void {
|
|
56
|
-
document.head
|
|
57
|
-
.querySelectorAll('link[rel="canonical"]')
|
|
58
|
-
.forEach((el) => el.remove())
|
|
48
|
+
document.head.querySelectorAll('link[rel="canonical"]').forEach((el) => el.remove());
|
|
59
49
|
}
|
|
60
50
|
|
|
61
51
|
function replaceAlternates(opts: {
|
|
62
|
-
site: SiteData
|
|
63
|
-
i18n: ResolvedI18n | undefined
|
|
64
|
-
route: string
|
|
65
|
-
routes?: ReadonlySet<string
|
|
52
|
+
site: SiteData;
|
|
53
|
+
i18n: ResolvedI18n | undefined;
|
|
54
|
+
route: string;
|
|
55
|
+
routes?: ReadonlySet<string>;
|
|
66
56
|
}): void {
|
|
67
|
-
document.head
|
|
68
|
-
|
|
69
|
-
.forEach((el) => el.remove())
|
|
70
|
-
if (!opts.site.url || !opts.i18n) return
|
|
57
|
+
document.head.querySelectorAll('link[rel="alternate"][hreflang]').forEach((el) => el.remove());
|
|
58
|
+
if (!opts.site.url || !opts.i18n) return;
|
|
71
59
|
for (const locale of opts.i18n.locales) {
|
|
72
|
-
const route = localizedRouteForLocale(opts.route, locale, opts.i18n, opts.routes)
|
|
73
|
-
if (opts.routes && !opts.routes.has(route)) continue
|
|
74
|
-
const el = document.createElement(
|
|
75
|
-
el.rel =
|
|
76
|
-
el.hreflang = locale.lang
|
|
77
|
-
el.href = canonicalUrl({ url: opts.site.url, base: opts.site.base, route })
|
|
78
|
-
document.head.appendChild(el)
|
|
60
|
+
const route = localizedRouteForLocale(opts.route, locale, opts.i18n, opts.routes);
|
|
61
|
+
if (opts.routes && !opts.routes.has(route)) continue;
|
|
62
|
+
const el = document.createElement("link");
|
|
63
|
+
el.rel = "alternate";
|
|
64
|
+
el.hreflang = locale.lang;
|
|
65
|
+
el.href = canonicalUrl({ url: opts.site.url, base: opts.site.base, route });
|
|
66
|
+
document.head.appendChild(el);
|
|
79
67
|
}
|
|
80
68
|
}
|
|
81
69
|
|
|
82
70
|
function upsertHeadTag(tag: HeadTag): void {
|
|
83
|
-
const [name, attrs, content] = tag
|
|
84
|
-
if (name ===
|
|
85
|
-
const key =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
const [name, attrs, content] = tag;
|
|
72
|
+
if (name === "meta") {
|
|
73
|
+
const key =
|
|
74
|
+
"name" in attrs && attrs.name ? "name" : "property" in attrs ? "property" : undefined;
|
|
75
|
+
if (key && typeof attrs[key] === "string") {
|
|
76
|
+
upsertMeta(key as "name" | "property", String(attrs[key]), String(attrs.content ?? ""));
|
|
77
|
+
return;
|
|
89
78
|
}
|
|
90
79
|
}
|
|
91
|
-
if (name ===
|
|
80
|
+
if (name === "link" && attrs.rel && typeof attrs.href === "string") {
|
|
92
81
|
let el = document.head.querySelector(
|
|
93
|
-
`link[rel="${attrs.rel}"]${attrs.hreflang ? `[hreflang="${attrs.hreflang}"]` :
|
|
94
|
-
) as HTMLLinkElement | null
|
|
82
|
+
`link[rel="${attrs.rel}"]${attrs.hreflang ? `[hreflang="${attrs.hreflang}"]` : ""}`,
|
|
83
|
+
) as HTMLLinkElement | null;
|
|
95
84
|
if (!el) {
|
|
96
|
-
el = document.createElement(
|
|
85
|
+
el = document.createElement("link");
|
|
97
86
|
for (const [key, value] of Object.entries(attrs)) {
|
|
98
|
-
if (value != null && value !== false) el.setAttribute(key, String(value))
|
|
87
|
+
if (value != null && value !== false) el.setAttribute(key, String(value));
|
|
99
88
|
}
|
|
100
|
-
document.head.appendChild(el)
|
|
89
|
+
document.head.appendChild(el);
|
|
101
90
|
} else {
|
|
102
|
-
el.href = String(attrs.href)
|
|
91
|
+
el.href = String(attrs.href);
|
|
103
92
|
}
|
|
104
|
-
return
|
|
93
|
+
return;
|
|
105
94
|
}
|
|
106
|
-
if (name ===
|
|
107
|
-
const id = typeof attrs.id ===
|
|
108
|
-
let el = id ? (document.getElementById(id) as HTMLScriptElement | null) : null
|
|
95
|
+
if (name === "script") {
|
|
96
|
+
const id = typeof attrs.id === "string" ? attrs.id : undefined;
|
|
97
|
+
let el = id ? (document.getElementById(id) as HTMLScriptElement | null) : null;
|
|
109
98
|
if (!el) {
|
|
110
|
-
el = document.createElement(
|
|
99
|
+
el = document.createElement("script");
|
|
111
100
|
for (const [key, value] of Object.entries(attrs)) {
|
|
112
|
-
if (value != null && value !== false) el.setAttribute(key, String(value))
|
|
101
|
+
if (value != null && value !== false) el.setAttribute(key, String(value));
|
|
113
102
|
}
|
|
114
|
-
el.textContent = content ??
|
|
115
|
-
document.head.appendChild(el)
|
|
103
|
+
el.textContent = content ?? "";
|
|
104
|
+
document.head.appendChild(el);
|
|
116
105
|
}
|
|
117
106
|
}
|
|
118
107
|
}
|
|
119
108
|
|
|
120
109
|
function resolveMetaImage(site: SiteData, image: string | undefined): string | undefined {
|
|
121
|
-
if (!image) return undefined
|
|
122
|
-
if (/^(?:[a-z]+:)?\/\//i.test(image)) return image
|
|
123
|
-
return site.url
|
|
124
|
-
? `${site.url}${publicUrl(site.base, image)}`
|
|
125
|
-
: publicUrl(site.base, image)
|
|
110
|
+
if (!image) return undefined;
|
|
111
|
+
if (/^(?:[a-z]+:)?\/\//i.test(image)) return image;
|
|
112
|
+
return site.url ? `${site.url}${publicUrl(site.base, image)}` : publicUrl(site.base, image);
|
|
126
113
|
}
|
|
127
114
|
|
|
128
115
|
export function usePageHead(opts: {
|
|
129
|
-
site: SiteData
|
|
130
|
-
i18n?: ResolvedI18n
|
|
131
|
-
routes?: ReadonlySet<string
|
|
132
|
-
route: string
|
|
133
|
-
page: PageMetaInput | undefined
|
|
116
|
+
site: SiteData;
|
|
117
|
+
i18n?: ResolvedI18n;
|
|
118
|
+
routes?: ReadonlySet<string>;
|
|
119
|
+
route: string;
|
|
120
|
+
page: PageMetaInput | undefined;
|
|
134
121
|
}): void {
|
|
135
|
-
const { site, i18n, routes, route, page } = opts
|
|
136
|
-
const activeSite = siteForRoute(site, route, i18n)
|
|
137
|
-
const pageTitle = page?.title
|
|
138
|
-
const pageDescription = page?.description
|
|
139
|
-
const pageTags = page?.tags
|
|
140
|
-
const pageImage = page?.image
|
|
141
|
-
const pageType = page?.pageType
|
|
142
|
-
const pageKind = page?.kind
|
|
143
|
-
const pageHtml = page?.kind ===
|
|
144
|
-
const pageMeta = page?.meta
|
|
122
|
+
const { site, i18n, routes, route, page } = opts;
|
|
123
|
+
const activeSite = siteForRoute(site, route, i18n);
|
|
124
|
+
const pageTitle = page?.title;
|
|
125
|
+
const pageDescription = page?.description;
|
|
126
|
+
const pageTags = page?.tags;
|
|
127
|
+
const pageImage = page?.image;
|
|
128
|
+
const pageType = page?.pageType;
|
|
129
|
+
const pageKind = page?.kind;
|
|
130
|
+
const pageHtml = page?.kind === "markdown" ? page.html : undefined;
|
|
131
|
+
const pageMeta = page?.meta;
|
|
145
132
|
|
|
146
133
|
useEffect(() => {
|
|
147
134
|
const head = resolvePageHeadMeta(
|
|
148
|
-
pageKind ===
|
|
135
|
+
pageKind === "markdown"
|
|
149
136
|
? {
|
|
150
137
|
title: pageTitle,
|
|
151
138
|
titleTemplate: titleTemplateFromMeta(pageMeta),
|
|
@@ -153,8 +140,8 @@ export function usePageHead(opts: {
|
|
|
153
140
|
tags: pageTags,
|
|
154
141
|
image: pageImage,
|
|
155
142
|
pageType,
|
|
156
|
-
kind:
|
|
157
|
-
html: pageHtml
|
|
143
|
+
kind: "markdown",
|
|
144
|
+
html: pageHtml,
|
|
158
145
|
}
|
|
159
146
|
: pageKind
|
|
160
147
|
? {
|
|
@@ -164,49 +151,62 @@ export function usePageHead(opts: {
|
|
|
164
151
|
tags: pageTags,
|
|
165
152
|
image: pageImage,
|
|
166
153
|
pageType,
|
|
167
|
-
kind: pageKind
|
|
154
|
+
kind: pageKind,
|
|
168
155
|
}
|
|
169
156
|
: undefined,
|
|
170
|
-
activeSite
|
|
171
|
-
)
|
|
157
|
+
activeSite,
|
|
158
|
+
);
|
|
172
159
|
|
|
173
|
-
for (const tag of headTagsFromMeta(pageMeta)) upsertHeadTag(tag)
|
|
160
|
+
for (const tag of headTagsFromMeta(pageMeta)) upsertHeadTag(tag);
|
|
174
161
|
|
|
175
|
-
document.title = head.title
|
|
162
|
+
document.title = head.title;
|
|
176
163
|
|
|
177
|
-
upsertMeta(
|
|
178
|
-
upsertMeta(
|
|
179
|
-
upsertMeta(
|
|
180
|
-
upsertMeta(
|
|
181
|
-
upsertMeta(
|
|
182
|
-
upsertMeta(
|
|
183
|
-
upsertMeta(
|
|
184
|
-
removeMeta(
|
|
185
|
-
removeMeta(
|
|
186
|
-
for (const tag of head.tags) appendMeta(
|
|
164
|
+
upsertMeta("name", "description", head.description);
|
|
165
|
+
upsertMeta("property", "og:title", head.title);
|
|
166
|
+
upsertMeta("property", "og:description", head.description);
|
|
167
|
+
upsertMeta("property", "og:type", head.pageType);
|
|
168
|
+
upsertMeta("name", "twitter:card", head.image ? "summary_large_image" : "summary");
|
|
169
|
+
upsertMeta("name", "twitter:title", head.title);
|
|
170
|
+
upsertMeta("name", "twitter:description", head.description);
|
|
171
|
+
removeMeta("name", "keywords");
|
|
172
|
+
removeMeta("property", "article:tag");
|
|
173
|
+
for (const tag of head.tags) appendMeta("property", "article:tag", tag);
|
|
187
174
|
|
|
188
|
-
const image = resolveMetaImage(activeSite, head.image)
|
|
175
|
+
const image = resolveMetaImage(activeSite, head.image);
|
|
189
176
|
if (image) {
|
|
190
|
-
upsertMeta(
|
|
191
|
-
upsertMeta(
|
|
177
|
+
upsertMeta("property", "og:image", image);
|
|
178
|
+
upsertMeta("name", "twitter:image", image);
|
|
192
179
|
} else {
|
|
193
|
-
removeMeta(
|
|
194
|
-
removeMeta(
|
|
180
|
+
removeMeta("property", "og:image");
|
|
181
|
+
removeMeta("name", "twitter:image");
|
|
195
182
|
}
|
|
196
183
|
|
|
197
|
-
const canonical = canonicalUrl({ url: activeSite.url, base: activeSite.base, route })
|
|
184
|
+
const canonical = canonicalUrl({ url: activeSite.url, base: activeSite.base, route });
|
|
198
185
|
if (canonical) {
|
|
199
|
-
upsertMeta(
|
|
200
|
-
upsertCanonical(canonical)
|
|
186
|
+
upsertMeta("property", "og:url", canonical);
|
|
187
|
+
upsertCanonical(canonical);
|
|
201
188
|
} else {
|
|
202
|
-
removeMeta(
|
|
203
|
-
removeCanonical()
|
|
189
|
+
removeMeta("property", "og:url");
|
|
190
|
+
removeCanonical();
|
|
204
191
|
}
|
|
205
192
|
|
|
206
|
-
replaceAlternates({ site: activeSite, i18n, route, routes })
|
|
193
|
+
replaceAlternates({ site: activeSite, i18n, route, routes });
|
|
207
194
|
|
|
208
195
|
if (document.documentElement.lang !== activeSite.lang) {
|
|
209
|
-
document.documentElement.lang = activeSite.lang
|
|
196
|
+
document.documentElement.lang = activeSite.lang;
|
|
210
197
|
}
|
|
211
|
-
}, [
|
|
198
|
+
}, [
|
|
199
|
+
activeSite,
|
|
200
|
+
i18n,
|
|
201
|
+
route,
|
|
202
|
+
routes,
|
|
203
|
+
pageTitle,
|
|
204
|
+
pageDescription,
|
|
205
|
+
pageTags,
|
|
206
|
+
pageImage,
|
|
207
|
+
pageType,
|
|
208
|
+
pageKind,
|
|
209
|
+
pageHtml,
|
|
210
|
+
pageMeta,
|
|
211
|
+
]);
|
|
212
212
|
}
|