@cossackframework/cms 0.0.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +145 -2
- package/agent-docs.json +259 -0
- package/app/README.md +78 -0
- package/app/cossack-recipe.json +43 -0
- package/app/src/auth-bot-check.ts +32 -0
- package/app/src/auth-bot-token.ts +11 -0
- package/app/src/auth-input.ts +35 -0
- package/app/src/auth-options.ts +18 -0
- package/app/src/auth-providers.ts +16 -0
- package/app/src/auth.ts +1082 -0
- package/app/src/brand.ts +68 -0
- package/app/src/cms/ai.ts +54 -0
- package/app/src/cms/analytics.ts +33 -0
- package/app/src/cms/block-errors.ts +55 -0
- package/app/src/cms/block-inserter.ts +111 -0
- package/app/src/cms/block-panel.ts +68 -0
- package/app/src/cms/block-rows.ts +44 -0
- package/app/src/cms/block-tree.ts +585 -0
- package/app/src/cms/blocks.css +708 -0
- package/app/src/cms/builder.ts +126 -0
- package/app/src/cms/cache.ts +44 -0
- package/app/src/cms/carousel.client.ts +52 -0
- package/app/src/cms/collab/presence.ts +69 -0
- package/app/src/cms/collab/rich-text-collab.client.ts +197 -0
- package/app/src/cms/collab/rich-text-notes.client.ts +138 -0
- package/app/src/cms/collab/room.ts +881 -0
- package/app/src/cms/compare.client.ts +47 -0
- package/app/src/cms/condition-control.ts +109 -0
- package/app/src/cms/content-api.ts +143 -0
- package/app/src/cms/content.ts +524 -0
- package/app/src/cms/countdown.client.ts +37 -0
- package/app/src/cms/editor-layout-editor.ts +260 -0
- package/app/src/cms/editor-layout-view.ts +37 -0
- package/app/src/cms/editor.ts +381 -0
- package/app/src/cms/entry.ts +26 -0
- package/app/src/cms/feeds.ts +145 -0
- package/app/src/cms/field-controls.ts +222 -0
- package/app/src/cms/field-group-editor.ts +105 -0
- package/app/src/cms/field-group-view.ts +211 -0
- package/app/src/cms/form-view.ts +203 -0
- package/app/src/cms/form.client.ts +203 -0
- package/app/src/cms/guards.ts +27 -0
- package/app/src/cms/handoff.ts +202 -0
- package/app/src/cms/headings.ts +51 -0
- package/app/src/cms/icons.ts +80 -0
- package/app/src/cms/import.client.ts +16 -0
- package/app/src/cms/index.ts +191 -0
- package/app/src/cms/lightbox.client.ts +109 -0
- package/app/src/cms/machine.ts +118 -0
- package/app/src/cms/maintenance.ts +97 -0
- package/app/src/cms/manage.ts +1236 -0
- package/app/src/cms/mcp-tools.ts +388 -0
- package/app/src/cms/mcp.ts +242 -0
- package/app/src/cms/media-chooser.ts +123 -0
- package/app/src/cms/media-usage.ts +57 -0
- package/app/src/cms/middleware.ts +199 -0
- package/app/src/cms/middlewares.ts +13 -0
- package/app/src/cms/network-ui.ts +36 -0
- package/app/src/cms/network-view.ts +38 -0
- package/app/src/cms/notes-announce.ts +65 -0
- package/app/src/cms/notes-rail.ts +207 -0
- package/app/src/cms/notification-rules.ts +66 -0
- package/app/src/cms/recovery.ts +82 -0
- package/app/src/cms/replace.ts +63 -0
- package/app/src/cms/reserved-paths.ts +19 -0
- package/app/src/cms/rich-text-field.ts +325 -0
- package/app/src/cms/rich-text-schema.ts +91 -0
- package/app/src/cms/rich-text.client.ts +255 -0
- package/app/src/cms/search.client.ts +116 -0
- package/app/src/cms/seo-head.ts +78 -0
- package/app/src/cms/seo.ts +241 -0
- package/app/src/cms/settings-draft.ts +218 -0
- package/app/src/cms/settings-file.ts +127 -0
- package/app/src/cms/settings-form.ts +180 -0
- package/app/src/cms/settings-languages.ts +125 -0
- package/app/src/cms/settings-nav.ts +102 -0
- package/app/src/cms/settings-network.ts +151 -0
- package/app/src/cms/settings-permalinks.ts +114 -0
- package/app/src/cms/settings-scroll.ts +10 -0
- package/app/src/cms/settings-search.ts +77 -0
- package/app/src/cms/settings-section.ts +38 -0
- package/app/src/cms/share.client.ts +27 -0
- package/app/src/cms/site-editing.ts +219 -0
- package/app/src/cms/site-editor.client.ts +1008 -0
- package/app/src/cms/site-editor.ts +99 -0
- package/app/src/cms/site-export.ts +60 -0
- package/app/src/cms/site-forms.ts +143 -0
- package/app/src/cms/site-import.ts +28 -0
- package/app/src/cms/site-session.ts +36 -0
- package/app/src/cms/site-taskbar.ts +77 -0
- package/app/src/cms/site-view.ts +1014 -0
- package/app/src/cms/site.ts +1322 -0
- package/app/src/cms/sitemaps.ts +131 -0
- package/app/src/cms/stat.client.ts +56 -0
- package/app/src/cms/style-controls.ts +252 -0
- package/app/src/cms/tabs.client.ts +36 -0
- package/app/src/cms/taskbar.ts +134 -0
- package/app/src/cms/term-icons.ts +10 -0
- package/app/src/cms/traffic.ts +26 -0
- package/app/src/cms/ui.ts +170 -0
- package/app/src/cms/updates.ts +124 -0
- package/app/src/cms/uploads.ts +26 -0
- package/app/src/cms/worker.ts +13 -0
- package/app/src/config/auth.ts +30 -0
- package/app/src/config/cms.ts +18 -0
- package/app/src/dashboard/access.ts +344 -0
- package/app/src/dashboard/agent-icons.ts +44 -0
- package/app/src/dashboard/app-passwords.ts +74 -0
- package/app/src/dashboard/avatar-field.ts +58 -0
- package/app/src/dashboard/bulk.ts +53 -0
- package/app/src/dashboard/head.ts +29 -0
- package/app/src/dashboard/icons.ts +15 -0
- package/app/src/dashboard/list-table.ts +120 -0
- package/app/src/dashboard/modules/roles.ts +15 -0
- package/app/src/dashboard/modules/sessions.ts +15 -0
- package/app/src/dashboard/modules/settings.ts +15 -0
- package/app/src/dashboard/modules/users.ts +18 -0
- package/app/src/dashboard/page.ts +67 -0
- package/app/src/dashboard/registry.ts +13 -0
- package/app/src/dashboard/session-list.ts +98 -0
- package/app/src/dashboard/tabs.ts +26 -0
- package/app/src/dashboard/time-ago.ts +16 -0
- package/app/src/dashboard/types.ts +40 -0
- package/app/src/dashboard/user-sections.ts +172 -0
- package/app/src/lib/permissions.ts +84 -0
- package/app/src/middlewares/auth.ts +117 -0
- package/app/src/pages/(site)/[...path]/index.ts +609 -0
- package/app/src/pages/(site)/feed/[...rest]/index.ts +13 -0
- package/app/src/pages/(site)/feed/index.ts +12 -0
- package/app/src/pages/(site)/index.ts +11 -0
- package/app/src/pages/(site)/indexnow/[file]/index.ts +18 -0
- package/app/src/pages/(site)/layout.ts +219 -0
- package/app/src/pages/(site)/llms.txt/index.ts +23 -0
- package/app/src/pages/(site)/manifest.webmanifest/index.ts +29 -0
- package/app/src/pages/(site)/media/[id]/[name]/index.ts +59 -0
- package/app/src/pages/(site)/preview/[collection]/[id]/index.ts +115 -0
- package/app/src/pages/(site)/robots.txt/index.ts +29 -0
- package/app/src/pages/(site)/search/index.ts +36 -0
- package/app/src/pages/(site)/sitemap.xml/index.ts +26 -0
- package/app/src/pages/(site)/sitemaps/[file]/index.ts +33 -0
- package/app/src/pages/api/auth/session.ts +48 -0
- package/app/src/pages/api/cms/appearance/areas/[name].ts +12 -0
- package/app/src/pages/api/cms/appearance/areas/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/[location].ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/menus/[id].ts +12 -0
- package/app/src/pages/api/cms/appearance/menus/index.ts +13 -0
- package/app/src/pages/api/cms/appearance/themes/[name]/activate.ts +6 -0
- package/app/src/pages/api/cms/appearance/themes/index.ts +6 -0
- package/app/src/pages/api/cms/cache/purge.ts +6 -0
- package/app/src/pages/api/cms/collections/index.ts +6 -0
- package/app/src/pages/api/cms/commands/[plugin]/[command].ts +26 -0
- package/app/src/pages/api/cms/comments/[id].ts +9 -0
- package/app/src/pages/api/cms/comments/index.ts +126 -0
- package/app/src/pages/api/cms/comments/queue.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/autosave.ts +27 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/blocks/[block].ts +16 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/notes.ts +18 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/publish.ts +11 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/restore.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/unpublish.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry].ts +42 -0
- package/app/src/pages/api/cms/content/[collection]/index.ts +24 -0
- package/app/src/pages/api/cms/export/[collection].ts +37 -0
- package/app/src/pages/api/cms/forms/[slug]/index.ts +173 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/[submission]/files/[file].ts +25 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/export.ts +34 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/index.ts +24 -0
- package/app/src/pages/api/cms/import/[collection].ts +23 -0
- package/app/src/pages/api/cms/mcp.ts +29 -0
- package/app/src/pages/api/cms/me/index.ts +6 -0
- package/app/src/pages/api/cms/me/recent-blocks.ts +37 -0
- package/app/src/pages/api/cms/me/tokens/[id].ts +6 -0
- package/app/src/pages/api/cms/me/tokens/index.ts +13 -0
- package/app/src/pages/api/cms/media/[id].ts +6 -0
- package/app/src/pages/api/cms/media.ts +26 -0
- package/app/src/pages/api/cms/menus/[location].ts +14 -0
- package/app/src/pages/api/cms/network/sites/[id]/export.ts +15 -0
- package/app/src/pages/api/cms/network/sites/[id]/index.ts +9 -0
- package/app/src/pages/api/cms/network/sites/index.ts +14 -0
- package/app/src/pages/api/cms/notes/[id].ts +13 -0
- package/app/src/pages/api/cms/notes/index.ts +6 -0
- package/app/src/pages/api/cms/payments/webhook.ts +28 -0
- package/app/src/pages/api/cms/plugins/[name]/grant.ts +6 -0
- package/app/src/pages/api/cms/plugins/[name]/revoke.ts +6 -0
- package/app/src/pages/api/cms/plugins/index.ts +6 -0
- package/app/src/pages/api/cms/recovery.ts +29 -0
- package/app/src/pages/api/cms/redirects/index.ts +9 -0
- package/app/src/pages/api/cms/roles/index.ts +6 -0
- package/app/src/pages/api/cms/schema/[collection].ts +13 -0
- package/app/src/pages/api/cms/search.ts +16 -0
- package/app/src/pages/api/cms/settings/[group].ts +9 -0
- package/app/src/pages/api/cms/settings/index.ts +9 -0
- package/app/src/pages/api/cms/site-export.ts +34 -0
- package/app/src/pages/api/cms/taxonomies/index.ts +6 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/[id].ts +12 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/index.ts +9 -0
- package/app/src/pages/api/cms/uploads/[id]/complete.ts +15 -0
- package/app/src/pages/api/cms/uploads/[id]/index.ts +15 -0
- package/app/src/pages/api/cms/uploads/index.ts +26 -0
- package/app/src/pages/api/cms/users/[id]/index.ts +12 -0
- package/app/src/pages/api/cms/users/[id]/meta.ts +40 -0
- package/app/src/pages/api/cms/users/index.ts +12 -0
- package/app/src/pages/api/cms/webhooks/[id].ts +6 -0
- package/app/src/pages/api/cms/webhooks/index.ts +9 -0
- package/app/src/pages/auth/[provider]/callback.ts +11 -0
- package/app/src/pages/auth/[provider]/redirect.ts +9 -0
- package/app/src/pages/auth/forgot-password/index.ts +75 -0
- package/app/src/pages/auth/layout.ts +32 -0
- package/app/src/pages/auth/login/index.ts +198 -0
- package/app/src/pages/auth/magic/index.ts +68 -0
- package/app/src/pages/auth/register/index.ts +117 -0
- package/app/src/pages/auth/reset-password/index.ts +65 -0
- package/app/src/pages/auth/setup/index.ts +194 -0
- package/app/src/pages/auth/two-factor/index.ts +67 -0
- package/app/src/pages/auth/verify/index.ts +62 -0
- package/app/src/pages/dashboard/(cms)/appearance/customize/index.ts +263 -0
- package/app/src/pages/dashboard/(cms)/appearance/dashboard-menu/index.ts +241 -0
- package/app/src/pages/dashboard/(cms)/appearance/index.ts +89 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/[id]/index.ts +697 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/index.ts +145 -0
- package/app/src/pages/dashboard/(cms)/appearance/widgets/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/blocks/index.ts +84 -0
- package/app/src/pages/dashboard/(cms)/calendar/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/collections/[name]/index.ts +525 -0
- package/app/src/pages/dashboard/(cms)/collections/index.ts +72 -0
- package/app/src/pages/dashboard/(cms)/collections/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/comments/index.ts +237 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/index.ts +2382 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/revisions/index.ts +126 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/index.ts +693 -0
- package/app/src/pages/dashboard/(cms)/field-groups/[id]/index.ts +193 -0
- package/app/src/pages/dashboard/(cms)/field-groups/index.ts +65 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/[submission]/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/index.ts +170 -0
- package/app/src/pages/dashboard/(cms)/forms/index.ts +171 -0
- package/app/src/pages/dashboard/(cms)/media/[id]/index.ts +317 -0
- package/app/src/pages/dashboard/(cms)/media/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/media/new/index.ts +9 -0
- package/app/src/pages/dashboard/(cms)/media/summary/index.ts +74 -0
- package/app/src/pages/dashboard/(cms)/my-sites/index.ts +63 -0
- package/app/src/pages/dashboard/(cms)/network/index.ts +53 -0
- package/app/src/pages/dashboard/(cms)/network/plugins/index.ts +110 -0
- package/app/src/pages/dashboard/(cms)/network/sites/[id]/index.ts +243 -0
- package/app/src/pages/dashboard/(cms)/network/sites/index.ts +186 -0
- package/app/src/pages/dashboard/(cms)/network/sites/new/index.ts +77 -0
- package/app/src/pages/dashboard/(cms)/network/themes/index.ts +82 -0
- package/app/src/pages/dashboard/(cms)/network/updates/index.ts +48 -0
- package/app/src/pages/dashboard/(cms)/network/users/[id]/index.ts +176 -0
- package/app/src/pages/dashboard/(cms)/network/users/index.ts +174 -0
- package/app/src/pages/dashboard/(cms)/network/users/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/plugins/index.ts +172 -0
- package/app/src/pages/dashboard/(cms)/profile/public/index.ts +105 -0
- package/app/src/pages/dashboard/(cms)/registrations/index.ts +70 -0
- package/app/src/pages/dashboard/(cms)/settings/index.ts +359 -0
- package/app/src/pages/dashboard/(cms)/settings/json/index.ts +202 -0
- package/app/src/pages/dashboard/(cms)/settings/layout.ts +67 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/[name]/index.ts +85 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/index.ts +98 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/[id]/index.ts +244 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/index.ts +148 -0
- package/app/src/pages/dashboard/(cms)/tools/activity/index.ts +94 -0
- package/app/src/pages/dashboard/(cms)/tools/automations/index.ts +131 -0
- package/app/src/pages/dashboard/(cms)/tools/cache/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/tools/export/index.ts +99 -0
- package/app/src/pages/dashboard/(cms)/tools/health/index.ts +189 -0
- package/app/src/pages/dashboard/(cms)/tools/jobs/index.ts +93 -0
- package/app/src/pages/dashboard/(cms)/tools/links/index.ts +115 -0
- package/app/src/pages/dashboard/(cms)/tools/redirects/index.ts +161 -0
- package/app/src/pages/dashboard/(cms)/tools/replace/index.ts +124 -0
- package/app/src/pages/dashboard/(cms)/tools/schema/index.ts +54 -0
- package/app/src/pages/dashboard/(cms)/tools/seo/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/tools/updates/index.ts +114 -0
- package/app/src/pages/dashboard/(cms)/tools/webhooks/index.ts +182 -0
- package/app/src/pages/dashboard/index.ts +214 -0
- package/app/src/pages/dashboard/layout.ts +320 -0
- package/app/src/pages/dashboard/profile/index.ts +211 -0
- package/app/src/pages/dashboard/profile/security/index.ts +255 -0
- package/app/src/pages/dashboard/roles/[id]/index.ts +116 -0
- package/app/src/pages/dashboard/roles/index.ts +134 -0
- package/app/src/pages/dashboard/roles/new/index.ts +95 -0
- package/app/src/pages/dashboard/sessions/index.ts +105 -0
- package/app/src/pages/dashboard/users/[id]/index.ts +472 -0
- package/app/src/pages/dashboard/users/index.ts +299 -0
- package/app/src/pages/dashboard/users/new/index.ts +123 -0
- package/app/src/passkeys.client.ts +18 -0
- package/app/src/plugins/default-theme/assets/cover.svg +31 -0
- package/app/src/plugins/default-theme/assets/logo.svg +8 -0
- package/app/src/plugins/default-theme/parts/comments.ts +66 -0
- package/app/src/plugins/default-theme/parts/list.ts +38 -0
- package/app/src/plugins/default-theme/parts/media.ts +15 -0
- package/app/src/plugins/default-theme/parts/options.ts +45 -0
- package/app/src/plugins/default-theme/plugin.json +275 -0
- package/app/src/plugins/default-theme/templates/archive.ts +14 -0
- package/app/src/plugins/default-theme/templates/entry-blank.ts +13 -0
- package/app/src/plugins/default-theme/templates/entry.ts +27 -0
- package/app/src/plugins/default-theme/templates/home.ts +8 -0
- package/app/src/plugins/default-theme/templates/layout.ts +40 -0
- package/app/src/plugins/default-theme/templates/not-found.ts +10 -0
- package/app/src/plugins/default-theme/templates/search.ts +32 -0
- package/app/src/services/rbac.ts +65 -0
- package/app/src/services/roles.ts +89 -0
- package/app/src/services/users.ts +173 -0
- package/package.json +114 -2
- package/src/automations.ts +95 -0
- package/src/bindings.ts +138 -0
- package/src/block-references.ts +239 -0
- package/src/block-shape.ts +155 -0
- package/src/blocks.ts +1157 -0
- package/src/cache.ts +54 -0
- package/src/checks.ts +198 -0
- package/src/cloudflare-workers.d.ts +13 -0
- package/src/cloudflare.ts +61 -0
- package/src/collab.ts +372 -0
- package/src/collections.ts +421 -0
- package/src/comments.ts +46 -0
- package/src/cron.ts +95 -0
- package/src/dashboard-menu.ts +105 -0
- package/src/diff.ts +113 -0
- package/src/editor-layout.ts +316 -0
- package/src/errors.ts +50 -0
- package/src/field-groups.ts +498 -0
- package/src/fields.ts +411 -0
- package/src/form-builder.ts +1053 -0
- package/src/forms.ts +109 -0
- package/src/highlight.ts +134 -0
- package/src/hooks.ts +510 -0
- package/src/icon-catalog.ts +55 -0
- package/src/icons.ts +128 -0
- package/src/images.ts +149 -0
- package/src/index.ts +100 -0
- package/src/isolate-core.ts +245 -0
- package/src/isolate.ts +19 -0
- package/src/isolation.ts +69 -0
- package/src/mail.ts +182 -0
- package/src/manifest.ts +476 -0
- package/src/media.ts +193 -0
- package/src/menus.ts +287 -0
- package/src/module.ts +32 -0
- package/src/modules/content.ts +64 -0
- package/src/modules/forms.ts +35 -0
- package/src/node.ts +66 -0
- package/src/notes.ts +237 -0
- package/src/permissions.ts +139 -0
- package/src/plugin-settings.ts +114 -0
- package/src/records.ts +56 -0
- package/src/redirects.ts +59 -0
- package/src/resource.ts +245 -0
- package/src/richtext.ts +402 -0
- package/src/schema-json.ts +112 -0
- package/src/search.ts +89 -0
- package/src/seo.ts +477 -0
- package/src/server/accounts.ts +418 -0
- package/src/server/ai.ts +33 -0
- package/src/server/api-tokens.ts +91 -0
- package/src/server/areas.ts +116 -0
- package/src/server/audit.ts +94 -0
- package/src/server/auth.ts +89 -0
- package/src/server/automations.ts +190 -0
- package/src/server/autosaves.ts +69 -0
- package/src/server/brand-icons.ts +50 -0
- package/src/server/brands.ts +86 -0
- package/src/server/budget.ts +97 -0
- package/src/server/cache.ts +104 -0
- package/src/server/capabilities.ts +333 -0
- package/src/server/cloudflare.ts +92 -0
- package/src/server/comments.ts +237 -0
- package/src/server/drafts.ts +176 -0
- package/src/server/field-groups.ts +88 -0
- package/src/server/files.ts +780 -0
- package/src/server/forms.ts +726 -0
- package/src/server/handoffs.ts +107 -0
- package/src/server/host-schema.ts +312 -0
- package/src/server/host.ts +2892 -0
- package/src/server/images.ts +34 -0
- package/src/server/index.ts +59 -0
- package/src/server/indexnow.ts +91 -0
- package/src/server/isolation.ts +183 -0
- package/src/server/locked.ts +45 -0
- package/src/server/mail.ts +93 -0
- package/src/server/markdown.ts +24 -0
- package/src/server/menus.ts +286 -0
- package/src/server/network-policy.ts +60 -0
- package/src/server/network.ts +665 -0
- package/src/server/notes.ts +275 -0
- package/src/server/outbox.ts +213 -0
- package/src/server/path-moves.ts +33 -0
- package/src/server/payments.ts +59 -0
- package/src/server/previews.ts +62 -0
- package/src/server/purge.ts +140 -0
- package/src/server/reconcile.ts +38 -0
- package/src/server/redirects.ts +183 -0
- package/src/server/repository.ts +1107 -0
- package/src/server/schedules.ts +105 -0
- package/src/server/schema.ts +562 -0
- package/src/server/security.ts +391 -0
- package/src/server/seed.ts +52 -0
- package/src/server/shared-fields.ts +34 -0
- package/src/server/site-export.ts +151 -0
- package/src/server/site-import.ts +482 -0
- package/src/server/site-search.ts +289 -0
- package/src/server/site-settings.ts +286 -0
- package/src/server/sites.ts +243 -0
- package/src/server/stores.ts +314 -0
- package/src/server/stripe.ts +173 -0
- package/src/server/taxonomies.ts +415 -0
- package/src/server/tokens.ts +25 -0
- package/src/server/traffic.ts +118 -0
- package/src/server/users.ts +653 -0
- package/src/server/webhooks.ts +245 -0
- package/src/settings-controls.ts +54 -0
- package/src/settings-document.ts +111 -0
- package/src/settings.ts +426 -0
- package/src/storage/cloudflare.ts +94 -0
- package/src/storage/index.ts +30 -0
- package/src/storage/node.ts +114 -0
- package/src/taxonomy.ts +51 -0
- package/src/theme.ts +1135 -0
- package/src/to-markdown.ts +179 -0
- package/src/updates.ts +126 -0
- package/src/version.ts +2 -0
- package/src/vite.d.ts +25 -0
- package/src/vite.js +199 -0
- package/src/webhooks.ts +107 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Page } from '@cossackframework/core';
|
|
2
|
+
import SitePath, { resolveSitePath } from './[...path]/index';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The home page: Settings → Reading's front page, or the latest posts. It is the page of every
|
|
6
|
+
* other site path (`[...path]`, which resolves `/` as the home page) under its own route, so a
|
|
7
|
+
* static front page is edited in place at `/?edit` like any other page. With the examples
|
|
8
|
+
* feature, the examples home page takes `/` and this file is not rendered.
|
|
9
|
+
*/
|
|
10
|
+
@Page({ transport: 'http', middlewares: [resolveSitePath] })
|
|
11
|
+
export default class HomePage extends SitePath {}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Cossack, Page } from '@cossackframework/core';
|
|
2
|
+
import { isCmsError } from '@cossackframework/cms';
|
|
3
|
+
|
|
4
|
+
/** The IndexNow key file, `/indexnow/<key>.txt`: engines fetch it to check that a ping came from the site. */
|
|
5
|
+
@Page({ transport: 'http' })
|
|
6
|
+
export default class IndexNowKey extends Cossack {
|
|
7
|
+
async get() {
|
|
8
|
+
const cms = this.c.get('cms');
|
|
9
|
+
try {
|
|
10
|
+
const key = await cms.indexnow.key();
|
|
11
|
+
if (!key || this.c.req.param('file') !== `${key}.txt`) return new Response('Not found', { status: 404 });
|
|
12
|
+
return new Response(key, { headers: { 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'public, max-age=86400', 'x-robots-tag': 'noindex' } });
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (!isCmsError(error, 'CMS_UNAVAILABLE')) throw error;
|
|
15
|
+
return new Response('Not available yet', { status: 503 });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { Client, ClientState, Cossack, Page, Server, State, server$, setRequestLocale, type HeadContext, type HeadTag, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { analyticsTags, NO_ANALYTICS, type AnalyticsServices } from '#app/cms/analytics';
|
|
3
|
+
import { listedCollections } from '#app/cms/cache';
|
|
4
|
+
import { html } from '@cossackframework/renderer';
|
|
5
|
+
import { hasPermission, PERMISSIONS, PLACEHOLDER_SCRIPT, usesUserBinding, type RenderedBlock, type SiteView, type ThemeData } from '@cossackframework/cms';
|
|
6
|
+
import { areaViews, bindableEntry, bindingScopes, languageLinks, resolvedOptions, siteMenus, siteView, themeData, themeState, unlockCookie, type Resolved, type ThemeState } from '#app/cms/site';
|
|
7
|
+
import { getCookie } from 'hono/cookie';
|
|
8
|
+
import { blockOptions } from '#app/cms/content';
|
|
9
|
+
import { areaDraftBlocks, patternDraftBlocks } from '#app/cms/site-editing';
|
|
10
|
+
import { siteSession, type AreaDraft, type PatternDraft, type SiteEditingContext } from '#app/cms/site-session';
|
|
11
|
+
import { closeMenusOnFollow, pluginHeads, siteTheme, tagDocument, themeHelpers } from '#app/cms/site-view';
|
|
12
|
+
import { siteTaskbar } from '#app/cms/site-taskbar';
|
|
13
|
+
import { ICON_STYLE_META, iconStyle } from '#app/cms/icons';
|
|
14
|
+
import { taskbar, type TaskbarView } from '#app/cms/taskbar';
|
|
15
|
+
|
|
16
|
+
import { logout } from '#app/auth';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The public site's frame, drawn by the active theme's layout, in the page's language, with
|
|
20
|
+
* the taskbar signed-in users see along the bottom. The taskbar is a `server$` resource: it is
|
|
21
|
+
* built during render, after the page's `init()` described the page (`c.set('cms.taskbar')`),
|
|
22
|
+
* and again on every client navigation, which a layout's `@State` is not.
|
|
23
|
+
*
|
|
24
|
+
* Every page under `(site)` gets this frame, the application's and plugins' own pages too:
|
|
25
|
+
* `src/plugins/<name>/pages/(site)/docs/guide.md` serves `/docs/guide` inside the theme.
|
|
26
|
+
* `ssg: false`: the frame comes from the database, so no page under it is rendered at build
|
|
27
|
+
* time, Markdown pages included, which otherwise are.
|
|
28
|
+
*/
|
|
29
|
+
@Page({ transport: 'http', ssg: false })
|
|
30
|
+
export default class SiteLayout extends Cossack {
|
|
31
|
+
/** The signed-in user's taskbar; null for visitors, whose pages carry no trace of it. */
|
|
32
|
+
taskbar: TaskbarView | null = server$(() => siteTaskbar(this.c, this.user), { initial: null });
|
|
33
|
+
@State() logoutError = '';
|
|
34
|
+
/** Settings → Analytics: the services counting this page, none for people signed in. */
|
|
35
|
+
@State() analytics: AnalyticsServices = NO_ANALYTICS;
|
|
36
|
+
@State() site: SiteView & { noindex: boolean } = { title: '', tagline: '', logo: null, blog: null, menus: {}, noindex: false, locale: 'en', languages: [], searchUrl: '/search', homeUrl: '/', areas: {}, template: null, url: '', breadcrumbs: [] };
|
|
37
|
+
@State() theme: ThemeState = { name: null, options: {} };
|
|
38
|
+
/** What the theme's `layout` loader returned. */
|
|
39
|
+
@State() data: ThemeData = {};
|
|
40
|
+
/** Settings → General: the site icon for tabs and the app icon for home screens, as URLs; empty for the application's own. */
|
|
41
|
+
@State() icons: { favicon: string; appIcon: string } = { favicon: '', appIcon: '' };
|
|
42
|
+
/**
|
|
43
|
+
* Live Edit: the page's area documents at render time (`c.set('cms.editing')` in the page's
|
|
44
|
+
* init), so the areas render with their markers from the first paint. The page owns the
|
|
45
|
+
* entry; the frame is this layout's, which previews the areas from the shared session.
|
|
46
|
+
*/
|
|
47
|
+
editing: SiteEditingContext | null = server$(() => this.c.get('cms.editing') ?? null, { initial: null });
|
|
48
|
+
/** The browser left edit mode: the markers go, the saved areas show. */
|
|
49
|
+
@ClientState() exited = false;
|
|
50
|
+
private unsubscribe: (() => void) | undefined;
|
|
51
|
+
/** Stops closing the theme's menus after a followed link. */
|
|
52
|
+
private menusWatched: (() => void) | undefined;
|
|
53
|
+
private sessionSeen = false;
|
|
54
|
+
private previewTimer: ReturnType<typeof setTimeout> | undefined;
|
|
55
|
+
private pendingPreview: { areas: AreaDraft[]; patterns: PatternDraft[] } | null | undefined;
|
|
56
|
+
private previewing = false;
|
|
57
|
+
|
|
58
|
+
onMount() {
|
|
59
|
+
this.menusWatched = closeMenusOnFollow();
|
|
60
|
+
this.unsubscribe = siteSession.subscribe(session => {
|
|
61
|
+
if (session) { this.sessionSeen = true; this.exited = false; this.queuePreview(session); }
|
|
62
|
+
else if (this.sessionSeen) { this.sessionSeen = false; this.exited = true; this.queuePreview(null); }
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
onCleanup() {
|
|
67
|
+
this.unsubscribe?.();
|
|
68
|
+
this.menusWatched?.();
|
|
69
|
+
if (this.previewTimer) clearTimeout(this.previewTimer);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Preview the areas from the drafts, one request at a time, a moment after the last change. */
|
|
73
|
+
@Client()
|
|
74
|
+
private queuePreview(session: { areas: AreaDraft[]; patterns: PatternDraft[] } | null) {
|
|
75
|
+
this.pendingPreview = session;
|
|
76
|
+
if (this.previewTimer) clearTimeout(this.previewTimer);
|
|
77
|
+
this.previewTimer = setTimeout(() => { void this.runPreview(); }, 150);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Client()
|
|
81
|
+
private async runPreview() {
|
|
82
|
+
if (this.previewing) return;
|
|
83
|
+
this.previewing = true;
|
|
84
|
+
try {
|
|
85
|
+
while (this.pendingPreview !== undefined) {
|
|
86
|
+
const next = this.pendingPreview;
|
|
87
|
+
this.pendingPreview = undefined;
|
|
88
|
+
await this.previewAreas(next);
|
|
89
|
+
}
|
|
90
|
+
} finally { this.previewing = false; }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The frame rendered from the editor's drafts (the areas, and the patterns the areas and menus show), or from what is saved when the session ends. */
|
|
94
|
+
@Server()
|
|
95
|
+
async previewAreas(session: { areas: AreaDraft[]; patterns: PatternDraft[] } | null) {
|
|
96
|
+
const cms = this.c.get('cms');
|
|
97
|
+
const principal = this.c.get('principal');
|
|
98
|
+
if (principal.kind !== 'user') return;
|
|
99
|
+
const settings = await cms.settings.all();
|
|
100
|
+
const info = cms.themes().find(entry => entry.name === this.theme.name);
|
|
101
|
+
const options = session ? await blockOptions(cms) : [];
|
|
102
|
+
const user = this.user ? { name: this.user.name } : null;
|
|
103
|
+
// Areas change only for users who may edit them; a pattern previews for whoever edits it, in the areas and the menus' panels.
|
|
104
|
+
const drafts = session && hasPermission(principal, PERMISSIONS.manageAppearance) ? areaDraftBlocks(session.areas, options) : undefined;
|
|
105
|
+
const patternDrafts = session?.patterns.length ? patternDraftBlocks(session.patterns, options) : undefined;
|
|
106
|
+
// Previews bind to the site and the user; the entry shown is the page's, not known here.
|
|
107
|
+
const areas = await areaViews(cms, info?.areas ?? [], undefined, bindingScopes(settings, { user }), undefined, drafts, patternDrafts);
|
|
108
|
+
const menus = patternDrafts || this.patternsPreviewed ? await siteMenus(cms, this.theme, { locale: this.site.locale, user, patternDrafts }) : this.site.menus;
|
|
109
|
+
this.patternsPreviewed = Boolean(patternDrafts);
|
|
110
|
+
this.site = { ...this.site, areas, menus };
|
|
111
|
+
}
|
|
112
|
+
/** The menus were rendered with pattern drafts: render them again when the drafts go. */
|
|
113
|
+
@State() patternsPreviewed = false;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Pages set their own titles; the site title is the fallback. The theme's head template
|
|
117
|
+
* adds stylesheets, fonts and meta under the page's own: a page's title and meta win.
|
|
118
|
+
*/
|
|
119
|
+
head(context: HeadContext): HeadValue {
|
|
120
|
+
const theme = siteTheme(this.theme);
|
|
121
|
+
const helpers = themeHelpers(theme, { ...this.theme, data: { layout: this.data }, languages: this.site.languages, menus: this.site.menus, site: this.site }, () => false);
|
|
122
|
+
const contributed = theme.head?.({ site: this.site, helpers }) ?? {};
|
|
123
|
+
// Active plugins add their tags under the theme's: a stylesheet for their blocks, say.
|
|
124
|
+
const added = pluginHeads(this.theme, this.site, helpers);
|
|
125
|
+
const key = (tag: HeadTag) => String(tag.attributes?.name ?? tag.attributes?.property ?? '');
|
|
126
|
+
const taken = new Set(context.meta.map(key).filter(Boolean));
|
|
127
|
+
const scripts = [...(contributed.scripts ?? []), ...added.flatMap(head => head.scripts ?? [])];
|
|
128
|
+
return {
|
|
129
|
+
title: context.title || contributed.title || this.site.title,
|
|
130
|
+
...(contributed.description && !context.description ? { description: contributed.description } : {}),
|
|
131
|
+
...(contributed.image && !context.image ? { image: contributed.image } : {}),
|
|
132
|
+
meta: [
|
|
133
|
+
...[...(contributed.meta ?? []), ...added.flatMap(head => head.meta ?? [])].filter(tag => !taken.has(key(tag))),
|
|
134
|
+
...(this.site.noindex ? [{ tag: 'meta', attributes: { name: 'robots', content: 'noindex, nofollow' } }] : []),
|
|
135
|
+
{ tag: 'meta', attributes: { property: 'og:site_name', content: this.site.title } },
|
|
136
|
+
// The icon style the sprites are drawn in, so Live Edit's client renders match the server's.
|
|
137
|
+
{ tag: 'meta', attributes: { name: ICON_STYLE_META, content: iconStyle() } },
|
|
138
|
+
],
|
|
139
|
+
links: [...(contributed.links ?? []), ...added.flatMap(head => head.links ?? []), ...(this.site.blog ? [{ tag: 'link', attributes: { rel: 'alternate', type: 'application/rss+xml', title: this.site.title, href: '/feed' } }] : []), ...this.iconLinks()],
|
|
140
|
+
...(scripts.length ? { scripts } : {}),
|
|
141
|
+
// The site's Additional CSS, checked on save, after the theme's own tags; then the script that drops
|
|
142
|
+
// an image's blurred placeholder once it has loaded, so it never shows through transparent pixels.
|
|
143
|
+
tags: [...(contributed.tags ?? []), ...(this.theme.customCss ? [{ tag: 'style', attributes: { 'data-cms-custom-css': '' }, children: this.theme.customCss }] : []),
|
|
144
|
+
{ tag: 'script', attributes: { 'data-cms-placeholders': '' }, children: PLACEHOLDER_SCRIPT },
|
|
145
|
+
...analyticsTags(this.analytics)],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** The site icon for tabs, the app icon for home screens, and the manifest that lists it. */
|
|
150
|
+
private iconLinks(): HeadTag[] {
|
|
151
|
+
const { favicon, appIcon } = this.icons;
|
|
152
|
+
const resized = (url: string, size: number) => url.startsWith('/media/') ? `${url}?w=${size}&h=${size}` : url;
|
|
153
|
+
return [
|
|
154
|
+
...(favicon ? [{ tag: 'link', attributes: { rel: 'icon', href: favicon, ...(/\.svg(?:$|[?#])/i.test(favicon) ? { type: 'image/svg+xml' } : {}) } }] : []),
|
|
155
|
+
...(appIcon ? [{ tag: 'link', attributes: { rel: 'apple-touch-icon', sizes: '180x180', href: resized(appIcon, 180) } }, { tag: 'link', attributes: { rel: 'manifest', href: '/manifest.webmanifest' } }] : []),
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@Server()
|
|
160
|
+
async doLogout() {
|
|
161
|
+
this.logoutError = '';
|
|
162
|
+
try {
|
|
163
|
+
const { headers } = await logout(this.c);
|
|
164
|
+
headers.forEach((value, key) => this.c.header(key, value));
|
|
165
|
+
this.redirect(config('auth.redirectAfterLogout'));
|
|
166
|
+
} catch {
|
|
167
|
+
this.logoutError = __('Could not sign out. Try again.');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async init() {
|
|
172
|
+
const cms = this.c.get('cms');
|
|
173
|
+
// A signed-in user's page carries their taskbar: never share it through a cache.
|
|
174
|
+
if (this.user) this.c.header('cache-control', 'private, no-store');
|
|
175
|
+
try {
|
|
176
|
+
this.theme = await themeState(cms);
|
|
177
|
+
const settings = await cms.settings.all();
|
|
178
|
+
this.icons = { favicon: settings['general.favicon'], appIcon: settings['general.appIcon'] };
|
|
179
|
+
const languages = await cms.languages();
|
|
180
|
+
// The catch-all route resolves its path first; other routes are in the default language.
|
|
181
|
+
const resolved = this.c.get('cms.site');
|
|
182
|
+
const path = this.c.req.path;
|
|
183
|
+
const page: Resolved | { kind: 'other'; locale: string } = resolved && 'locale' in resolved ? resolved
|
|
184
|
+
: path === '/' ? { kind: 'home', locale: languages.default }
|
|
185
|
+
: path === '/search' ? { kind: 'search', locale: languages.default }
|
|
186
|
+
// A page of the application's or a plugin's own under (site), a Markdown page say: the frame around it, nothing the CMS resolved.
|
|
187
|
+
: { kind: 'other', locale: languages.default };
|
|
188
|
+
// The catch-all route set its content's language; the others render in the default one.
|
|
189
|
+
if (!(resolved && 'locale' in resolved)) setRequestLocale(languages.default);
|
|
190
|
+
const template = resolved?.kind === 'entry' && typeof resolved.record.template === 'string' && resolved.record.template ? resolved.record.template : null;
|
|
191
|
+
// Widgets and theme options bind like blocks: `$` is the entry shown, `$site` and `$user` are there on every page.
|
|
192
|
+
// A locked entry binds as its readers see it unless this reader may read it; the password never binds.
|
|
193
|
+
const principal = this.c.get('principal');
|
|
194
|
+
const entry = resolved?.kind === 'entry' ? await bindableEntry(cms, resolved.collection.name, resolved.record, principal, getCookie(this.c, unlockCookie(resolved.record))) : null;
|
|
195
|
+
// `$user` is the signed-in principal's: a session still owing its second factor binds as a visitor.
|
|
196
|
+
const user = principal.kind === 'user' && this.user ? { name: this.user.name } : null;
|
|
197
|
+
const usage = { user: Object.values(this.theme.options).some(value => usesUserBinding(value)) };
|
|
198
|
+
this.theme = { ...this.theme, options: resolvedOptions(this.theme.options, bindingScopes(settings, { entry, user })) };
|
|
199
|
+
this.site = await siteView(cms, this.theme, { locale: page.locale, languages: await languageLinks(cms, page), template, entry, user, usage, url: this.c.req.url, page, forms: { query: this.c.req.query(), principal: this.c.get('principal'), url: this.c.req.path } });
|
|
200
|
+
if (usage.user && user) this.c.header('cache-control', 'private, no-store');
|
|
201
|
+
this.data = await themeData(cms, this.theme, 'layout', this.site, this.c.get('principal'), page.locale);
|
|
202
|
+
this.analytics = user ? NO_ANALYTICS : { cloudflareToken: settings['analytics.cloudflareToken'] || '', googleMeasurementId: settings['analytics.googleMeasurementId'] || '' };
|
|
203
|
+
// A Latest entries block in a widget area puts the collection on every page: the page adds these to its cache tags.
|
|
204
|
+
this.c.set('cms.cacheTags', [...listedCollections(Object.values(this.site.areas).flat())].map(name => cms.purge.tag.collection(name)));
|
|
205
|
+
} catch { this.site = { ...this.site, title: config('app.name') }; }
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
render() {
|
|
209
|
+
const theme = siteTheme(this.theme);
|
|
210
|
+
// In edit mode every area block carries its document, and a lock when the user may not change areas.
|
|
211
|
+
const editing = Boolean(this.editing) && !this.exited;
|
|
212
|
+
const patterns = editing ? new Map(this.editing!.patterns.map(pattern => [pattern.id, !pattern.editable])) : undefined;
|
|
213
|
+
const areas: Record<string, readonly RenderedBlock[]> = editing ? Object.fromEntries(Object.entries(this.site.areas).map(([name, blocks]) => [name, tagDocument(blocks, `area:${name}`, !this.editing!.editable, patterns)])) : this.site.areas;
|
|
214
|
+
const site = editing ? { ...this.site, areas } : this.site;
|
|
215
|
+
const helpers = themeHelpers(theme, { ...this.theme, data: { layout: this.data }, editing, languages: this.site.languages, menus: this.site.menus, site: this.site }, (path, exact) => this.isActive(path, exact));
|
|
216
|
+
const frame = theme.layout({ site, content: html`${this.children}`, helpers });
|
|
217
|
+
return this.taskbar ? html`${frame}${taskbar(this.taskbar, { logout: () => this.doLogout(), error: this.logoutError })}` : frame;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Cossack, Page } from '@cossackframework/core';
|
|
2
|
+
import { isCmsError } from '@cossackframework/cms';
|
|
3
|
+
import { llmsTxt } from '#app/cms/machine';
|
|
4
|
+
import { siteOrigin } from '#app/cms/seo';
|
|
5
|
+
import { trackCrawler } from '#app/cms/traffic';
|
|
6
|
+
import { cacheHeaders } from '#app/cms/cache';
|
|
7
|
+
|
|
8
|
+
/** `/llms.txt`: the site for AI assistants, as Settings → SEO allows. Off with the site hidden from search engines. */
|
|
9
|
+
@Page({ transport: 'http' })
|
|
10
|
+
export default class LlmsTxt extends Cossack {
|
|
11
|
+
async get() {
|
|
12
|
+
const cms = this.c.get('cms');
|
|
13
|
+
try {
|
|
14
|
+
const settings = await cms.settings.all();
|
|
15
|
+
if (!settings['seo.llmsTxt'] || settings['reading.discourageSearchEngines']) return new Response('Not found', { status: 404 });
|
|
16
|
+
trackCrawler(this.c, 'llms');
|
|
17
|
+
return new Response(await llmsTxt(cms, siteOrigin(this.c)), { headers: { 'content-type': 'text/markdown; charset=utf-8', ...await cacheHeaders(cms, cms.collections().filter(collection => typeof collection.path === 'string').map(collection => cms.purge.tag.collection(collection.name))) } });
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (!isCmsError(error, 'CMS_UNAVAILABLE')) throw error;
|
|
20
|
+
return new Response('Not available yet', { status: 503 });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Cossack, Page } from '@cossackframework/core';
|
|
2
|
+
import { cacheHeaders } from '#app/cms/cache';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The web app manifest: the site's name and its app icon from Settings → General, resized
|
|
6
|
+
* to the home screen sizes when it is a library image. Without an app icon, the
|
|
7
|
+
* application's own icons from `public/` serve.
|
|
8
|
+
*/
|
|
9
|
+
@Page({ transport: 'http' })
|
|
10
|
+
export default class Manifest extends Cossack {
|
|
11
|
+
async get() {
|
|
12
|
+
const cms = this.c.get('cms');
|
|
13
|
+
let name = 'Site';
|
|
14
|
+
let icon = '';
|
|
15
|
+
try {
|
|
16
|
+
const settings = await cms.settings.all();
|
|
17
|
+
name = settings['general.siteTitle'];
|
|
18
|
+
icon = settings['general.appIcon'];
|
|
19
|
+
} catch { /* before setup: the defaults */ }
|
|
20
|
+
const resizable = icon.startsWith('/media/') && (cms.files?.resizes ?? false);
|
|
21
|
+
const icons = !icon ? [
|
|
22
|
+
{ src: '/web-app-manifest-192x192.png', sizes: '192x192', type: 'image/png', purpose: 'maskable' },
|
|
23
|
+
{ src: '/web-app-manifest-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
|
|
24
|
+
] : resizable ? [192, 512].map(size => ({ src: `${icon}?w=${size}&h=${size}`, sizes: `${size}x${size}`, type: 'image/png', purpose: 'any maskable' }))
|
|
25
|
+
: [{ src: icon, sizes: 'any', purpose: 'any maskable' }];
|
|
26
|
+
const manifest = { name, short_name: name.slice(0, 30), start_url: '/', display: 'standalone', background_color: '#ffffff', theme_color: '#ffffff', icons };
|
|
27
|
+
return new Response(JSON.stringify(manifest), { headers: { 'content-type': 'application/manifest+json', ...await cacheHeaders(cms, []) } });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Cossack, Page } from '@cossackframework/core';
|
|
2
|
+
import { cacheTagHeader } from '@cossackframework/cms';
|
|
3
|
+
|
|
4
|
+
const HEADERS = {
|
|
5
|
+
'x-content-type-options': 'nosniff',
|
|
6
|
+
'content-security-policy': "default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'; sandbox",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Uploaded media. Files are public once uploaded; the name in the URL is decorative. The
|
|
11
|
+
* stored type was checked against the file's signature, and responses forbid sniffing,
|
|
12
|
+
* scripts and framing. `?w=` (and `h=`) serve a resized variant of an image in the best
|
|
13
|
+
* format the browser accepts, made once and kept; `v` names the version of its crop.
|
|
14
|
+
*
|
|
15
|
+
* Answers carry the site's cache tag, so a deleted or changed file leaves a purging cache with
|
|
16
|
+
* the site's next purge (every media change queues one). An original is kept an hour, not for
|
|
17
|
+
* good: a file deleted by mistake stops answering from browsers within the hour. A variant asked
|
|
18
|
+
* for at the file's current version (`v`, which every edit changes, as the site's srcsets write
|
|
19
|
+
* it) never answers differently at that URL, so browsers keep it a year.
|
|
20
|
+
*/
|
|
21
|
+
const VARIANT_KEPT = 'public, max-age=31536000, immutable';
|
|
22
|
+
const KEPT = 'public, max-age=3600';
|
|
23
|
+
@Page({ transport: 'http' })
|
|
24
|
+
export default class MediaFile extends Cossack {
|
|
25
|
+
async get() {
|
|
26
|
+
const cms = this.c.get('cms');
|
|
27
|
+
const files = cms.files;
|
|
28
|
+
const tag = cacheTagHeader([cms.purge.tag.site()]);
|
|
29
|
+
const id = this.c.req.param('id') ?? '';
|
|
30
|
+
const width = Number(this.c.req.query('w'));
|
|
31
|
+
if (files && Number.isSafeInteger(width) && width > 0) {
|
|
32
|
+
const height = Number(this.c.req.query('h'));
|
|
33
|
+
const variant = await files.variant(id, {
|
|
34
|
+
width, ...(Number.isSafeInteger(height) && height > 0 ? { height } : {}), accept: this.c.req.header('accept') ?? '', signal: this.c.req.raw.signal,
|
|
35
|
+
});
|
|
36
|
+
if (variant) {
|
|
37
|
+
const current = this.c.req.query('v') === String(variant.file.updatedAt);
|
|
38
|
+
return new Response(variant.body, {
|
|
39
|
+
headers: { ...HEADERS, 'content-type': variant.contentType, 'content-length': String(variant.size), 'cache-control': current ? VARIANT_KEPT : KEPT, 'cache-tag': tag, vary: 'Accept' },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
// Files that are not resized, such as SVG and GIF, answer as uploaded.
|
|
43
|
+
}
|
|
44
|
+
const opened = files ? await files.open(id, { signal: this.c.req.raw.signal }) : null;
|
|
45
|
+
if (!opened) return new Response('Not found', { status: 404, headers: { 'content-type': 'text/plain; charset=utf-8' } });
|
|
46
|
+
const { file, body } = opened;
|
|
47
|
+
const inline = /^(image|video|audio)\//.test(file.contentType) || file.contentType === 'application/pdf';
|
|
48
|
+
return new Response(body, {
|
|
49
|
+
headers: {
|
|
50
|
+
...HEADERS,
|
|
51
|
+
'content-type': file.contentType === 'text/plain' ? 'text/plain; charset=utf-8' : file.contentType,
|
|
52
|
+
'content-length': String(file.size),
|
|
53
|
+
'cache-control': KEPT,
|
|
54
|
+
'cache-tag': tag,
|
|
55
|
+
'content-disposition': `${inline ? 'inline' : 'attachment'}; filename*=UTF-8''${encodeURIComponent(file.name)}`,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Cossack, Page, State, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { html } from '@cossackframework/renderer';
|
|
3
|
+
import { isCmsError, type EntryView, type RecordShape, type RenderedBlock, type ThemeData } from '@cossackframework/cms';
|
|
4
|
+
import { entryInput } from '#app/cms/content';
|
|
5
|
+
import { entryViews, formPreviewBlock, siteView, themeData, themeState, type ThemeState } from '#app/cms/site';
|
|
6
|
+
import { entryTemplate, withContentFields, siteContent, siteTheme, themeContext, themeHelpers } from '#app/cms/site-view';
|
|
7
|
+
import { contentMenus, siteInfo, type SiteInfo } from '#app/cms/site';
|
|
8
|
+
import type { MenuItemView } from '@cossackframework/cms';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An entry as the site will show it, whatever its status. Its editors see their newest
|
|
12
|
+
* autosave; anyone with a preview link (`?token=`) sees the saved entry. Never indexed or cached.
|
|
13
|
+
*/
|
|
14
|
+
@Page({ transport: 'http' })
|
|
15
|
+
export default class PreviewPage extends Cossack {
|
|
16
|
+
@State() entry: EntryView | null = null;
|
|
17
|
+
/** The theme's menus, for Navigation blocks in the entry's content. */
|
|
18
|
+
@State() menus: Record<string, readonly MenuItemView[]> = {};
|
|
19
|
+
@State() site: SiteInfo | null = null;
|
|
20
|
+
/** A form's preview: the Form block alone, on the site's page layout. */
|
|
21
|
+
@State() form: RenderedBlock | null = null;
|
|
22
|
+
@State() title = '';
|
|
23
|
+
@State() status = '';
|
|
24
|
+
@State() autosaved = false;
|
|
25
|
+
@State() editUrl = '';
|
|
26
|
+
@State() theme: ThemeState = { name: null, options: {} };
|
|
27
|
+
@State() data: ThemeData = {};
|
|
28
|
+
|
|
29
|
+
head(): HeadValue {
|
|
30
|
+
return {
|
|
31
|
+
title: this.entry || this.form ? `${__('Preview')}: ${this.entry?.title ?? this.title}` : __('Preview'),
|
|
32
|
+
meta: [{ tag: 'meta', attributes: { name: 'robots', content: 'noindex, nofollow' } }],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async init() {
|
|
37
|
+
const cms = this.c.get('cms');
|
|
38
|
+
const principal = this.c.get('principal');
|
|
39
|
+
const name = this.c.req.param('collection') ?? '';
|
|
40
|
+
const id = this.c.req.param('id') ?? '';
|
|
41
|
+
const token = this.c.req.query('token');
|
|
42
|
+
this.c.header('cache-control', 'private, no-store');
|
|
43
|
+
this.c.header('x-robots-tag', 'noindex');
|
|
44
|
+
try {
|
|
45
|
+
this.theme = await themeState(cms);
|
|
46
|
+
const collection = cms.collection(name);
|
|
47
|
+
const resourceId = `cms/${collection.name}`;
|
|
48
|
+
let record: RecordShape | null = null;
|
|
49
|
+
let stored: RecordShape | null = null;
|
|
50
|
+
if (token) {
|
|
51
|
+
const found = await cms.previewByToken(token);
|
|
52
|
+
if (found?.resource.id === resourceId && found.record.id === id) record = stored = found.record;
|
|
53
|
+
} else {
|
|
54
|
+
const repository = cms.resource(resourceId);
|
|
55
|
+
const saved = await repository.get(id, { principal });
|
|
56
|
+
if (saved && repository.canUpdate(saved, principal)) {
|
|
57
|
+
record = stored = saved;
|
|
58
|
+
this.editUrl = `/dashboard/content/${collection.name}/${id}`;
|
|
59
|
+
// Unsaved changes from the editor show in place of the saved ones.
|
|
60
|
+
const autosave = await cms.latestAutosave(resourceId, id, principal);
|
|
61
|
+
if (autosave && autosave.at > saved.updatedAt && autosave.data && typeof autosave.data === 'object') {
|
|
62
|
+
const input = await entryInput(cms, collection.name, autosave.data as Record<string, unknown>).catch(() => null);
|
|
63
|
+
if (input) { record = { ...saved, ...input }; this.autosaved = true; }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!record || !stored) {
|
|
68
|
+
this.c.status(404);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.status = String(record.status ?? '');
|
|
72
|
+
if (collection.name === 'forms') {
|
|
73
|
+
// A form has no page of its own: its preview is the Form block on an empty page.
|
|
74
|
+
this.title = typeof record.title === 'string' ? record.title : '';
|
|
75
|
+
const saved = await cms.forms.load(stored);
|
|
76
|
+
this.form = await formPreviewBlock(cms, saved, record, { query: {}, principal, url: this.c.req.path });
|
|
77
|
+
const site = await siteView(cms, this.theme);
|
|
78
|
+
this.data = await themeData(cms, this.theme, 'layout', site, principal);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// The preview is for the entry's editor or the holder of its preview link: nothing is locked for them.
|
|
82
|
+
this.entry = (await entryViews(cms, collection, [record], { full: true, editable: new Set([record.id]), forms: { query: {}, principal, url: this.c.req.path } }))[0]!;
|
|
83
|
+
this.menus = await contentMenus(cms, this.theme, this.entry.content, { locale: this.entry.locale });
|
|
84
|
+
this.site = await siteInfo(cms, this.entry.locale, { url: this.c.req.url, page: { kind: 'entry', collection, record, locale: this.entry.locale } });
|
|
85
|
+
this.data = await themeData(cms, this.theme, { kind: 'entry', collection: collection.name, template: this.entry.template }, this.entry, principal, this.entry.locale);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (!isCmsError(error)) throw error;
|
|
88
|
+
this.c.status(error.status === 503 ? 503 : 404);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The strip above the preview: its status, and the way back. */
|
|
93
|
+
private banner() {
|
|
94
|
+
return html`<div role="status" class="mb-6 flex flex-wrap items-center justify-between gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-4 py-2 text-sm text-foreground">
|
|
95
|
+
<span><strong>${__('Preview')}</strong> · ${this.status === 'published' ? __('Published') : __('Not published')}${this.autosaved ? html` · ${__('with unsaved changes')}` : null}</span>
|
|
96
|
+
${this.editUrl ? html`<a href=${this.editUrl} class="text-primary hover:underline">${__('Back to the editor')}</a>` : null}
|
|
97
|
+
</div>`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
render() {
|
|
101
|
+
if (this.form) {
|
|
102
|
+
const theme = siteTheme(this.theme);
|
|
103
|
+
const helpers = themeHelpers(theme, { ...this.theme, data: { page: this.data } }, (path, exact) => this.isActive(path, exact));
|
|
104
|
+
return html`${this.banner()}${siteContent(html`<article class="mx-auto max-w-2xl py-8">${helpers.block(this.form)}</article>`, this.theme)}`;
|
|
105
|
+
}
|
|
106
|
+
if (!this.entry) return html`<section class="space-y-3 py-16 text-center">
|
|
107
|
+
<h1 class="text-3xl font-bold text-foreground">${__('Preview not available')}</h1>
|
|
108
|
+
<p class="text-muted-foreground">${__('The link expired, or you cannot edit this entry.')}</p>
|
|
109
|
+
</section>`;
|
|
110
|
+
const theme = siteTheme(this.theme);
|
|
111
|
+
const context = themeContext(theme, { ...this.theme, data: { page: this.data }, menus: this.menus, site: this.site ?? undefined }, (path, exact) => this.isActive(path, exact));
|
|
112
|
+
return html`${this.banner()}
|
|
113
|
+
${siteContent(entryTemplate(theme, this.entry.collection, this.entry.template)({ ...context, entry: withContentFields(this.entry) }), this.theme)}`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Cossack, Page } from '@cossackframework/core';
|
|
2
|
+
import { robotsTxtLines } from '@cossackframework/cms';
|
|
3
|
+
import { siteOrigin } from '#app/cms/seo';
|
|
4
|
+
import { trackCrawler } from '#app/cms/traffic';
|
|
5
|
+
import { cacheHeaders } from '#app/cms/cache';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* robots.txt: keeps crawlers out of the dashboard, the API, sign-in, previews and the IndexNow
|
|
9
|
+
* key, blocks the crawler groups Settings → Crawlers turned off, and names the sitemap.
|
|
10
|
+
* Settings → Reading can hide the whole site; Settings → SEO adds rules.
|
|
11
|
+
*/
|
|
12
|
+
@Page({ transport: 'http' })
|
|
13
|
+
export default class Robots extends Cossack {
|
|
14
|
+
async get() {
|
|
15
|
+
const cms = this.c.get('cms');
|
|
16
|
+
let hidden = false;
|
|
17
|
+
let extra = '';
|
|
18
|
+
let crawlers = { allowSearch: true, allowAiSearch: true, allowAiTraining: true, contentSignals: false };
|
|
19
|
+
try {
|
|
20
|
+
const settings = await cms.settings.all();
|
|
21
|
+
hidden = settings['reading.discourageSearchEngines'];
|
|
22
|
+
extra = settings['seo.robotsTxt'];
|
|
23
|
+
crawlers = { allowSearch: settings['crawlers.allowSearch'], allowAiSearch: settings['crawlers.allowAiSearch'], allowAiTraining: settings['crawlers.allowAiTraining'], contentSignals: settings['crawlers.contentSignals'] };
|
|
24
|
+
} catch { /* before setup: the defaults */ }
|
|
25
|
+
trackCrawler(this.c, 'robots');
|
|
26
|
+
const lines = robotsTxtLines({ hidden, crawlers, extra, sitemapUrl: `${siteOrigin(this.c)}/sitemap.xml` });
|
|
27
|
+
return new Response(`${lines.join('\n')}\n`, { headers: { 'content-type': 'text/plain; charset=utf-8', ...await cacheHeaders(cms, []) } });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Cossack, Page, State, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import type { ArchiveView, ThemeData } from '@cossackframework/cms';
|
|
3
|
+
import { pageNumber, searchBase, searchEntries, siteInfo, themeData, themeState, type SiteInfo, type ThemeState } from '#app/cms/site';
|
|
4
|
+
import { archiveTemplate, siteContent, siteTheme, themeContext } from '#app/cms/site-view';
|
|
5
|
+
|
|
6
|
+
/** Search published entries of every collection on the site. */
|
|
7
|
+
@Page({ transport: 'http' })
|
|
8
|
+
export default class SearchPage extends Cossack {
|
|
9
|
+
@State() view: ArchiveView = { kind: 'search', collection: null, taxonomy: null, title: '', description: '', entries: [], paging: { page: 1, pages: 1, base: '/search' }, query: '' };
|
|
10
|
+
@State() theme: ThemeState = { name: null, options: {} };
|
|
11
|
+
/** What the theme's loader for search returned. */
|
|
12
|
+
@State() data: ThemeData = {};
|
|
13
|
+
/** The site's title, logo and URLs, for the template's `site`. */
|
|
14
|
+
@State() site: SiteInfo | null = null;
|
|
15
|
+
|
|
16
|
+
head(): HeadValue {
|
|
17
|
+
return { title: this.view.query ? `${__('Search results for')} “${this.view.query}”` : __('Search'), meta: [{ tag: 'meta', attributes: { name: 'robots', content: 'noindex' } }] };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async init() {
|
|
21
|
+
const cms = this.c.get('cms');
|
|
22
|
+
const query = (this.c.req.query('q') ?? '').trim().slice(0, 200);
|
|
23
|
+
this.theme = await themeState(cms).catch(() => this.theme);
|
|
24
|
+
const locale = (await cms.languages()).default;
|
|
25
|
+
const base = searchBase('/search', query);
|
|
26
|
+
const found = query ? await searchEntries(cms, query, { locale, page: pageNumber(this.c.req.query('page')), base }) : { entries: [], paging: { page: 1, pages: 1, base }, loose: false };
|
|
27
|
+
this.view = { ...this.view, query, title: query ? `${__('Results for')} “${query}”` : __('Search'), ...found };
|
|
28
|
+
[this.data, this.site] = await Promise.all([themeData(cms, this.theme, this.view, this.view, this.c.get('principal'), locale), siteInfo(cms, locale, { url: this.c.req.url }).catch(() => null)]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
render() {
|
|
32
|
+
const theme = siteTheme(this.theme);
|
|
33
|
+
const context = themeContext(theme, { ...this.theme, data: { page: this.data }, site: this.site ?? undefined }, (path, exact) => this.isActive(path, exact));
|
|
34
|
+
return siteContent(archiveTemplate(theme, this.view)({ ...context, view: this.view }), this.theme);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Cossack, Page } from '@cossackframework/core';
|
|
2
|
+
import { isCmsError } from '@cossackframework/cms';
|
|
3
|
+
import { siteOrigin } from '#app/cms/seo';
|
|
4
|
+
import registry from 'virtual:cossack-pages';
|
|
5
|
+
import { sitemapFiles, staticPages, xmlEscape } from '#app/cms/sitemaps';
|
|
6
|
+
import { trackCrawler } from '#app/cms/traffic';
|
|
7
|
+
import { cacheHeaders } from '#app/cms/cache';
|
|
8
|
+
|
|
9
|
+
/** The sitemap index: one sitemap per 1,000 entries of each collection on the site, and one per taxonomy. */
|
|
10
|
+
@Page({ transport: 'http' })
|
|
11
|
+
export default class SitemapIndex extends Cossack {
|
|
12
|
+
async get() {
|
|
13
|
+
const cms = this.c.get('cms');
|
|
14
|
+
try {
|
|
15
|
+
if (await cms.settings.get('reading.discourageSearchEngines')) return new Response('Not found', { status: 404 });
|
|
16
|
+
trackCrawler(this.c, 'sitemap');
|
|
17
|
+
const origin = siteOrigin(this.c);
|
|
18
|
+
const files = await sitemapFiles(cms, { pages: staticPages(Object.keys(registry.pages)) });
|
|
19
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${files.map(file => `<sitemap><loc>${xmlEscape(`${origin}/sitemaps/${file}`)}</loc></sitemap>`).join('')}</sitemapindex>\n`;
|
|
20
|
+
return new Response(xml, { headers: { 'content-type': 'application/xml; charset=utf-8', ...await cacheHeaders(cms, []) } });
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (!isCmsError(error, 'CMS_UNAVAILABLE')) throw error;
|
|
23
|
+
return new Response('Not available yet', { status: 503 });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Cossack, Page } from '@cossackframework/core';
|
|
2
|
+
import { isCmsError } from '@cossackframework/cms';
|
|
3
|
+
import { siteOrigin } from '#app/cms/seo';
|
|
4
|
+
import registry from 'virtual:cossack-pages';
|
|
5
|
+
import { sitemapUrls, staticPages, xmlEscape } from '#app/cms/sitemaps';
|
|
6
|
+
import { trackCrawler } from '#app/cms/traffic';
|
|
7
|
+
import { cacheHeaders } from '#app/cms/cache';
|
|
8
|
+
|
|
9
|
+
/** One sitemap: `/sitemaps/posts-1.xml` for entries, `/sitemaps/terms-categories.xml` for a taxonomy's archives. */
|
|
10
|
+
@Page({ transport: 'http' })
|
|
11
|
+
export default class Sitemap extends Cossack {
|
|
12
|
+
async get() {
|
|
13
|
+
const cms = this.c.get('cms');
|
|
14
|
+
try {
|
|
15
|
+
if (await cms.settings.get('reading.discourageSearchEngines')) return new Response('Not found', { status: 404 });
|
|
16
|
+
const urls = await sitemapUrls(cms, this.c.req.param('file') ?? '', { pages: staticPages(Object.keys(registry.pages)) });
|
|
17
|
+
if (!urls) return new Response('Not found', { status: 404 });
|
|
18
|
+
trackCrawler(this.c, 'sitemap');
|
|
19
|
+
const origin = siteOrigin(this.c);
|
|
20
|
+
const siteName = xmlEscape(await cms.settings.get('general.siteTitle'));
|
|
21
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">${urls.map(entry =>
|
|
22
|
+
`<url><loc>${xmlEscape(`${origin}${entry.url}`)}</loc>${entry.updatedAt ? `<lastmod>${new Date(entry.updatedAt).toISOString()}</lastmod>` : ''}`
|
|
23
|
+
+ (entry.alternates ?? []).map(alternate => `<xhtml:link rel="alternate" hreflang="${xmlEscape(alternate.hreflang)}" href="${xmlEscape(`${origin}${alternate.href}`)}"/>`).join('')
|
|
24
|
+
+ (entry.image ? `<image:image><image:loc>${xmlEscape(`${origin}${entry.image}`)}</image:loc></image:image>` : '')
|
|
25
|
+
+ (entry.news ? `<news:news><news:publication><news:name>${siteName}</news:name><news:language>${xmlEscape(entry.news.language)}</news:language></news:publication><news:publication_date>${new Date(entry.news.publishedAt).toISOString()}</news:publication_date><news:title>${xmlEscape(entry.news.title)}</news:title></news:news>` : '')
|
|
26
|
+
+ '</url>').join('')}</urlset>\n`;
|
|
27
|
+
return new Response(xml, { headers: { 'content-type': 'application/xml; charset=utf-8', ...await cacheHeaders(cms, []) } });
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (!isCmsError(error)) throw error;
|
|
30
|
+
return new Response('Not found', { status: error.code === 'CMS_UNAVAILABLE' ? 503 : 404 });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|