@fecommunity/reactpress-toolkit 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +194 -309
- package/dist/admin/index.d.ts +2 -0
- package/dist/admin/index.js +18 -0
- package/dist/admin/permissions.d.ts +5 -0
- package/dist/admin/permissions.js +33 -0
- package/dist/admin/registry.d.ts +62 -0
- package/dist/admin/registry.js +79 -0
- package/dist/api/HttpClient.d.ts +2 -2
- package/dist/api/HttpClient.js +1 -1
- package/dist/api/Smtp.d.ts +17 -0
- package/dist/api/Smtp.js +15 -0
- package/dist/api/instance.d.ts +1 -1
- package/dist/api/instance.js +3 -3
- package/dist/app/createReactPressApp.d.ts +88 -0
- package/dist/app/createReactPressApp.js +262 -0
- package/dist/app/createThemeApp.d.ts +6 -0
- package/dist/app/createThemeApp.js +47 -0
- package/dist/app/devChunkRecovery.d.ts +2 -0
- package/dist/app/devChunkRecovery.js +68 -0
- package/dist/app/index.d.ts +39 -0
- package/dist/app/index.js +11 -0
- package/dist/config/env.js +29 -15
- package/dist/config/global.d.ts +7 -1
- package/dist/config/global.js +9 -3
- package/dist/config/i18n.js +27 -11
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +6 -5
- package/dist/{locales → config/locales}/en.json +31 -3
- package/dist/{locales → config/locales}/zh.json +31 -3
- package/dist/dev/index.d.ts +3 -0
- package/dist/dev/index.js +12 -0
- package/dist/dev/portRedirect.d.ts +20 -0
- package/dist/dev/portRedirect.js +93 -0
- package/dist/dev/vitePortRedirectPlugin.d.ts +24 -0
- package/dist/dev/vitePortRedirectPlugin.js +40 -0
- package/dist/extension/branding-mods.d.ts +10 -0
- package/dist/extension/branding-mods.js +65 -0
- package/dist/extension/configuration/defaults.d.ts +3 -0
- package/dist/extension/configuration/defaults.js +32 -0
- package/dist/extension/configuration/formily.d.ts +10 -0
- package/dist/extension/configuration/formily.js +170 -0
- package/dist/extension/configuration/index.d.ts +7 -0
- package/dist/extension/configuration/index.js +28 -0
- package/dist/extension/configuration/paths.d.ts +4 -0
- package/dist/extension/configuration/paths.js +50 -0
- package/dist/extension/configuration/presets/twentytwentyfive.d.ts +7 -0
- package/dist/extension/configuration/presets/twentytwentyfive.js +94 -0
- package/dist/extension/configuration/resolve.d.ts +24 -0
- package/dist/extension/configuration/resolve.js +98 -0
- package/dist/extension/configuration/types.d.ts +68 -0
- package/dist/extension/configuration/types.js +3 -0
- package/dist/extension/configuration/validate.d.ts +8 -0
- package/dist/extension/configuration/validate.js +21 -0
- package/dist/extension/index.d.ts +9 -0
- package/dist/extension/index.js +35 -0
- package/dist/extension/manifest-normalize.d.ts +5 -0
- package/dist/extension/manifest-normalize.js +75 -0
- package/dist/extension/node.d.ts +2 -0
- package/dist/extension/node.js +6 -0
- package/dist/extension/presets/twentytwentyfive-appearance.d.ts +10 -0
- package/dist/extension/presets/twentytwentyfive-appearance.js +193 -0
- package/dist/extension/presets/twentytwentyfive-customizer.d.ts +19 -0
- package/dist/extension/presets/twentytwentyfive-customizer.js +199 -0
- package/dist/extension/preview.d.ts +46 -0
- package/dist/extension/preview.js +92 -0
- package/dist/extension/site-notices.d.ts +19 -0
- package/dist/extension/site-notices.js +88 -0
- package/dist/extension/site-settings.d.ts +37 -0
- package/dist/extension/site-settings.js +144 -0
- package/dist/extension/theme-admin-locale.d.ts +11 -0
- package/dist/extension/theme-admin-locale.io.d.ts +2 -0
- package/dist/extension/theme-admin-locale.io.js +54 -0
- package/dist/extension/theme-admin-locale.js +81 -0
- package/dist/extension/theme.d.ts +89 -0
- package/dist/extension/theme.js +93 -0
- package/dist/extension/twentytwentyfive-vars.d.ts +7 -0
- package/dist/extension/twentytwentyfive-vars.js +100 -0
- package/dist/index.d.ts +15 -7
- package/dist/index.js +44 -22
- package/dist/plugin/admin/index.d.ts +2 -0
- package/dist/plugin/admin/index.js +18 -0
- package/dist/plugin/admin/permissions.d.ts +5 -0
- package/dist/plugin/admin/permissions.js +33 -0
- package/dist/plugin/admin/registry.d.ts +62 -0
- package/dist/plugin/admin/registry.js +79 -0
- package/dist/plugin/client/client.d.ts +14 -0
- package/dist/plugin/client/client.js +95 -0
- package/dist/plugin/client/index.d.ts +4 -0
- package/dist/plugin/client/index.js +11 -0
- package/dist/plugin/client/runtime.d.ts +18 -0
- package/dist/plugin/client/runtime.js +30 -0
- package/dist/plugin/dev/index.d.ts +4 -0
- package/dist/plugin/dev/index.js +16 -0
- package/dist/plugin/dev/portRedirect.d.ts +26 -0
- package/dist/plugin/dev/portRedirect.js +111 -0
- package/dist/plugin/dev/vitePortRedirectPlugin.d.ts +24 -0
- package/dist/plugin/dev/vitePortRedirectPlugin.js +40 -0
- package/dist/plugin/index.d.ts +9 -0
- package/dist/plugin/index.js +48 -0
- package/dist/plugin/react/client.d.ts +14 -0
- package/dist/plugin/react/client.js +95 -0
- package/dist/plugin/react/index.d.ts +2 -0
- package/dist/plugin/react/index.js +18 -0
- package/dist/plugin/react/runtime.d.ts +18 -0
- package/dist/plugin/react/runtime.js +30 -0
- package/dist/primitives/AntdStyleTransitionFix.d.ts +2 -0
- package/dist/primitives/AntdStyleTransitionFix.js +16 -0
- package/dist/primitives/Badge.d.ts +7 -0
- package/dist/primitives/Badge.js +9 -0
- package/dist/primitives/Button.d.ts +10 -0
- package/dist/primitives/Button.js +38 -0
- package/dist/primitives/ColorModeToggle.d.ts +8 -0
- package/dist/primitives/ColorModeToggle.js +13 -0
- package/dist/primitives/IconButton.d.ts +7 -0
- package/dist/primitives/IconButton.js +13 -0
- package/dist/primitives/ScrollToTarget.d.ts +9 -0
- package/dist/primitives/ScrollToTarget.js +48 -0
- package/dist/primitives/Separator.d.ts +7 -0
- package/dist/primitives/Separator.js +9 -0
- package/dist/primitives/Skeleton.d.ts +7 -0
- package/dist/primitives/Skeleton.js +9 -0
- package/dist/primitives/Slot.d.ts +10 -0
- package/dist/primitives/Slot.js +25 -0
- package/dist/primitives/Spinner.d.ts +6 -0
- package/dist/primitives/Spinner.js +9 -0
- package/dist/primitives/animation/ConditionTransition.d.ts +8 -0
- package/dist/primitives/animation/ConditionTransition.js +13 -0
- package/dist/primitives/animation/ListTrail.d.ts +10 -0
- package/dist/primitives/animation/ListTrail.js +14 -0
- package/dist/primitives/animation/Opacity.d.ts +3 -0
- package/dist/primitives/animation/Opacity.js +10 -0
- package/dist/primitives/animation/Spring.d.ts +9 -0
- package/dist/primitives/animation/Spring.js +29 -0
- package/dist/primitives/animation/index.d.ts +7 -0
- package/dist/primitives/animation/index.js +11 -0
- package/dist/primitives/cn.d.ts +4 -0
- package/dist/primitives/cn.js +7 -0
- package/dist/primitives/icons.d.ts +4 -0
- package/dist/primitives/icons.js +15 -0
- package/dist/primitives/index.d.ts +22 -0
- package/dist/primitives/index.js +44 -0
- package/dist/react/client.d.ts +14 -0
- package/dist/react/client.js +95 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js +11 -0
- package/dist/react/runtime.d.ts +18 -0
- package/dist/react/runtime.js +30 -0
- package/dist/theme/antdDocument.d.ts +18 -0
- package/dist/theme/antdDocument.js +59 -0
- package/dist/theme/api/api-data.d.ts +2 -0
- package/dist/theme/api/api-data.js +8 -0
- package/dist/theme/api/api.d.ts +28 -0
- package/dist/theme/api/api.js +27 -0
- package/dist/theme/api/httpClient.d.ts +24 -0
- package/dist/theme/api/httpClient.js +83 -0
- package/dist/theme/api/json.d.ts +1 -0
- package/dist/theme/api/json.js +5 -0
- package/dist/theme/api/jsonp.d.ts +1 -0
- package/dist/theme/api/jsonp.js +5 -0
- package/dist/theme/api-data.d.ts +12 -0
- package/dist/theme/api-data.js +22 -0
- package/dist/theme/api.d.ts +28 -0
- package/dist/theme/api.js +27 -0
- package/dist/theme/appearance.d.ts +4 -0
- package/dist/theme/appearance.js +16 -0
- package/dist/theme/assets.d.ts +2 -0
- package/dist/theme/assets.js +27 -0
- package/dist/theme/authSession.d.ts +16 -0
- package/dist/theme/authSession.js +92 -0
- package/dist/theme/build/antdDocument.d.ts +145 -0
- package/dist/theme/build/antdDocument.js +70 -0
- package/dist/theme/build/next-config.d.ts +17 -0
- package/dist/theme/build/next-config.js +100 -0
- package/dist/theme/build/node.d.ts +2 -0
- package/dist/theme/build/node.js +6 -0
- package/dist/theme/colorMode.d.ts +12 -0
- package/dist/theme/colorMode.js +45 -0
- package/dist/theme/commentAuthor.d.ts +17 -0
- package/dist/theme/commentAuthor.js +48 -0
- package/dist/theme/content/archiveSlim.d.ts +7 -0
- package/dist/theme/content/archiveSlim.js +38 -0
- package/dist/theme/content/articleSlim.d.ts +10 -0
- package/dist/theme/content/articleSlim.js +35 -0
- package/dist/theme/content/assets.d.ts +8 -0
- package/dist/theme/content/assets.js +74 -0
- package/dist/theme/content/carouselArticles.d.ts +10 -0
- package/dist/theme/content/carouselArticles.js +39 -0
- package/dist/theme/content/excerpt.d.ts +15 -0
- package/dist/theme/content/excerpt.js +42 -0
- package/dist/theme/content/nav.d.ts +10 -0
- package/dist/theme/content/nav.js +30 -0
- package/dist/theme/content/seo.d.ts +6 -0
- package/dist/theme/content/seo.js +12 -0
- package/dist/theme/createAntdApp.d.ts +106 -0
- package/dist/theme/createAntdApp.js +175 -0
- package/dist/theme/createApp.d.ts +10 -0
- package/dist/theme/createApp.js +141 -0
- package/dist/theme/createCatalogApp.d.ts +108 -0
- package/dist/theme/createCatalogApp.js +168 -0
- package/dist/theme/customizer.d.ts +1 -0
- package/dist/theme/customizer.js +5 -0
- package/dist/theme/excerpt.d.ts +16 -0
- package/dist/theme/excerpt.js +31 -0
- package/dist/theme/extension/branding-mods.d.ts +10 -0
- package/dist/theme/extension/branding-mods.js +65 -0
- package/dist/theme/extension/configuration/defaults.d.ts +3 -0
- package/dist/theme/extension/configuration/defaults.js +32 -0
- package/dist/theme/extension/configuration/formily.d.ts +10 -0
- package/dist/theme/extension/configuration/formily.js +170 -0
- package/dist/theme/extension/configuration/index.d.ts +7 -0
- package/dist/theme/extension/configuration/index.js +28 -0
- package/dist/theme/extension/configuration/paths.d.ts +1 -0
- package/dist/theme/extension/configuration/paths.js +7 -0
- package/dist/theme/extension/configuration/presets/twentytwentyfive.d.ts +7 -0
- package/dist/theme/extension/configuration/presets/twentytwentyfive.js +94 -0
- package/dist/theme/extension/configuration/resolve.d.ts +24 -0
- package/dist/theme/extension/configuration/resolve.js +98 -0
- package/dist/theme/extension/configuration/types.d.ts +68 -0
- package/dist/theme/extension/configuration/types.js +3 -0
- package/dist/theme/extension/configuration/validate.d.ts +8 -0
- package/dist/theme/extension/configuration/validate.js +21 -0
- package/dist/theme/extension/index.d.ts +11 -0
- package/dist/theme/extension/index.js +38 -0
- package/dist/theme/extension/manifest-normalize.d.ts +5 -0
- package/dist/theme/extension/manifest-normalize.js +75 -0
- package/dist/theme/extension/presets/twentytwentyfive-appearance.d.ts +10 -0
- package/dist/theme/extension/presets/twentytwentyfive-appearance.js +193 -0
- package/dist/theme/extension/preview.d.ts +46 -0
- package/dist/theme/extension/preview.js +92 -0
- package/dist/theme/extension/site-notices.d.ts +19 -0
- package/dist/theme/extension/site-notices.js +88 -0
- package/dist/theme/extension/site-settings.d.ts +37 -0
- package/dist/theme/extension/site-settings.js +144 -0
- package/dist/theme/extension/siteNav.d.ts +18 -0
- package/dist/theme/extension/siteNav.js +17 -0
- package/dist/theme/extension/theme-admin-locale.d.ts +11 -0
- package/dist/theme/extension/theme-admin-locale.io.d.ts +2 -0
- package/dist/theme/extension/theme-admin-locale.io.js +54 -0
- package/dist/theme/extension/theme-admin-locale.js +68 -0
- package/dist/theme/extension/theme.d.ts +89 -0
- package/dist/theme/extension/theme.js +93 -0
- package/dist/theme/extension/twentytwentyfive-vars.d.ts +9 -0
- package/dist/theme/extension/twentytwentyfive-vars.js +103 -0
- package/dist/theme/fetch.d.ts +134 -0
- package/dist/theme/fetch.js +241 -0
- package/dist/theme/format.d.ts +16 -0
- package/dist/theme/format.js +48 -0
- package/dist/theme/httpClient.d.ts +20 -0
- package/dist/theme/httpClient.js +89 -0
- package/dist/theme/index.d.ts +63 -0
- package/dist/theme/index.js +226 -0
- package/dist/theme/json.d.ts +1 -0
- package/dist/theme/json.js +17 -0
- package/dist/theme/jsonp.d.ts +8 -0
- package/dist/theme/jsonp.js +27 -0
- package/dist/theme/locale.d.ts +23 -0
- package/dist/theme/locale.js +55 -0
- package/dist/theme/nav.d.ts +10 -0
- package/dist/theme/nav.js +30 -0
- package/dist/theme/next-config.d.ts +2 -0
- package/dist/theme/next-config.js +18 -0
- package/dist/theme/node.d.ts +2 -0
- package/dist/theme/node.js +18 -0
- package/dist/theme/preview/preview-config.d.ts +13 -0
- package/dist/theme/preview/preview-config.js +65 -0
- package/dist/theme/preview/preview-draft.d.ts +19 -0
- package/dist/theme/preview/preview-draft.js +51 -0
- package/dist/theme/preview/preview-mods.d.ts +16 -0
- package/dist/theme/preview/preview-mods.js +78 -0
- package/dist/theme/preview-config.d.ts +13 -0
- package/dist/theme/preview-config.js +65 -0
- package/dist/theme/preview-draft.d.ts +19 -0
- package/dist/theme/preview-draft.js +51 -0
- package/dist/theme/preview-mods.d.ts +16 -0
- package/dist/theme/preview-mods.js +78 -0
- package/dist/theme/providers/index.d.ts +118 -0
- package/dist/theme/providers/index.js +251 -0
- package/dist/theme/providers/setup.d.ts +124 -0
- package/dist/theme/providers/setup.js +29 -0
- package/dist/theme/runtime.d.ts +18 -0
- package/dist/theme/runtime.js +19 -0
- package/dist/theme/seo.d.ts +6 -0
- package/dist/theme/seo.js +12 -0
- package/dist/theme/server.d.ts +65 -0
- package/dist/theme/server.js +177 -0
- package/dist/theme/setting.d.ts +12 -0
- package/dist/theme/setting.js +42 -0
- package/dist/theme/ssr/bootstrap.d.ts +48 -0
- package/dist/theme/ssr/bootstrap.js +112 -0
- package/dist/theme/ssr/fetch.d.ts +134 -0
- package/dist/theme/ssr/fetch.js +264 -0
- package/dist/theme/ssr/format.d.ts +3 -0
- package/dist/theme/ssr/format.js +8 -0
- package/dist/theme/ssr/pageProps.d.ts +62 -0
- package/dist/theme/ssr/pageProps.js +138 -0
- package/dist/theme/ssr/setting.d.ts +12 -0
- package/dist/theme/ssr/setting.js +42 -0
- package/dist/theme/ssr/slimBootstrap.d.ts +11 -0
- package/dist/theme/ssr/slimBootstrap.js +75 -0
- package/dist/theme/ssr/static.d.ts +10 -0
- package/dist/theme/ssr/static.js +17 -0
- package/dist/theme/ssr/templates.d.ts +35 -0
- package/dist/theme/ssr/templates.js +50 -0
- package/dist/theme/static.d.ts +10 -0
- package/dist/theme/static.js +17 -0
- package/dist/theme/templates.d.ts +27 -0
- package/dist/theme/templates.js +38 -0
- package/dist/theme/ui-optional.d.ts +1 -0
- package/dist/theme/ui-optional.js +21 -0
- package/dist/theme/visitor/appearance.d.ts +4 -0
- package/dist/theme/visitor/appearance.js +16 -0
- package/dist/theme/visitor/authSession.d.ts +16 -0
- package/dist/theme/visitor/authSession.js +92 -0
- package/dist/theme/visitor/colorMode.d.ts +17 -0
- package/dist/theme/visitor/colorMode.js +59 -0
- package/dist/theme/visitor/commentAuthor.d.ts +16 -0
- package/dist/theme/visitor/commentAuthor.js +45 -0
- package/dist/theme/visitor/i18n.d.ts +4 -0
- package/dist/theme/visitor/i18n.js +28 -0
- package/dist/theme/visitor/locale.d.ts +23 -0
- package/dist/theme/visitor/locale.js +72 -0
- package/dist/theme/visitor/runtime.d.ts +18 -0
- package/dist/theme/visitor/runtime.js +19 -0
- package/dist/theme/visitor/visitorLocale.d.ts +11 -0
- package/dist/theme/visitor/visitorLocale.js +56 -0
- package/dist/theme/visitorLocale.d.ts +6 -0
- package/dist/theme/visitorLocale.js +39 -0
- package/dist/types/index.d.ts +79 -68
- package/dist/ui/AntdStyleTransitionFix.d.ts +5 -0
- package/dist/ui/AntdStyleTransitionFix.js +16 -0
- package/dist/ui/ArchiveEmptyState.d.ts +13 -0
- package/dist/ui/ArchiveEmptyState.js +8 -0
- package/dist/ui/ArchivePageLayout.d.ts +10 -0
- package/dist/ui/ArchivePageLayout.js +8 -0
- package/dist/ui/ArticleCard.d.ts +27 -0
- package/dist/ui/ArticleCard.js +16 -0
- package/dist/ui/ArticleList.d.ts +14 -0
- package/dist/ui/ArticleList.js +16 -0
- package/dist/ui/BaseGlobalStyles.d.ts +5 -0
- package/dist/ui/BaseGlobalStyles.js +18 -0
- package/dist/ui/LocaleSwitcher.d.ts +7 -0
- package/dist/ui/LocaleSwitcher.js +15 -0
- package/dist/ui/NavMenu.d.ts +16 -0
- package/dist/ui/NavMenu.js +8 -0
- package/dist/ui/NotFoundPanel.d.ts +11 -0
- package/dist/ui/NotFoundPanel.js +8 -0
- package/dist/ui/PageHeader.d.ts +10 -0
- package/dist/ui/PageHeader.js +8 -0
- package/dist/ui/SiteBranding.d.ts +10 -0
- package/dist/ui/SiteBranding.js +14 -0
- package/dist/ui/SiteDocument.d.ts +20 -0
- package/dist/ui/SiteDocument.js +13 -0
- package/dist/ui/SiteDocumentFallback.d.ts +8 -0
- package/dist/ui/SiteDocumentFallback.js +9 -0
- package/dist/ui/SiteLogo.d.ts +6 -0
- package/dist/ui/SiteLogo.js +16 -0
- package/dist/ui/SiteTagline.d.ts +7 -0
- package/dist/ui/SiteTagline.js +15 -0
- package/dist/ui/TaxonomyList.d.ts +25 -0
- package/dist/ui/TaxonomyList.js +30 -0
- package/dist/ui/ThemeCssVars.d.ts +2 -0
- package/dist/ui/ThemeCssVars.js +85 -0
- package/dist/ui/ThemeLayout.d.ts +13 -0
- package/dist/ui/ThemeLayout.js +11 -0
- package/dist/ui/components/AntdStyleTransitionFix.d.ts +5 -0
- package/dist/ui/components/AntdStyleTransitionFix.js +16 -0
- package/dist/ui/components/ArchiveEmptyState.d.ts +13 -0
- package/dist/ui/components/ArchiveEmptyState.js +8 -0
- package/dist/ui/components/ArchivePageLayout.d.ts +10 -0
- package/dist/ui/components/ArchivePageLayout.js +8 -0
- package/dist/ui/components/ArticleCard.d.ts +27 -0
- package/dist/ui/components/ArticleCard.js +16 -0
- package/dist/ui/components/ArticleList.d.ts +14 -0
- package/dist/ui/components/ArticleList.js +16 -0
- package/dist/ui/components/BaseGlobalStyles.d.ts +5 -0
- package/dist/ui/components/BaseGlobalStyles.js +18 -0
- package/dist/ui/components/LocaleSwitcher.d.ts +10 -0
- package/dist/ui/components/LocaleSwitcher.js +11 -0
- package/dist/ui/components/NavMenu.d.ts +16 -0
- package/dist/ui/components/NavMenu.js +8 -0
- package/dist/ui/components/NotFoundPanel.d.ts +11 -0
- package/dist/ui/components/NotFoundPanel.js +8 -0
- package/dist/ui/components/PageHeader.d.ts +10 -0
- package/dist/ui/components/PageHeader.js +8 -0
- package/dist/ui/components/RouteProgress.d.ts +9 -0
- package/dist/ui/components/RouteProgress.js +40 -0
- package/dist/ui/components/SiteAnalytics.d.ts +5 -0
- package/dist/ui/components/SiteAnalytics.js +42 -0
- package/dist/ui/components/SiteBranding.d.ts +10 -0
- package/dist/ui/components/SiteBranding.js +14 -0
- package/dist/ui/components/SiteDocument.d.ts +20 -0
- package/dist/ui/components/SiteDocument.js +13 -0
- package/dist/ui/components/SiteDocumentFallback.d.ts +8 -0
- package/dist/ui/components/SiteDocumentFallback.js +9 -0
- package/dist/ui/components/SiteLogo.d.ts +8 -0
- package/dist/ui/components/SiteLogo.js +23 -0
- package/dist/ui/components/SiteSeo.d.ts +13 -0
- package/dist/ui/components/SiteSeo.js +19 -0
- package/dist/ui/components/SiteTagline.d.ts +7 -0
- package/dist/ui/components/SiteTagline.js +15 -0
- package/dist/ui/components/TaxonomyList.d.ts +25 -0
- package/dist/ui/components/TaxonomyList.js +30 -0
- package/dist/ui/components/ThemeCssVars.d.ts +2 -0
- package/dist/ui/components/ThemeCssVars.js +85 -0
- package/dist/ui/components/ThemeLayout.d.ts +13 -0
- package/dist/ui/components/ThemeLayout.js +11 -0
- package/dist/ui/components/content/ArticleReader.d.ts +45 -0
- package/dist/ui/components/content/ArticleReader.js +23 -0
- package/dist/ui/components/content/ArticleToc.d.ts +21 -0
- package/dist/ui/components/content/ArticleToc.js +75 -0
- package/dist/ui/components/content/HtmlContent.d.ts +15 -0
- package/dist/ui/components/content/HtmlContent.js +237 -0
- package/dist/ui/components/content/Image.d.ts +9 -0
- package/dist/ui/components/content/Image.js +13 -0
- package/dist/ui/components/content/ImageViewer.d.ts +8 -0
- package/dist/ui/components/content/ImageViewer.js +33 -0
- package/dist/ui/components/content/LocaleTime.d.ts +9 -0
- package/dist/ui/components/content/LocaleTime.js +63 -0
- package/dist/ui/components/content/index.d.ts +14 -0
- package/dist/ui/components/content/index.js +18 -0
- package/dist/ui/components/toolbar/LocaleToggleButton.d.ts +8 -0
- package/dist/ui/components/toolbar/LocaleToggleButton.js +18 -0
- package/dist/ui/components/toolbar/ThemeToggleButton.d.ts +7 -0
- package/dist/ui/components/toolbar/ThemeToggleButton.js +10 -0
- package/dist/ui/components/toolbar/ToolbarIconButton.d.ts +7 -0
- package/dist/ui/components/toolbar/ToolbarIconButton.js +22 -0
- package/dist/ui/components/toolbar/constants.d.ts +5 -0
- package/dist/ui/components/toolbar/constants.js +8 -0
- package/dist/ui/components/toolbar/icons.d.ts +17 -0
- package/dist/ui/components/toolbar/icons.js +44 -0
- package/dist/ui/components/toolbar/index.d.ts +9 -0
- package/dist/ui/components/toolbar/index.js +25 -0
- package/dist/ui/components/toolbar/locale-label.d.ts +3 -0
- package/dist/ui/components/toolbar/locale-label.js +19 -0
- package/dist/ui/context/LocaleContext.d.ts +15 -0
- package/dist/ui/context/LocaleContext.js +59 -0
- package/dist/ui/context/ReactPressProvider.d.ts +3 -0
- package/dist/ui/context/ReactPressProvider.js +10 -0
- package/dist/ui/context/SiteCatalogContext.d.ts +41 -0
- package/dist/ui/context/SiteCatalogContext.js +60 -0
- package/dist/ui/context/ThemeRuntimeContext.d.ts +21 -0
- package/dist/ui/context/ThemeRuntimeContext.js +59 -0
- package/dist/ui/context/index.d.ts +8 -0
- package/dist/ui/context/index.js +26 -0
- package/dist/ui/context/siteCatalogTypes.d.ts +64 -0
- package/dist/ui/context/siteCatalogTypes.js +20 -0
- package/dist/ui/context/types.d.ts +34 -0
- package/dist/ui/context/types.js +2 -0
- package/dist/ui/hooks/index.d.ts +12 -0
- package/dist/ui/hooks/index.js +29 -0
- package/dist/ui/hooks/useAsyncLoading.d.ts +4 -0
- package/dist/ui/hooks/useAsyncLoading.js +31 -0
- package/dist/ui/hooks/useForceUpdate.d.ts +2 -0
- package/dist/ui/hooks/useForceUpdate.js +11 -0
- package/dist/ui/hooks/useNavActive.d.ts +5 -0
- package/dist/ui/hooks/useNavActive.js +11 -0
- package/dist/ui/hooks/usePagination.d.ts +34 -0
- package/dist/ui/hooks/usePagination.js +55 -0
- package/dist/ui/hooks/useReportArticleView.d.ts +4 -0
- package/dist/ui/hooks/useReportArticleView.js +40 -0
- package/dist/ui/hooks/useReportPageView.d.ts +11 -0
- package/dist/ui/hooks/useReportPageView.js +28 -0
- package/dist/ui/hooks/useRouteParam.d.ts +5 -0
- package/dist/ui/hooks/useRouteParam.js +15 -0
- package/dist/ui/hooks/useToggle.d.ts +2 -0
- package/dist/ui/hooks/useToggle.js +17 -0
- package/dist/ui/hooks/useWarningOnExit.d.ts +5 -0
- package/dist/ui/hooks/useWarningOnExit.js +59 -0
- package/dist/ui/index.d.ts +43 -0
- package/dist/ui/index.js +87 -0
- package/dist/utils/api-envelope.d.ts +14 -0
- package/dist/utils/api-envelope.js +31 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.js +24 -0
- package/dist/utils/cookie.d.ts +2 -0
- package/dist/utils/cookie.js +15 -0
- package/dist/utils/date.d.ts +4 -0
- package/dist/utils/date.js +45 -0
- package/dist/utils/email.d.ts +3 -0
- package/dist/utils/email.js +9 -0
- package/dist/utils/error.d.ts +7 -0
- package/dist/utils/error.js +26 -0
- package/dist/utils/image.d.ts +7 -0
- package/dist/utils/image.js +34 -0
- package/dist/utils/index.d.ts +15 -33
- package/dist/utils/index.js +37 -57
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +18 -0
- package/dist/utils/jsonp.d.ts +8 -0
- package/dist/utils/jsonp.js +27 -0
- package/dist/utils/object.d.ts +7 -0
- package/dist/utils/object.js +63 -0
- package/dist/utils/setting.d.ts +12 -0
- package/dist/utils/setting.js +13 -0
- package/dist/utils/string.d.ts +4 -0
- package/dist/utils/string.js +15 -0
- package/dist/utils/viewport.d.ts +3 -0
- package/dist/utils/viewport.js +14 -0
- package/package.json +129 -16
- package/LICENSE +0 -21
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.THEME_ISR_REVALIDATE_SECONDS = void 0;
|
|
4
|
+
exports.withApiRetry = withApiRetry;
|
|
5
|
+
exports.fetchThemeCatalog = fetchThemeCatalog;
|
|
6
|
+
exports.sanitizeNextProps = sanitizeNextProps;
|
|
7
|
+
exports.themeStaticProps = themeStaticProps;
|
|
8
|
+
exports.resolveStaticVisitorContext = resolveStaticVisitorContext;
|
|
9
|
+
exports.fetchCategoryIndex = fetchCategoryIndex;
|
|
10
|
+
exports.fetchTagIndex = fetchTagIndex;
|
|
11
|
+
exports.fetchSiteSettings = fetchSiteSettings;
|
|
12
|
+
exports.createDefaultVisitorContext = createDefaultVisitorContext;
|
|
13
|
+
exports.fetchVisitorContext = fetchVisitorContext;
|
|
14
|
+
exports.fetchSiteMeta = fetchSiteMeta;
|
|
15
|
+
exports.fetchCategoryArchive = fetchCategoryArchive;
|
|
16
|
+
exports.fetchTagArchive = fetchTagArchive;
|
|
17
|
+
exports.fetchSingleArticle = fetchSingleArticle;
|
|
18
|
+
exports.fetchSearchArticles = fetchSearchArticles;
|
|
19
|
+
exports.withThemeStaticProps = withThemeStaticProps;
|
|
20
|
+
exports.createArchiveGetStaticProps = createArchiveGetStaticProps;
|
|
21
|
+
exports.fetchArticlePageProps = fetchArticlePageProps;
|
|
22
|
+
const api_1 = require("../api/api");
|
|
23
|
+
const api_data_1 = require("../api/api-data");
|
|
24
|
+
const assets_1 = require("../content/assets");
|
|
25
|
+
const format_1 = require("./format");
|
|
26
|
+
const json_1 = require("../api/json");
|
|
27
|
+
const locale_1 = require("../visitor/locale");
|
|
28
|
+
const runtime_1 = require("../visitor/runtime");
|
|
29
|
+
const setting_1 = require("./setting");
|
|
30
|
+
const static_1 = require("./static");
|
|
31
|
+
/** Default ISR interval for theme list/home pages. */
|
|
32
|
+
exports.THEME_ISR_REVALIDATE_SECONDS = 60;
|
|
33
|
+
function isConnectionRefused(error) {
|
|
34
|
+
const err = error;
|
|
35
|
+
return err?.code === 'ECONNREFUSED' || err?.cause?.code === 'ECONNREFUSED';
|
|
36
|
+
}
|
|
37
|
+
function isRetryableNetworkError(error) {
|
|
38
|
+
if (isConnectionRefused(error))
|
|
39
|
+
return true;
|
|
40
|
+
const err = error;
|
|
41
|
+
const code = err?.code || err?.cause?.code;
|
|
42
|
+
const message = `${err?.message || ''} ${err?.cause?.message || ''}`.toLowerCase();
|
|
43
|
+
return (code === 'ECONNRESET' ||
|
|
44
|
+
code === 'ETIMEDOUT' ||
|
|
45
|
+
code === 'EPIPE' ||
|
|
46
|
+
message.includes('socket hang up') ||
|
|
47
|
+
message.includes('network error') ||
|
|
48
|
+
message.includes('timeout'));
|
|
49
|
+
}
|
|
50
|
+
/** Retry SSR API calls during dev startup or flaky remote connections. */
|
|
51
|
+
async function withApiRetry(fn, attempts = 8, delayMs = 400) {
|
|
52
|
+
let lastError;
|
|
53
|
+
for (let i = 0; i < attempts; i += 1) {
|
|
54
|
+
try {
|
|
55
|
+
return await fn();
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
lastError = error;
|
|
59
|
+
if (!isRetryableNetworkError(error) || i >= attempts - 1) {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
await new Promise((resolve) => {
|
|
63
|
+
setTimeout(resolve, delayMs);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw lastError;
|
|
68
|
+
}
|
|
69
|
+
/** Articles, categories, and tags for home / toolkit demo pages. */
|
|
70
|
+
async function fetchThemeCatalog(api) {
|
|
71
|
+
return withApiRetry(async () => {
|
|
72
|
+
const [articlesResponse, categoriesResponse, tagsResponse] = await Promise.all([
|
|
73
|
+
api.article.findAll(),
|
|
74
|
+
api.category.findAll(),
|
|
75
|
+
api.tag.findAll(),
|
|
76
|
+
]);
|
|
77
|
+
return {
|
|
78
|
+
articles: (0, api_data_1.unpackPaginated)(articlesResponse),
|
|
79
|
+
categories: (0, api_data_1.unpackList)(categoriesResponse),
|
|
80
|
+
tags: (0, api_data_1.unpackList)(tagsResponse),
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** Strip `undefined` values so Next.js can serialize `getStaticProps` results. */
|
|
85
|
+
function sanitizeNextProps(props) {
|
|
86
|
+
return JSON.parse(JSON.stringify(props));
|
|
87
|
+
}
|
|
88
|
+
function themeStaticProps(props, revalidate = exports.THEME_ISR_REVALIDATE_SECONDS) {
|
|
89
|
+
return { props: sanitizeNextProps(props), revalidate };
|
|
90
|
+
}
|
|
91
|
+
let staticVisitorContextPromise = null;
|
|
92
|
+
let staticVisitorContextKey = '';
|
|
93
|
+
/** Visitor context for `getStaticProps` — `_app.getInitialProps` does not run on SSR for static pages. */
|
|
94
|
+
async function resolveStaticVisitorContext() {
|
|
95
|
+
const themeId = process.env.REACTPRESS_THEME_ID?.trim() || 'starter-theme';
|
|
96
|
+
const honorPreview = process.env.REACTPRESS_HONOR_PREVIEW === '1';
|
|
97
|
+
const cacheKey = `${themeId}:${honorPreview ? '1' : '0'}`;
|
|
98
|
+
if (staticVisitorContextPromise && staticVisitorContextKey === cacheKey) {
|
|
99
|
+
return staticVisitorContextPromise;
|
|
100
|
+
}
|
|
101
|
+
staticVisitorContextKey = cacheKey;
|
|
102
|
+
staticVisitorContextPromise = (async () => {
|
|
103
|
+
try {
|
|
104
|
+
return await fetchVisitorContext(api_1.themeApi, { themeId, honorPreview });
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const code = error?.code
|
|
108
|
+
?? error?.cause?.code;
|
|
109
|
+
if (code !== 'ECONNREFUSED') {
|
|
110
|
+
console.error('[reactpress] resolveStaticVisitorContext failed', error);
|
|
111
|
+
}
|
|
112
|
+
return createDefaultVisitorContext(themeId);
|
|
113
|
+
}
|
|
114
|
+
})();
|
|
115
|
+
return staticVisitorContextPromise;
|
|
116
|
+
}
|
|
117
|
+
/** All categories — `getStaticProps` for `pages/category/index.tsx`. */
|
|
118
|
+
async function fetchCategoryIndex(api) {
|
|
119
|
+
return { categories: (0, api_data_1.unpackList)(await api.category.findAll()) };
|
|
120
|
+
}
|
|
121
|
+
/** All tags — `getStaticProps` for `pages/tag/index.tsx`. */
|
|
122
|
+
async function fetchTagIndex(api) {
|
|
123
|
+
return { tags: (0, api_data_1.unpackList)(await api.tag.findAll()) };
|
|
124
|
+
}
|
|
125
|
+
/** Site settings for about/footer pages (`getStaticProps`). */
|
|
126
|
+
async function fetchSiteSettings(api, schema) {
|
|
127
|
+
const rows = (0, api_data_1.unpackList)(await api.setting.findAll());
|
|
128
|
+
return (0, format_1.pickSiteSettings)(rows, schema);
|
|
129
|
+
}
|
|
130
|
+
/** Safe defaults when API is unreachable (still wraps pages in Provider). */
|
|
131
|
+
function createDefaultVisitorContext(themeId, partial = {}) {
|
|
132
|
+
return {
|
|
133
|
+
locale: 'zh',
|
|
134
|
+
locales: ['zh', 'en'],
|
|
135
|
+
messages: {},
|
|
136
|
+
catalog: {},
|
|
137
|
+
themeId,
|
|
138
|
+
activeThemeId: themeId,
|
|
139
|
+
mods: {},
|
|
140
|
+
isPreview: false,
|
|
141
|
+
siteMeta: setting_1.DEFAULT_SITE_META,
|
|
142
|
+
...partial,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async function fetchVisitorContext(api, options) {
|
|
146
|
+
if (!api?.setting?.findAll) {
|
|
147
|
+
throw new Error('fetchVisitorContext: invalid ThemeApi instance');
|
|
148
|
+
}
|
|
149
|
+
return withApiRetry(async () => {
|
|
150
|
+
const row = (0, setting_1.unwrapSetting)(await api.setting.findAll());
|
|
151
|
+
const localeState = (0, locale_1.parseSiteLocale)(row?.i18n, {
|
|
152
|
+
locale: options.locale,
|
|
153
|
+
fallbackLocale: options.fallbackLocale,
|
|
154
|
+
preferredLocale: options.preferredLocale,
|
|
155
|
+
acceptLanguage: options.acceptLanguage,
|
|
156
|
+
});
|
|
157
|
+
const globalSetting = (0, json_1.safeJsonParse)(row?.globalSetting, {});
|
|
158
|
+
const runtime = (0, runtime_1.resolveThemeRuntime)(globalSetting, {
|
|
159
|
+
themeId: options.themeId,
|
|
160
|
+
honorPreview: options.honorPreview,
|
|
161
|
+
});
|
|
162
|
+
const siteMeta = (0, setting_1.parseSiteMeta)(row);
|
|
163
|
+
return {
|
|
164
|
+
locale: localeState.locale,
|
|
165
|
+
locales: localeState.locales,
|
|
166
|
+
messages: localeState.messages,
|
|
167
|
+
catalog: localeState.catalog,
|
|
168
|
+
themeId: runtime.themeId,
|
|
169
|
+
activeThemeId: runtime.activeThemeId,
|
|
170
|
+
mods: runtime.mods,
|
|
171
|
+
isPreview: runtime.isPreview,
|
|
172
|
+
siteMeta,
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/** Common site meta from the Setting row (`systemTitle`, `systemSubTitle`, …). */
|
|
177
|
+
async function fetchSiteMeta(api) {
|
|
178
|
+
return withApiRetry(async () => {
|
|
179
|
+
const row = (0, setting_1.unwrapSetting)(await api.setting.findAll());
|
|
180
|
+
return (0, setting_1.parseSiteMeta)(row);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/** Category archive — `getStaticProps` for `pages/category/[category].tsx`. */
|
|
184
|
+
async function fetchCategoryArchive(api, category) {
|
|
185
|
+
const [articlesResponse, categoriesResponse] = await Promise.all([
|
|
186
|
+
api.article.findArticlesByCategory(category),
|
|
187
|
+
api.category.findAll(),
|
|
188
|
+
]);
|
|
189
|
+
return {
|
|
190
|
+
category,
|
|
191
|
+
articles: (0, api_data_1.unpackPaginated)(articlesResponse),
|
|
192
|
+
categories: (0, api_data_1.unpackList)(categoriesResponse),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/** Tag archive — `getStaticProps` for `pages/tag/[tag].tsx`. */
|
|
196
|
+
async function fetchTagArchive(api, tag) {
|
|
197
|
+
const [articlesResponse, tagsResponse] = await Promise.all([
|
|
198
|
+
api.article.findArticlesByTag(tag),
|
|
199
|
+
api.tag.findAll(),
|
|
200
|
+
]);
|
|
201
|
+
return {
|
|
202
|
+
tag,
|
|
203
|
+
articles: (0, api_data_1.unpackPaginated)(articlesResponse),
|
|
204
|
+
tags: (0, api_data_1.unpackList)(tagsResponse),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/** Single article — `getStaticProps` for `pages/article/[id].tsx`. */
|
|
208
|
+
async function fetchSingleArticle(api, id) {
|
|
209
|
+
const articleResponse = await api.article.findById(id);
|
|
210
|
+
return { article: (0, api_data_1.unpackOne)(articleResponse) };
|
|
211
|
+
}
|
|
212
|
+
/** Site search — `getServerSideProps` / `getStaticProps` helper. */
|
|
213
|
+
async function fetchSearchArticles(api, keyword) {
|
|
214
|
+
if (!keyword.trim()) {
|
|
215
|
+
return { query: '', articles: [] };
|
|
216
|
+
}
|
|
217
|
+
const searchResponse = await api.search.searchArticle({
|
|
218
|
+
query: { keyword: keyword.trim() },
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
query: keyword.trim(),
|
|
222
|
+
articles: (0, api_data_1.unpackList)(searchResponse),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Wrap `getStaticProps` fetchers with consistent logging and ISR fallback props.
|
|
227
|
+
*/
|
|
228
|
+
async function withThemeStaticProps(label, fetchFn, fallback) {
|
|
229
|
+
const reactPress = await resolveStaticVisitorContext();
|
|
230
|
+
try {
|
|
231
|
+
const data = await withApiRetry(fetchFn);
|
|
232
|
+
return themeStaticProps({ ...data, reactPress });
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
console.error(`[reactpress] ${label}`, error);
|
|
236
|
+
const props = typeof fallback === 'function' ? fallback(error) : fallback;
|
|
237
|
+
return themeStaticProps({ ...props, reactPress });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/** Factory for category/tag archive pages — removes duplicated `getStaticProps` boilerplate. */
|
|
241
|
+
function createArchiveGetStaticProps(kind, fetchArchive, emptyFallback) {
|
|
242
|
+
return async (ctx) => {
|
|
243
|
+
const slug = ctx.params?.[kind];
|
|
244
|
+
if (typeof slug !== 'string' || !slug)
|
|
245
|
+
return (0, static_1.themeNotFound)();
|
|
246
|
+
return withThemeStaticProps(`fetch ${kind} archive failed`, () => fetchArchive(api_1.themeApi, slug), () => emptyFallback(slug));
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/** Standard on-demand article page props. */
|
|
250
|
+
async function fetchArticlePageProps(api, id) {
|
|
251
|
+
if (!id)
|
|
252
|
+
return { article: null };
|
|
253
|
+
const data = await fetchSingleArticle(api, id);
|
|
254
|
+
const article = data.article ?? null;
|
|
255
|
+
if (!article)
|
|
256
|
+
return { article: null };
|
|
257
|
+
return {
|
|
258
|
+
article: {
|
|
259
|
+
...article,
|
|
260
|
+
html: article.html ? (0, assets_1.rewriteArticleHtmlAssets)(article.html) : article.html,
|
|
261
|
+
cover: article.cover ? (0, assets_1.resolvePublicAssetUrl)(article.cover) : article.cover,
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pickSiteSettings = exports.formatPublishDateShort = exports.formatPublishDate = void 0;
|
|
4
|
+
var date_1 = require("../../utils/date");
|
|
5
|
+
Object.defineProperty(exports, "formatPublishDate", { enumerable: true, get: function () { return date_1.formatPublishDate; } });
|
|
6
|
+
Object.defineProperty(exports, "formatPublishDateShort", { enumerable: true, get: function () { return date_1.formatPublishDateShort; } });
|
|
7
|
+
var setting_1 = require("../../utils/setting");
|
|
8
|
+
Object.defineProperty(exports, "pickSiteSettings", { enumerable: true, get: function () { return setting_1.pickSiteSettings; } });
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ThemeApi } from '../api/api';
|
|
2
|
+
import { type CarouselArticle, type ListArticle } from '../content/articleSlim';
|
|
3
|
+
import { type ArchiveTree } from '../content/archiveSlim';
|
|
4
|
+
import type { IArticle, ICategory, IKnowledge, ITag } from '../../types';
|
|
5
|
+
export type HomePageProps = {
|
|
6
|
+
articles: ListArticle[];
|
|
7
|
+
total: number;
|
|
8
|
+
recommendedArticles: CarouselArticle[];
|
|
9
|
+
};
|
|
10
|
+
export type CategoryArchivePageProps = {
|
|
11
|
+
articles: ListArticle[];
|
|
12
|
+
total: number;
|
|
13
|
+
category: Pick<ICategory, 'value' | 'label'> & Partial<ICategory>;
|
|
14
|
+
};
|
|
15
|
+
export type TagArchivePageProps = {
|
|
16
|
+
articles: ListArticle[];
|
|
17
|
+
total: number;
|
|
18
|
+
tag: Pick<ITag, 'value' | 'label'> & Partial<ITag>;
|
|
19
|
+
};
|
|
20
|
+
export type KnowledgeIndexPageProps = {
|
|
21
|
+
books: IKnowledge[];
|
|
22
|
+
total: number;
|
|
23
|
+
};
|
|
24
|
+
export type SearchPageProps = {
|
|
25
|
+
keyword: string;
|
|
26
|
+
articles: IArticle[];
|
|
27
|
+
};
|
|
28
|
+
/** Home / blog index — first page of articles + carousel recommendations. */
|
|
29
|
+
export declare function fetchHomePageProps(api?: ThemeApi, pageSize?: number): Promise<HomePageProps>;
|
|
30
|
+
/** Category archive — paginated list with taxonomy metadata. */
|
|
31
|
+
export declare function fetchCategoryArchivePageProps(api: ThemeApi, categoryValue: string, pageSize?: number): Promise<CategoryArchivePageProps>;
|
|
32
|
+
/** Tag archive — paginated list with taxonomy metadata. */
|
|
33
|
+
export declare function fetchTagArchivePageProps(api: ThemeApi, tagValue: string, pageSize?: number): Promise<TagArchivePageProps>;
|
|
34
|
+
/** Archives tree — year/month grouped article index. */
|
|
35
|
+
export declare function fetchArchivesPageProps(api?: ThemeApi): Promise<{
|
|
36
|
+
articles: ArchiveTree;
|
|
37
|
+
}>;
|
|
38
|
+
/** Knowledge library index — first page. */
|
|
39
|
+
export declare function fetchKnowledgeIndexPageProps(api?: ThemeApi, pageSize?: number): Promise<KnowledgeIndexPageProps>;
|
|
40
|
+
/** Knowledge book detail with sibling books for sidebar. */
|
|
41
|
+
export declare function fetchKnowledgeBookPageProps(api: ThemeApi, pId: string): Promise<{
|
|
42
|
+
pId: string;
|
|
43
|
+
book: IKnowledge | null;
|
|
44
|
+
otherBooks: IKnowledge[];
|
|
45
|
+
}>;
|
|
46
|
+
/** Knowledge chapter detail. */
|
|
47
|
+
export declare function fetchKnowledgeChapterPageProps(api: ThemeApi, pId: string, id: string): Promise<{
|
|
48
|
+
pId: string;
|
|
49
|
+
book: IKnowledge | null;
|
|
50
|
+
id: string;
|
|
51
|
+
chapter: IKnowledge | null;
|
|
52
|
+
}>;
|
|
53
|
+
/** Site search results for `/search?keyword=`. */
|
|
54
|
+
export declare function fetchSearchPageProps(api: ThemeApi, keyword: string): Promise<SearchPageProps>;
|
|
55
|
+
/** CMS static page by id. */
|
|
56
|
+
export declare function fetchCmsPageProps(api: ThemeApi, id: string): Promise<{
|
|
57
|
+
page: unknown;
|
|
58
|
+
}>;
|
|
59
|
+
/** Single article by id (full entity from API). */
|
|
60
|
+
export declare function fetchArticleDetailProps(api: ThemeApi, id: string): Promise<{
|
|
61
|
+
article: IArticle | null;
|
|
62
|
+
}>;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchHomePageProps = fetchHomePageProps;
|
|
4
|
+
exports.fetchCategoryArchivePageProps = fetchCategoryArchivePageProps;
|
|
5
|
+
exports.fetchTagArchivePageProps = fetchTagArchivePageProps;
|
|
6
|
+
exports.fetchArchivesPageProps = fetchArchivesPageProps;
|
|
7
|
+
exports.fetchKnowledgeIndexPageProps = fetchKnowledgeIndexPageProps;
|
|
8
|
+
exports.fetchKnowledgeBookPageProps = fetchKnowledgeBookPageProps;
|
|
9
|
+
exports.fetchKnowledgeChapterPageProps = fetchKnowledgeChapterPageProps;
|
|
10
|
+
exports.fetchSearchPageProps = fetchSearchPageProps;
|
|
11
|
+
exports.fetchCmsPageProps = fetchCmsPageProps;
|
|
12
|
+
exports.fetchArticleDetailProps = fetchArticleDetailProps;
|
|
13
|
+
const api_1 = require("../api/api");
|
|
14
|
+
const api_data_1 = require("../api/api-data");
|
|
15
|
+
const articleSlim_1 = require("../content/articleSlim");
|
|
16
|
+
const archiveSlim_1 = require("../content/archiveSlim");
|
|
17
|
+
const carouselArticles_1 = require("../content/carouselArticles");
|
|
18
|
+
const fetch_1 = require("./fetch");
|
|
19
|
+
const DEFAULT_PAGE_SIZE = 12;
|
|
20
|
+
function fallbackCategory(value) {
|
|
21
|
+
return { value, label: value };
|
|
22
|
+
}
|
|
23
|
+
function fallbackTag(value) {
|
|
24
|
+
return { value, label: value };
|
|
25
|
+
}
|
|
26
|
+
/** Home / blog index — first page of articles + carousel recommendations. */
|
|
27
|
+
async function fetchHomePageProps(api = api_1.themeApi, pageSize = DEFAULT_PAGE_SIZE) {
|
|
28
|
+
return (0, fetch_1.withApiRetry)(async () => {
|
|
29
|
+
const response = await api.article.findAll({
|
|
30
|
+
query: { page: 1, pageSize, status: 'publish' },
|
|
31
|
+
});
|
|
32
|
+
const [rawArticles, total] = (0, api_data_1.unpackPaginatedPair)(response);
|
|
33
|
+
const recommendedArticles = await (0, carouselArticles_1.resolveCarouselArticles)(rawArticles, {
|
|
34
|
+
fetchRecommended: async () => (0, api_data_1.unpackList)(await api.article.getRecommendArticles({})),
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
articles: (0, articleSlim_1.slimArticlesForList)(rawArticles),
|
|
38
|
+
total,
|
|
39
|
+
recommendedArticles,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Category archive — paginated list with taxonomy metadata. */
|
|
44
|
+
async function fetchCategoryArchivePageProps(api, categoryValue, pageSize = DEFAULT_PAGE_SIZE) {
|
|
45
|
+
const [articlesResponse, categoryResponse] = await Promise.all([
|
|
46
|
+
api.article.findArticlesByCategory(categoryValue, {
|
|
47
|
+
query: { page: 1, pageSize, status: 'publish' },
|
|
48
|
+
}),
|
|
49
|
+
api.category.findById(categoryValue),
|
|
50
|
+
]);
|
|
51
|
+
const [rawArticles, total] = (0, api_data_1.unpackPaginatedPair)(articlesResponse);
|
|
52
|
+
const category = (0, api_data_1.unpackOne)(categoryResponse) ?? fallbackCategory(categoryValue);
|
|
53
|
+
return {
|
|
54
|
+
articles: (0, articleSlim_1.slimArticlesForList)(rawArticles),
|
|
55
|
+
total,
|
|
56
|
+
category,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Tag archive — paginated list with taxonomy metadata. */
|
|
60
|
+
async function fetchTagArchivePageProps(api, tagValue, pageSize = DEFAULT_PAGE_SIZE) {
|
|
61
|
+
const [articlesResponse, tagResponse] = await Promise.all([
|
|
62
|
+
api.article.findArticlesByTag(tagValue, {
|
|
63
|
+
query: { page: 1, pageSize, status: 'publish' },
|
|
64
|
+
}),
|
|
65
|
+
api.tag.findById(tagValue),
|
|
66
|
+
]);
|
|
67
|
+
const [rawArticles, total] = (0, api_data_1.unpackPaginatedPair)(articlesResponse);
|
|
68
|
+
const tag = (0, api_data_1.unpackOne)(tagResponse) ?? fallbackTag(tagValue);
|
|
69
|
+
return {
|
|
70
|
+
articles: (0, articleSlim_1.slimArticlesForList)(rawArticles),
|
|
71
|
+
total,
|
|
72
|
+
tag,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Archives tree — year/month grouped article index. */
|
|
76
|
+
async function fetchArchivesPageProps(api = api_1.themeApi) {
|
|
77
|
+
const response = await api.article.getArchives({});
|
|
78
|
+
const raw = (0, api_data_1.unpackOne)(response) ??
|
|
79
|
+
response;
|
|
80
|
+
return {
|
|
81
|
+
articles: (0, archiveSlim_1.slimArchiveTree)(raw ?? {}),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Knowledge library index — first page. */
|
|
85
|
+
async function fetchKnowledgeIndexPageProps(api = api_1.themeApi, pageSize = DEFAULT_PAGE_SIZE) {
|
|
86
|
+
const response = await api.knowledge.findAll({
|
|
87
|
+
query: { page: 1, pageSize, status: 'publish' },
|
|
88
|
+
});
|
|
89
|
+
const [books, total] = (0, api_data_1.unpackPaginatedPair)(response);
|
|
90
|
+
return { books, total };
|
|
91
|
+
}
|
|
92
|
+
/** Knowledge book detail with sibling books for sidebar. */
|
|
93
|
+
async function fetchKnowledgeBookPageProps(api, pId) {
|
|
94
|
+
const [bookResponse, listResponse] = await Promise.all([
|
|
95
|
+
api.knowledge.findById(pId),
|
|
96
|
+
api.knowledge.findAll({ query: { page: 1, pageSize: 6, status: 'publish' } }),
|
|
97
|
+
]);
|
|
98
|
+
const book = (0, api_data_1.unpackOne)(bookResponse);
|
|
99
|
+
const [allBooks] = (0, api_data_1.unpackPaginatedPair)(listResponse);
|
|
100
|
+
return {
|
|
101
|
+
pId,
|
|
102
|
+
book,
|
|
103
|
+
otherBooks: book ? allBooks.filter((item) => item.id !== book.id) : allBooks,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Knowledge chapter detail. */
|
|
107
|
+
async function fetchKnowledgeChapterPageProps(api, pId, id) {
|
|
108
|
+
const [bookResponse, chapterResponse] = await Promise.all([
|
|
109
|
+
api.knowledge.findById(pId),
|
|
110
|
+
api.knowledge.findById(id),
|
|
111
|
+
]);
|
|
112
|
+
return {
|
|
113
|
+
pId,
|
|
114
|
+
book: (0, api_data_1.unpackOne)(bookResponse),
|
|
115
|
+
id,
|
|
116
|
+
chapter: (0, api_data_1.unpackOne)(chapterResponse),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Site search results for `/search?keyword=`. */
|
|
120
|
+
async function fetchSearchPageProps(api, keyword) {
|
|
121
|
+
const trimmed = keyword.trim();
|
|
122
|
+
if (!trimmed) {
|
|
123
|
+
return { keyword: '', articles: [] };
|
|
124
|
+
}
|
|
125
|
+
const response = await api.search.searchArticle({
|
|
126
|
+
query: { keyword: trimmed },
|
|
127
|
+
});
|
|
128
|
+
const articles = (0, api_data_1.unpackList)(response).filter((article) => article.status === 'publish');
|
|
129
|
+
return { keyword: trimmed, articles };
|
|
130
|
+
}
|
|
131
|
+
/** CMS static page by id. */
|
|
132
|
+
async function fetchCmsPageProps(api, id) {
|
|
133
|
+
return { page: (0, api_data_1.unpackOne)(await api.page.findById(id)) };
|
|
134
|
+
}
|
|
135
|
+
/** Single article by id (full entity from API). */
|
|
136
|
+
async function fetchArticleDetailProps(api, id) {
|
|
137
|
+
return { article: (0, api_data_1.unpackOne)(await api.article.findById(id)) };
|
|
138
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Unwrap `setting.findAll()` — API returns a single Setting row in the envelope. */
|
|
2
|
+
export declare function unwrapSetting(response: unknown): Record<string, unknown> | null;
|
|
3
|
+
export interface SiteMeta {
|
|
4
|
+
siteName: string;
|
|
5
|
+
siteDescription: string;
|
|
6
|
+
siteUrl?: string;
|
|
7
|
+
siteLogo?: string;
|
|
8
|
+
siteFavicon?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const DEFAULT_SITE_META: SiteMeta;
|
|
11
|
+
/** Parse branding from an effective Setting row (mods overlay applied by API). */
|
|
12
|
+
export declare function parseSiteMeta(row: Record<string, unknown> | null): SiteMeta;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SITE_META = void 0;
|
|
4
|
+
exports.unwrapSetting = unwrapSetting;
|
|
5
|
+
exports.parseSiteMeta = parseSiteMeta;
|
|
6
|
+
const api_data_1 = require("../api/api-data");
|
|
7
|
+
/** Unwrap `setting.findAll()` — API returns a single Setting row in the envelope. */
|
|
8
|
+
function unwrapSetting(response) {
|
|
9
|
+
const data = (0, api_data_1.unpackOne)(response);
|
|
10
|
+
if (data && typeof data === 'object' && !Array.isArray(data)) {
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
13
|
+
if (response && typeof response === 'object' && !Array.isArray(response)) {
|
|
14
|
+
const maybe = response;
|
|
15
|
+
if ('i18n' in maybe || 'globalSetting' in maybe || 'systemTitle' in maybe) {
|
|
16
|
+
return maybe;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
exports.DEFAULT_SITE_META = {
|
|
22
|
+
siteName: 'ReactPress Site',
|
|
23
|
+
siteDescription: 'A ReactPress powered site',
|
|
24
|
+
};
|
|
25
|
+
/** Parse branding from an effective Setting row (mods overlay applied by API). */
|
|
26
|
+
function parseSiteMeta(row) {
|
|
27
|
+
if (!row) {
|
|
28
|
+
return { ...exports.DEFAULT_SITE_META };
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
siteName: String(row.systemTitle ?? 'ReactPress Site').trim() || exports.DEFAULT_SITE_META.siteName,
|
|
32
|
+
siteDescription: String(row.systemSubTitle ?? exports.DEFAULT_SITE_META.siteDescription).trim() ||
|
|
33
|
+
exports.DEFAULT_SITE_META.siteDescription,
|
|
34
|
+
siteUrl: row.systemUrl != null ? String(row.systemUrl).trim() || undefined : undefined,
|
|
35
|
+
siteLogo: row.systemLogo != null && String(row.systemLogo).trim()
|
|
36
|
+
? String(row.systemLogo).trim()
|
|
37
|
+
: undefined,
|
|
38
|
+
siteFavicon: row.systemFavicon != null && String(row.systemFavicon).trim()
|
|
39
|
+
? String(row.systemFavicon).trim()
|
|
40
|
+
: undefined,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AppBootstrapResult } from './bootstrap';
|
|
2
|
+
export type SlimBootstrapOptions = {
|
|
3
|
+
/** Routes that receive full `siteConfig` and `globalSetting`. Default: `/nav` prefix. */
|
|
4
|
+
fullSiteConfigRoutes?: string[] | ((pathname: string) => boolean);
|
|
5
|
+
/** Keys stripped from `setting` in SSR payload. */
|
|
6
|
+
settingOmitKeys?: readonly string[];
|
|
7
|
+
};
|
|
8
|
+
/** Shrink `_app` SSR payload — drop duplicate JSON blobs and heavy site config on list pages. */
|
|
9
|
+
export declare function slimAppBootstrapForRoute(bootstrap: AppBootstrapResult, pathname: string, options?: SlimBootstrapOptions): AppBootstrapResult;
|
|
10
|
+
/** Preset slimmer for catalog themes with `/nav` pages (Twenty Twenty-Five pattern). */
|
|
11
|
+
export declare function createBootstrapSlimmer(options?: SlimBootstrapOptions): (bootstrap: AppBootstrapResult, pathname: string) => AppBootstrapResult;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.slimAppBootstrapForRoute = slimAppBootstrapForRoute;
|
|
4
|
+
exports.createBootstrapSlimmer = createBootstrapSlimmer;
|
|
5
|
+
const i18n_1 = require("../visitor/i18n");
|
|
6
|
+
const DEFAULT_SETTING_OMIT_KEYS = [
|
|
7
|
+
'i18n',
|
|
8
|
+
'globalSetting',
|
|
9
|
+
'adminSystemUrl',
|
|
10
|
+
'oss',
|
|
11
|
+
'smtpHost',
|
|
12
|
+
'smtpPort',
|
|
13
|
+
'smtpUser',
|
|
14
|
+
'smtpPass',
|
|
15
|
+
'smtpFromUser',
|
|
16
|
+
'createAt',
|
|
17
|
+
'updateAt',
|
|
18
|
+
];
|
|
19
|
+
function slimTags(tags) {
|
|
20
|
+
return tags.map(({ id, label, value, articleCount }) => ({
|
|
21
|
+
id,
|
|
22
|
+
label,
|
|
23
|
+
value,
|
|
24
|
+
articleCount,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
function slimCategories(categories) {
|
|
28
|
+
return categories.map(({ value, label }) => ({ value, label }));
|
|
29
|
+
}
|
|
30
|
+
function slimPages(pages) {
|
|
31
|
+
return pages.map(({ path, name }) => ({ path, name }));
|
|
32
|
+
}
|
|
33
|
+
function slimSetting(setting, omitKeys) {
|
|
34
|
+
const next = { ...setting };
|
|
35
|
+
for (const key of omitKeys) {
|
|
36
|
+
delete next[key];
|
|
37
|
+
}
|
|
38
|
+
return next;
|
|
39
|
+
}
|
|
40
|
+
function defaultFullSiteConfigRoute(pathname) {
|
|
41
|
+
return pathname === '/nav' || pathname.startsWith('/nav/');
|
|
42
|
+
}
|
|
43
|
+
function resolveFullSiteConfigRoute(pathname, options) {
|
|
44
|
+
const matcher = options?.fullSiteConfigRoutes ?? defaultFullSiteConfigRoute;
|
|
45
|
+
return typeof matcher === 'function' ? matcher(pathname) : matcher.some((route) => {
|
|
46
|
+
if (route.endsWith('*')) {
|
|
47
|
+
const prefix = route.slice(0, -1);
|
|
48
|
+
return pathname === prefix || pathname.startsWith(prefix);
|
|
49
|
+
}
|
|
50
|
+
return pathname === route || pathname.startsWith(`${route}/`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** Shrink `_app` SSR payload — drop duplicate JSON blobs and heavy site config on list pages. */
|
|
54
|
+
function slimAppBootstrapForRoute(bootstrap, pathname, options) {
|
|
55
|
+
const fullSiteConfig = resolveFullSiteConfigRoute(pathname, options);
|
|
56
|
+
const omitKeys = options?.settingOmitKeys ?? DEFAULT_SETTING_OMIT_KEYS;
|
|
57
|
+
let siteConfig = bootstrap.siteConfig;
|
|
58
|
+
if (!fullSiteConfig) {
|
|
59
|
+
siteConfig = bootstrap.siteConfig?.header ? { header: bootstrap.siteConfig.header } : {};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
...bootstrap,
|
|
63
|
+
setting: slimSetting(bootstrap.setting, omitKeys),
|
|
64
|
+
tags: slimTags(bootstrap.tags),
|
|
65
|
+
categories: slimCategories(bootstrap.categories),
|
|
66
|
+
pages: slimPages(bootstrap.pages),
|
|
67
|
+
i18n: (0, i18n_1.slimVisitorI18nForSsr)(bootstrap.i18n, bootstrap.initialLocale),
|
|
68
|
+
siteConfig,
|
|
69
|
+
globalSetting: fullSiteConfig ? bootstrap.globalSetting : undefined,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Preset slimmer for catalog themes with `/nav` pages (Twenty Twenty-Five pattern). */
|
|
73
|
+
function createBootstrapSlimmer(options) {
|
|
74
|
+
return (bootstrap, pathname) => slimAppBootstrapForRoute(bootstrap, pathname, options);
|
|
75
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GetStaticPathsResult } from 'next';
|
|
2
|
+
/** WordPress-style on-demand ISR paths (`fallback: true`). */
|
|
3
|
+
export declare const themeOnDemandPaths: GetStaticPathsResult;
|
|
4
|
+
export declare function themeNotFound(): {
|
|
5
|
+
notFound: true;
|
|
6
|
+
};
|
|
7
|
+
export declare function themeStaticNotFound(revalidate?: number): {
|
|
8
|
+
notFound: true;
|
|
9
|
+
revalidate: number;
|
|
10
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.themeOnDemandPaths = void 0;
|
|
4
|
+
exports.themeNotFound = themeNotFound;
|
|
5
|
+
exports.themeStaticNotFound = themeStaticNotFound;
|
|
6
|
+
const fetch_1 = require("./fetch");
|
|
7
|
+
/** WordPress-style on-demand ISR paths (`fallback: true`). */
|
|
8
|
+
exports.themeOnDemandPaths = {
|
|
9
|
+
paths: [],
|
|
10
|
+
fallback: true,
|
|
11
|
+
};
|
|
12
|
+
function themeNotFound() {
|
|
13
|
+
return { notFound: true };
|
|
14
|
+
}
|
|
15
|
+
function themeStaticNotFound(revalidate = fetch_1.THEME_ISR_REVALIDATE_SECONDS) {
|
|
16
|
+
return { notFound: true, revalidate };
|
|
17
|
+
}
|