@cossackframework/cms 0.0.0-stage → 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.
Files changed (427) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +147 -2
  3. package/agent-docs.json +259 -0
  4. package/app/README.md +78 -0
  5. package/app/cossack-recipe.json +43 -0
  6. package/app/src/auth-bot-check.ts +32 -0
  7. package/app/src/auth-bot-token.ts +11 -0
  8. package/app/src/auth-input.ts +35 -0
  9. package/app/src/auth-options.ts +18 -0
  10. package/app/src/auth-providers.ts +16 -0
  11. package/app/src/auth.ts +1082 -0
  12. package/app/src/brand.ts +68 -0
  13. package/app/src/cms/ai.ts +54 -0
  14. package/app/src/cms/analytics.ts +33 -0
  15. package/app/src/cms/block-errors.ts +55 -0
  16. package/app/src/cms/block-inserter.ts +111 -0
  17. package/app/src/cms/block-panel.ts +68 -0
  18. package/app/src/cms/block-rows.ts +44 -0
  19. package/app/src/cms/block-tree.ts +585 -0
  20. package/app/src/cms/blocks.css +708 -0
  21. package/app/src/cms/builder.ts +126 -0
  22. package/app/src/cms/cache.ts +44 -0
  23. package/app/src/cms/carousel.client.ts +52 -0
  24. package/app/src/cms/collab/presence.ts +69 -0
  25. package/app/src/cms/collab/rich-text-collab.client.ts +197 -0
  26. package/app/src/cms/collab/rich-text-notes.client.ts +138 -0
  27. package/app/src/cms/collab/room.ts +881 -0
  28. package/app/src/cms/compare.client.ts +47 -0
  29. package/app/src/cms/condition-control.ts +109 -0
  30. package/app/src/cms/content-api.ts +143 -0
  31. package/app/src/cms/content.ts +524 -0
  32. package/app/src/cms/countdown.client.ts +37 -0
  33. package/app/src/cms/editor-layout-editor.ts +260 -0
  34. package/app/src/cms/editor-layout-view.ts +37 -0
  35. package/app/src/cms/editor.ts +381 -0
  36. package/app/src/cms/entry.ts +26 -0
  37. package/app/src/cms/feeds.ts +145 -0
  38. package/app/src/cms/field-controls.ts +222 -0
  39. package/app/src/cms/field-group-editor.ts +105 -0
  40. package/app/src/cms/field-group-view.ts +211 -0
  41. package/app/src/cms/form-view.ts +203 -0
  42. package/app/src/cms/form.client.ts +203 -0
  43. package/app/src/cms/guards.ts +27 -0
  44. package/app/src/cms/handoff.ts +202 -0
  45. package/app/src/cms/headings.ts +51 -0
  46. package/app/src/cms/icons.ts +80 -0
  47. package/app/src/cms/import.client.ts +16 -0
  48. package/app/src/cms/index.ts +191 -0
  49. package/app/src/cms/lightbox.client.ts +109 -0
  50. package/app/src/cms/machine.ts +118 -0
  51. package/app/src/cms/maintenance.ts +97 -0
  52. package/app/src/cms/manage.ts +1236 -0
  53. package/app/src/cms/mcp-tools.ts +388 -0
  54. package/app/src/cms/mcp.ts +242 -0
  55. package/app/src/cms/media-chooser.ts +123 -0
  56. package/app/src/cms/media-usage.ts +57 -0
  57. package/app/src/cms/middleware.ts +199 -0
  58. package/app/src/cms/middlewares.ts +13 -0
  59. package/app/src/cms/network-ui.ts +36 -0
  60. package/app/src/cms/network-view.ts +38 -0
  61. package/app/src/cms/notes-announce.ts +65 -0
  62. package/app/src/cms/notes-rail.ts +207 -0
  63. package/app/src/cms/notification-rules.ts +66 -0
  64. package/app/src/cms/recovery.ts +82 -0
  65. package/app/src/cms/replace.ts +63 -0
  66. package/app/src/cms/reserved-paths.ts +19 -0
  67. package/app/src/cms/rich-text-field.ts +325 -0
  68. package/app/src/cms/rich-text-schema.ts +91 -0
  69. package/app/src/cms/rich-text.client.ts +255 -0
  70. package/app/src/cms/search.client.ts +116 -0
  71. package/app/src/cms/seo-head.ts +78 -0
  72. package/app/src/cms/seo.ts +241 -0
  73. package/app/src/cms/settings-draft.ts +218 -0
  74. package/app/src/cms/settings-file.ts +127 -0
  75. package/app/src/cms/settings-form.ts +180 -0
  76. package/app/src/cms/settings-languages.ts +125 -0
  77. package/app/src/cms/settings-nav.ts +102 -0
  78. package/app/src/cms/settings-network.ts +151 -0
  79. package/app/src/cms/settings-permalinks.ts +114 -0
  80. package/app/src/cms/settings-scroll.ts +10 -0
  81. package/app/src/cms/settings-search.ts +77 -0
  82. package/app/src/cms/settings-section.ts +38 -0
  83. package/app/src/cms/share.client.ts +27 -0
  84. package/app/src/cms/site-editing.ts +219 -0
  85. package/app/src/cms/site-editor.client.ts +1008 -0
  86. package/app/src/cms/site-editor.ts +99 -0
  87. package/app/src/cms/site-export.ts +60 -0
  88. package/app/src/cms/site-forms.ts +143 -0
  89. package/app/src/cms/site-import.ts +28 -0
  90. package/app/src/cms/site-session.ts +36 -0
  91. package/app/src/cms/site-taskbar.ts +77 -0
  92. package/app/src/cms/site-view.ts +1014 -0
  93. package/app/src/cms/site.ts +1322 -0
  94. package/app/src/cms/sitemaps.ts +131 -0
  95. package/app/src/cms/stat.client.ts +56 -0
  96. package/app/src/cms/style-controls.ts +252 -0
  97. package/app/src/cms/tabs.client.ts +36 -0
  98. package/app/src/cms/taskbar.ts +134 -0
  99. package/app/src/cms/term-icons.ts +10 -0
  100. package/app/src/cms/traffic.ts +26 -0
  101. package/app/src/cms/ui.ts +170 -0
  102. package/app/src/cms/updates.ts +124 -0
  103. package/app/src/cms/uploads.ts +26 -0
  104. package/app/src/cms/worker.ts +13 -0
  105. package/app/src/config/auth.ts +30 -0
  106. package/app/src/config/cms.ts +18 -0
  107. package/app/src/dashboard/access.ts +344 -0
  108. package/app/src/dashboard/agent-icons.ts +44 -0
  109. package/app/src/dashboard/app-passwords.ts +74 -0
  110. package/app/src/dashboard/avatar-field.ts +58 -0
  111. package/app/src/dashboard/bulk.ts +53 -0
  112. package/app/src/dashboard/head.ts +29 -0
  113. package/app/src/dashboard/icons.ts +15 -0
  114. package/app/src/dashboard/list-table.ts +120 -0
  115. package/app/src/dashboard/modules/roles.ts +15 -0
  116. package/app/src/dashboard/modules/sessions.ts +15 -0
  117. package/app/src/dashboard/modules/settings.ts +15 -0
  118. package/app/src/dashboard/modules/users.ts +18 -0
  119. package/app/src/dashboard/page.ts +67 -0
  120. package/app/src/dashboard/registry.ts +13 -0
  121. package/app/src/dashboard/session-list.ts +98 -0
  122. package/app/src/dashboard/tabs.ts +26 -0
  123. package/app/src/dashboard/time-ago.ts +16 -0
  124. package/app/src/dashboard/types.ts +40 -0
  125. package/app/src/dashboard/user-sections.ts +172 -0
  126. package/app/src/lib/permissions.ts +84 -0
  127. package/app/src/middlewares/auth.ts +117 -0
  128. package/app/src/pages/(site)/[...path]/index.ts +609 -0
  129. package/app/src/pages/(site)/feed/[...rest]/index.ts +13 -0
  130. package/app/src/pages/(site)/feed/index.ts +12 -0
  131. package/app/src/pages/(site)/index.ts +11 -0
  132. package/app/src/pages/(site)/indexnow/[file]/index.ts +18 -0
  133. package/app/src/pages/(site)/layout.ts +219 -0
  134. package/app/src/pages/(site)/llms.txt/index.ts +23 -0
  135. package/app/src/pages/(site)/manifest.webmanifest/index.ts +29 -0
  136. package/app/src/pages/(site)/media/[id]/[name]/index.ts +59 -0
  137. package/app/src/pages/(site)/preview/[collection]/[id]/index.ts +115 -0
  138. package/app/src/pages/(site)/robots.txt/index.ts +29 -0
  139. package/app/src/pages/(site)/search/index.ts +36 -0
  140. package/app/src/pages/(site)/sitemap.xml/index.ts +26 -0
  141. package/app/src/pages/(site)/sitemaps/[file]/index.ts +33 -0
  142. package/app/src/pages/api/auth/session.ts +48 -0
  143. package/app/src/pages/api/cms/appearance/areas/[name].ts +12 -0
  144. package/app/src/pages/api/cms/appearance/areas/index.ts +6 -0
  145. package/app/src/pages/api/cms/appearance/locations/[location].ts +6 -0
  146. package/app/src/pages/api/cms/appearance/locations/index.ts +6 -0
  147. package/app/src/pages/api/cms/appearance/menus/[id].ts +12 -0
  148. package/app/src/pages/api/cms/appearance/menus/index.ts +13 -0
  149. package/app/src/pages/api/cms/appearance/themes/[name]/activate.ts +6 -0
  150. package/app/src/pages/api/cms/appearance/themes/index.ts +6 -0
  151. package/app/src/pages/api/cms/cache/purge.ts +6 -0
  152. package/app/src/pages/api/cms/collections/index.ts +6 -0
  153. package/app/src/pages/api/cms/commands/[plugin]/[command].ts +26 -0
  154. package/app/src/pages/api/cms/comments/[id].ts +9 -0
  155. package/app/src/pages/api/cms/comments/index.ts +126 -0
  156. package/app/src/pages/api/cms/comments/queue.ts +6 -0
  157. package/app/src/pages/api/cms/content/[collection]/[entry]/autosave.ts +27 -0
  158. package/app/src/pages/api/cms/content/[collection]/[entry]/blocks/[block].ts +16 -0
  159. package/app/src/pages/api/cms/content/[collection]/[entry]/notes.ts +18 -0
  160. package/app/src/pages/api/cms/content/[collection]/[entry]/publish.ts +11 -0
  161. package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/index.ts +6 -0
  162. package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/restore.ts +6 -0
  163. package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/index.ts +6 -0
  164. package/app/src/pages/api/cms/content/[collection]/[entry]/unpublish.ts +6 -0
  165. package/app/src/pages/api/cms/content/[collection]/[entry].ts +42 -0
  166. package/app/src/pages/api/cms/content/[collection]/index.ts +24 -0
  167. package/app/src/pages/api/cms/export/[collection].ts +37 -0
  168. package/app/src/pages/api/cms/forms/[slug]/index.ts +173 -0
  169. package/app/src/pages/api/cms/forms/[slug]/submissions/[submission]/files/[file].ts +25 -0
  170. package/app/src/pages/api/cms/forms/[slug]/submissions/export.ts +34 -0
  171. package/app/src/pages/api/cms/forms/[slug]/submissions/index.ts +24 -0
  172. package/app/src/pages/api/cms/import/[collection].ts +23 -0
  173. package/app/src/pages/api/cms/mcp.ts +29 -0
  174. package/app/src/pages/api/cms/me/index.ts +6 -0
  175. package/app/src/pages/api/cms/me/recent-blocks.ts +37 -0
  176. package/app/src/pages/api/cms/me/tokens/[id].ts +6 -0
  177. package/app/src/pages/api/cms/me/tokens/index.ts +13 -0
  178. package/app/src/pages/api/cms/media/[id].ts +6 -0
  179. package/app/src/pages/api/cms/media.ts +26 -0
  180. package/app/src/pages/api/cms/menus/[location].ts +14 -0
  181. package/app/src/pages/api/cms/network/sites/[id]/export.ts +15 -0
  182. package/app/src/pages/api/cms/network/sites/[id]/index.ts +9 -0
  183. package/app/src/pages/api/cms/network/sites/index.ts +14 -0
  184. package/app/src/pages/api/cms/notes/[id].ts +13 -0
  185. package/app/src/pages/api/cms/notes/index.ts +6 -0
  186. package/app/src/pages/api/cms/payments/webhook.ts +28 -0
  187. package/app/src/pages/api/cms/plugins/[name]/grant.ts +6 -0
  188. package/app/src/pages/api/cms/plugins/[name]/revoke.ts +6 -0
  189. package/app/src/pages/api/cms/plugins/index.ts +6 -0
  190. package/app/src/pages/api/cms/recovery.ts +29 -0
  191. package/app/src/pages/api/cms/redirects/index.ts +9 -0
  192. package/app/src/pages/api/cms/roles/index.ts +6 -0
  193. package/app/src/pages/api/cms/schema/[collection].ts +13 -0
  194. package/app/src/pages/api/cms/search.ts +16 -0
  195. package/app/src/pages/api/cms/settings/[group].ts +9 -0
  196. package/app/src/pages/api/cms/settings/index.ts +9 -0
  197. package/app/src/pages/api/cms/site-export.ts +34 -0
  198. package/app/src/pages/api/cms/taxonomies/index.ts +6 -0
  199. package/app/src/pages/api/cms/terms/[taxonomy]/[id].ts +12 -0
  200. package/app/src/pages/api/cms/terms/[taxonomy]/index.ts +9 -0
  201. package/app/src/pages/api/cms/uploads/[id]/complete.ts +15 -0
  202. package/app/src/pages/api/cms/uploads/[id]/index.ts +15 -0
  203. package/app/src/pages/api/cms/uploads/index.ts +26 -0
  204. package/app/src/pages/api/cms/users/[id]/index.ts +12 -0
  205. package/app/src/pages/api/cms/users/[id]/meta.ts +40 -0
  206. package/app/src/pages/api/cms/users/index.ts +12 -0
  207. package/app/src/pages/api/cms/webhooks/[id].ts +6 -0
  208. package/app/src/pages/api/cms/webhooks/index.ts +9 -0
  209. package/app/src/pages/auth/[provider]/callback.ts +11 -0
  210. package/app/src/pages/auth/[provider]/redirect.ts +9 -0
  211. package/app/src/pages/auth/forgot-password/index.ts +75 -0
  212. package/app/src/pages/auth/layout.ts +32 -0
  213. package/app/src/pages/auth/login/index.ts +198 -0
  214. package/app/src/pages/auth/magic/index.ts +68 -0
  215. package/app/src/pages/auth/register/index.ts +117 -0
  216. package/app/src/pages/auth/reset-password/index.ts +65 -0
  217. package/app/src/pages/auth/setup/index.ts +194 -0
  218. package/app/src/pages/auth/two-factor/index.ts +67 -0
  219. package/app/src/pages/auth/verify/index.ts +62 -0
  220. package/app/src/pages/dashboard/(cms)/appearance/customize/index.ts +263 -0
  221. package/app/src/pages/dashboard/(cms)/appearance/dashboard-menu/index.ts +241 -0
  222. package/app/src/pages/dashboard/(cms)/appearance/index.ts +89 -0
  223. package/app/src/pages/dashboard/(cms)/appearance/menus/[id]/index.ts +697 -0
  224. package/app/src/pages/dashboard/(cms)/appearance/menus/index.ts +145 -0
  225. package/app/src/pages/dashboard/(cms)/appearance/widgets/index.ts +279 -0
  226. package/app/src/pages/dashboard/(cms)/blocks/index.ts +84 -0
  227. package/app/src/pages/dashboard/(cms)/calendar/index.ts +92 -0
  228. package/app/src/pages/dashboard/(cms)/collections/[name]/index.ts +525 -0
  229. package/app/src/pages/dashboard/(cms)/collections/index.ts +72 -0
  230. package/app/src/pages/dashboard/(cms)/collections/new/index.ts +66 -0
  231. package/app/src/pages/dashboard/(cms)/comments/index.ts +237 -0
  232. package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/index.ts +2382 -0
  233. package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/revisions/index.ts +126 -0
  234. package/app/src/pages/dashboard/(cms)/content/[collection]/index.ts +693 -0
  235. package/app/src/pages/dashboard/(cms)/field-groups/[id]/index.ts +193 -0
  236. package/app/src/pages/dashboard/(cms)/field-groups/index.ts +65 -0
  237. package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/[submission]/index.ts +279 -0
  238. package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/index.ts +170 -0
  239. package/app/src/pages/dashboard/(cms)/forms/index.ts +171 -0
  240. package/app/src/pages/dashboard/(cms)/media/[id]/index.ts +317 -0
  241. package/app/src/pages/dashboard/(cms)/media/index.ts +156 -0
  242. package/app/src/pages/dashboard/(cms)/media/new/index.ts +9 -0
  243. package/app/src/pages/dashboard/(cms)/media/summary/index.ts +74 -0
  244. package/app/src/pages/dashboard/(cms)/my-sites/index.ts +63 -0
  245. package/app/src/pages/dashboard/(cms)/network/index.ts +53 -0
  246. package/app/src/pages/dashboard/(cms)/network/plugins/index.ts +110 -0
  247. package/app/src/pages/dashboard/(cms)/network/sites/[id]/index.ts +243 -0
  248. package/app/src/pages/dashboard/(cms)/network/sites/index.ts +186 -0
  249. package/app/src/pages/dashboard/(cms)/network/sites/new/index.ts +77 -0
  250. package/app/src/pages/dashboard/(cms)/network/themes/index.ts +82 -0
  251. package/app/src/pages/dashboard/(cms)/network/updates/index.ts +48 -0
  252. package/app/src/pages/dashboard/(cms)/network/users/[id]/index.ts +176 -0
  253. package/app/src/pages/dashboard/(cms)/network/users/index.ts +174 -0
  254. package/app/src/pages/dashboard/(cms)/network/users/new/index.ts +66 -0
  255. package/app/src/pages/dashboard/(cms)/plugins/index.ts +172 -0
  256. package/app/src/pages/dashboard/(cms)/profile/public/index.ts +105 -0
  257. package/app/src/pages/dashboard/(cms)/registrations/index.ts +70 -0
  258. package/app/src/pages/dashboard/(cms)/settings/index.ts +359 -0
  259. package/app/src/pages/dashboard/(cms)/settings/json/index.ts +202 -0
  260. package/app/src/pages/dashboard/(cms)/settings/layout.ts +67 -0
  261. package/app/src/pages/dashboard/(cms)/taxonomies/[name]/index.ts +85 -0
  262. package/app/src/pages/dashboard/(cms)/taxonomies/index.ts +98 -0
  263. package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/[id]/index.ts +244 -0
  264. package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/index.ts +148 -0
  265. package/app/src/pages/dashboard/(cms)/tools/activity/index.ts +94 -0
  266. package/app/src/pages/dashboard/(cms)/tools/automations/index.ts +131 -0
  267. package/app/src/pages/dashboard/(cms)/tools/cache/index.ts +92 -0
  268. package/app/src/pages/dashboard/(cms)/tools/export/index.ts +99 -0
  269. package/app/src/pages/dashboard/(cms)/tools/health/index.ts +189 -0
  270. package/app/src/pages/dashboard/(cms)/tools/jobs/index.ts +93 -0
  271. package/app/src/pages/dashboard/(cms)/tools/links/index.ts +115 -0
  272. package/app/src/pages/dashboard/(cms)/tools/redirects/index.ts +161 -0
  273. package/app/src/pages/dashboard/(cms)/tools/replace/index.ts +124 -0
  274. package/app/src/pages/dashboard/(cms)/tools/schema/index.ts +54 -0
  275. package/app/src/pages/dashboard/(cms)/tools/seo/index.ts +156 -0
  276. package/app/src/pages/dashboard/(cms)/tools/updates/index.ts +114 -0
  277. package/app/src/pages/dashboard/(cms)/tools/webhooks/index.ts +182 -0
  278. package/app/src/pages/dashboard/index.ts +214 -0
  279. package/app/src/pages/dashboard/layout.ts +320 -0
  280. package/app/src/pages/dashboard/profile/index.ts +211 -0
  281. package/app/src/pages/dashboard/profile/security/index.ts +255 -0
  282. package/app/src/pages/dashboard/roles/[id]/index.ts +116 -0
  283. package/app/src/pages/dashboard/roles/index.ts +134 -0
  284. package/app/src/pages/dashboard/roles/new/index.ts +95 -0
  285. package/app/src/pages/dashboard/sessions/index.ts +105 -0
  286. package/app/src/pages/dashboard/users/[id]/index.ts +472 -0
  287. package/app/src/pages/dashboard/users/index.ts +299 -0
  288. package/app/src/pages/dashboard/users/new/index.ts +123 -0
  289. package/app/src/passkeys.client.ts +18 -0
  290. package/app/src/plugins/default-theme/assets/cover.svg +31 -0
  291. package/app/src/plugins/default-theme/assets/logo.svg +8 -0
  292. package/app/src/plugins/default-theme/parts/comments.ts +66 -0
  293. package/app/src/plugins/default-theme/parts/list.ts +38 -0
  294. package/app/src/plugins/default-theme/parts/media.ts +15 -0
  295. package/app/src/plugins/default-theme/parts/options.ts +45 -0
  296. package/app/src/plugins/default-theme/plugin.json +275 -0
  297. package/app/src/plugins/default-theme/templates/archive.ts +14 -0
  298. package/app/src/plugins/default-theme/templates/entry-blank.ts +13 -0
  299. package/app/src/plugins/default-theme/templates/entry.ts +27 -0
  300. package/app/src/plugins/default-theme/templates/home.ts +8 -0
  301. package/app/src/plugins/default-theme/templates/layout.ts +40 -0
  302. package/app/src/plugins/default-theme/templates/not-found.ts +10 -0
  303. package/app/src/plugins/default-theme/templates/search.ts +32 -0
  304. package/app/src/services/rbac.ts +65 -0
  305. package/app/src/services/roles.ts +89 -0
  306. package/app/src/services/users.ts +173 -0
  307. package/package.json +123 -3
  308. package/src/automations.ts +95 -0
  309. package/src/bindings.ts +138 -0
  310. package/src/block-references.ts +239 -0
  311. package/src/block-shape.ts +155 -0
  312. package/src/blocks.ts +1157 -0
  313. package/src/cache.ts +54 -0
  314. package/src/checks.ts +198 -0
  315. package/src/cloudflare-workers.d.ts +13 -0
  316. package/src/cloudflare.ts +61 -0
  317. package/src/collab.ts +372 -0
  318. package/src/collections.ts +421 -0
  319. package/src/comments.ts +46 -0
  320. package/src/cron.ts +95 -0
  321. package/src/dashboard-menu.ts +105 -0
  322. package/src/diff.ts +113 -0
  323. package/src/editor-layout.ts +316 -0
  324. package/src/errors.ts +50 -0
  325. package/src/field-groups.ts +498 -0
  326. package/src/fields.ts +411 -0
  327. package/src/form-builder.ts +1053 -0
  328. package/src/forms.ts +109 -0
  329. package/src/highlight.ts +134 -0
  330. package/src/hooks.ts +510 -0
  331. package/src/icon-catalog.ts +55 -0
  332. package/src/icons.ts +128 -0
  333. package/src/images.ts +149 -0
  334. package/src/index.ts +100 -0
  335. package/src/isolate-core.ts +245 -0
  336. package/src/isolate.ts +19 -0
  337. package/src/isolation.ts +69 -0
  338. package/src/mail.ts +182 -0
  339. package/src/manifest.ts +476 -0
  340. package/src/media.ts +193 -0
  341. package/src/menus.ts +287 -0
  342. package/src/module.ts +32 -0
  343. package/src/modules/content.ts +64 -0
  344. package/src/modules/forms.ts +35 -0
  345. package/src/node.ts +66 -0
  346. package/src/notes.ts +237 -0
  347. package/src/permissions.ts +139 -0
  348. package/src/plugin-settings.ts +114 -0
  349. package/src/records.ts +56 -0
  350. package/src/redirects.ts +59 -0
  351. package/src/resource.ts +245 -0
  352. package/src/richtext.ts +402 -0
  353. package/src/schema-json.ts +112 -0
  354. package/src/search.ts +89 -0
  355. package/src/seo.ts +477 -0
  356. package/src/server/accounts.ts +418 -0
  357. package/src/server/ai.ts +33 -0
  358. package/src/server/api-tokens.ts +91 -0
  359. package/src/server/areas.ts +116 -0
  360. package/src/server/audit.ts +94 -0
  361. package/src/server/auth.ts +89 -0
  362. package/src/server/automations.ts +190 -0
  363. package/src/server/autosaves.ts +69 -0
  364. package/src/server/brand-icons.ts +50 -0
  365. package/src/server/brands.ts +86 -0
  366. package/src/server/budget.ts +97 -0
  367. package/src/server/cache.ts +104 -0
  368. package/src/server/capabilities.ts +333 -0
  369. package/src/server/cloudflare.ts +92 -0
  370. package/src/server/comments.ts +237 -0
  371. package/src/server/drafts.ts +176 -0
  372. package/src/server/field-groups.ts +88 -0
  373. package/src/server/files.ts +780 -0
  374. package/src/server/forms.ts +726 -0
  375. package/src/server/handoffs.ts +107 -0
  376. package/src/server/host-schema.ts +312 -0
  377. package/src/server/host.ts +2892 -0
  378. package/src/server/images.ts +34 -0
  379. package/src/server/index.ts +59 -0
  380. package/src/server/indexnow.ts +91 -0
  381. package/src/server/isolation.ts +183 -0
  382. package/src/server/locked.ts +45 -0
  383. package/src/server/mail.ts +93 -0
  384. package/src/server/markdown.ts +24 -0
  385. package/src/server/menus.ts +286 -0
  386. package/src/server/network-policy.ts +60 -0
  387. package/src/server/network.ts +665 -0
  388. package/src/server/notes.ts +275 -0
  389. package/src/server/outbox.ts +213 -0
  390. package/src/server/path-moves.ts +33 -0
  391. package/src/server/payments.ts +59 -0
  392. package/src/server/previews.ts +62 -0
  393. package/src/server/purge.ts +140 -0
  394. package/src/server/reconcile.ts +38 -0
  395. package/src/server/redirects.ts +183 -0
  396. package/src/server/repository.ts +1107 -0
  397. package/src/server/schedules.ts +105 -0
  398. package/src/server/schema.ts +562 -0
  399. package/src/server/security.ts +391 -0
  400. package/src/server/seed.ts +52 -0
  401. package/src/server/shared-fields.ts +34 -0
  402. package/src/server/site-export.ts +151 -0
  403. package/src/server/site-import.ts +482 -0
  404. package/src/server/site-search.ts +289 -0
  405. package/src/server/site-settings.ts +286 -0
  406. package/src/server/sites.ts +243 -0
  407. package/src/server/stores.ts +314 -0
  408. package/src/server/stripe.ts +173 -0
  409. package/src/server/taxonomies.ts +415 -0
  410. package/src/server/tokens.ts +25 -0
  411. package/src/server/traffic.ts +118 -0
  412. package/src/server/users.ts +653 -0
  413. package/src/server/webhooks.ts +245 -0
  414. package/src/settings-controls.ts +54 -0
  415. package/src/settings-document.ts +111 -0
  416. package/src/settings.ts +426 -0
  417. package/src/storage/cloudflare.ts +94 -0
  418. package/src/storage/index.ts +30 -0
  419. package/src/storage/node.ts +114 -0
  420. package/src/taxonomy.ts +51 -0
  421. package/src/theme.ts +1135 -0
  422. package/src/to-markdown.ts +179 -0
  423. package/src/updates.ts +126 -0
  424. package/src/version.ts +2 -0
  425. package/src/vite.d.ts +25 -0
  426. package/src/vite.js +199 -0
  427. package/src/webhooks.ts +107 -0
@@ -0,0 +1,131 @@
1
+ /**
2
+ * XML sitemaps of the site: the site's own pages (the routes without parameters, such as `/`),
3
+ * 1,000 entries per file for each collection on the site, with their featured images, and one
4
+ * file of term archives per taxonomy. Server-only.
5
+ */
6
+ import { ANONYMOUS, ARTICLE_TYPES, authorUrl } from '@cossackframework/cms';
7
+ import type { CmsHost } from '@cossackframework/cms/server';
8
+ import { isMembersOnly, isProtected } from './site';
9
+
10
+ const PER_FILE = 1000;
11
+
12
+ /** Routes the site serves that are not pages for crawlers: the dashboard, the API, feeds and the sitemaps themselves. */
13
+ const NOT_PAGES = [/^\/(?:api|auth|dashboard|preview|media|sitemaps|indexnow)(?:\/|$)/, /^\/(?:feed|search|robots\.txt|sitemap\.xml|llms\.txt|manifest\.webmanifest)$/];
14
+ /** How long an article counts as news for the news sitemap. */
15
+ const NEWS_WINDOW = 48 * 3600 * 1000;
16
+
17
+ export interface SitemapUrl {
18
+ url: string;
19
+ updatedAt: number | null;
20
+ /** The entry's featured image, for the image sitemap. */
21
+ image?: string;
22
+ /** The page in each language, itself included, plus `x-default`; only on multilingual sites. */
23
+ alternates?: { hreflang: string; href: string }[];
24
+ /** News sitemap: the article's title, language and publication time. */
25
+ news?: { title: string; language: string; publishedAt: number };
26
+ }
27
+
28
+ /**
29
+ * The site's own pages among its page files (the keys of `virtual:cossack-pages`, such as
30
+ * `/src/pages/(site)/index.ts`): those without parameters, the dashboard, the API and the
31
+ * machine-read files left out, as paths.
32
+ */
33
+ export function staticPages(files: readonly string[]): string[] {
34
+ const paths = files.filter(file => !file.includes('[')).map(file => {
35
+ const path = file.replace('/src/pages/', '/').replace(/\/index\.(ts|mdx?)$/, '').replace(/\.(ts|mdx?)$/, '').replace(/\/\([^)]+\)/g, '');
36
+ return path === '' || path === '/index' ? '/' : path;
37
+ });
38
+ return [...new Set(paths.filter(path => !NOT_PAGES.some(rule => rule.test(path))))].sort();
39
+ }
40
+
41
+ export function xmlEscape(text: string): string {
42
+ return text.replace(/[<>&'"]/g, character => ({ '<': '&lt;', '>': '&gt;', '&': '&amp;', "'": '&apos;', '"': '&quot;' })[character]!);
43
+ }
44
+
45
+ /** The sitemap files to list in the index: `site.xml` for the site's own pages, then `posts-1.xml`, `terms-categories.xml` and the like. */
46
+ export async function sitemapFiles(cms: CmsHost, options: { readonly pages?: readonly string[] } = {}): Promise<string[]> {
47
+ const files: string[] = [];
48
+ if (options.pages?.length) files.push('site.xml');
49
+ for (const collection of cms.collections()) {
50
+ if (collection.path === null || collection.path === undefined || collection.slug === false || collection.sitemap === false || collection.robots?.noindex || (collection.publishable === false && collection.visibility !== 'public')) continue;
51
+ const count = await cms.resource(`cms/${collection.name}`).count(collection.publishable === false ? {} : { where: { status: 'published' } }, { principal: { kind: 'anonymous' } });
52
+ for (let page = 1; page <= Math.max(1, Math.ceil(count / PER_FILE)); page++) if (count) files.push(`${collection.name}-${page}.xml`);
53
+ }
54
+ for (const taxonomy of cms.taxonomies.declarations) if (taxonomy.path && !taxonomy.noindex) files.push(`terms-${taxonomy.name}.xml`);
55
+ if (await cms.settings.get('seo.authorPages') && (await cms.users.authors({ limit: 1 })).length) files.push('authors.xml');
56
+ if ((await newsUrls(cms)).length) files.push('news.xml');
57
+ return files;
58
+ }
59
+
60
+ /** Google News: articles of `NewsArticle` collections published in the last two days, newest first, at most 1,000. */
61
+ async function newsUrls(cms: CmsHost): Promise<SitemapUrl[]> {
62
+ const collections = cms.collections().filter(collection => collection.schema?.type === 'NewsArticle' && typeof collection.path === 'string' && collection.publishable !== false && collection.sitemap !== false && !collection.robots?.noindex);
63
+ if (!collections.length) return [];
64
+ const languages = await cms.languages();
65
+ const since = Date.now() - NEWS_WINDOW;
66
+ const urls: SitemapUrl[] = [];
67
+ for (const collection of collections) {
68
+ const page = await cms.resource(`cms/${collection.name}`).list({ where: { status: 'published', publishedAt: { gte: since } }, order: { field: 'publishedAt', direction: 'desc' }, limit: 100 }, { principal: ANONYMOUS }).catch(() => ({ records: [] }));
69
+ // As in the other sitemaps: protected and members-only entries, and their titles, stay out.
70
+ const records = page.records.filter(record => !(record.seo as { noindex?: boolean } | null)?.noindex && !isProtected(record) && !isMembersOnly(record));
71
+ const found = await cms.entryUrls(collection, records);
72
+ for (const record of records) {
73
+ const url = found.get(record.id);
74
+ if (url) urls.push({ url, updatedAt: record.updatedAt, news: { title: String(record.title ?? ''), language: typeof record.locale === 'string' ? record.locale : languages.default, publishedAt: Number(record.publishedAt) } });
75
+ }
76
+ }
77
+ return urls.sort((a, b) => b.news!.publishedAt - a.news!.publishedAt).slice(0, 1000);
78
+ }
79
+
80
+ /** Language alternates of the entries of one sitemap file, grouped by translation group. */
81
+ function withAlternates(urls: readonly { id: string; url: string; locale: string | null; translationGroup: string | null }[], languages: { multilingual: boolean; default: string }): Map<string, { hreflang: string; href: string }[]> {
82
+ const alternates = new Map<string, { hreflang: string; href: string }[]>();
83
+ if (!languages.multilingual) return alternates;
84
+ const groups = new Map<string, { id: string; url: string; locale: string }[]>();
85
+ for (const entry of urls) {
86
+ const key = entry.translationGroup ?? entry.id;
87
+ groups.set(key, [...(groups.get(key) ?? []), { id: entry.id, url: entry.url, locale: entry.locale ?? languages.default }]);
88
+ }
89
+ for (const members of groups.values()) {
90
+ if (members.length < 2) continue;
91
+ const links = members.map(member => ({ hreflang: member.locale, href: member.url }));
92
+ const fallback = members.find(member => member.locale === languages.default) ?? members[0]!;
93
+ for (const member of members) alternates.set(member.id, [...links, { hreflang: 'x-default', href: fallback.url }]);
94
+ }
95
+ return alternates;
96
+ }
97
+
98
+ /** Author pages: active users with a slug who own a published article. */
99
+ async function authorUrls(cms: CmsHost): Promise<SitemapUrl[]> {
100
+ const urls: SitemapUrl[] = [];
101
+ const collections = cms.collections().filter(collection => typeof collection.path === 'string' && collection.publishable !== false && ARTICLE_TYPES.has(collection.schema?.type ?? 'WebPage'));
102
+ for (const user of await cms.users.authors({ limit: 1000 })) {
103
+ let count = 0;
104
+ for (const collection of collections) count += await cms.resource(`cms/${collection.name}`).count({ where: { status: 'published' }, owner: user.id }, { principal: ANONYMOUS }).catch(() => 0);
105
+ if (count) urls.push({ url: authorUrl(user.slug)!, updatedAt: null });
106
+ }
107
+ return urls;
108
+ }
109
+
110
+ /** The URLs of one sitemap file, or null when there is no such file. */
111
+ export async function sitemapUrls(cms: CmsHost, file: string, options: { readonly pages?: readonly string[] } = {}): Promise<SitemapUrl[] | null> {
112
+ if (file === 'site.xml') return options.pages?.length ? options.pages.map(url => ({ url, updatedAt: null })) : null;
113
+ if (file === 'authors.xml') return await cms.settings.get('seo.authorPages') ? authorUrls(cms) : null;
114
+ if (file === 'news.xml') { const urls = await newsUrls(cms); return urls.length ? urls : null; }
115
+ const terms = /^terms-([a-z][a-zA-Z0-9]{0,40})\.xml$/.exec(file);
116
+ if (terms) {
117
+ const taxonomy = cms.taxonomies.declarations.find(entry => entry.name === terms[1]);
118
+ if (!taxonomy?.path || taxonomy.noindex) return null;
119
+ const { items } = await cms.taxonomies.list(taxonomy.name, { limit: 200 });
120
+ return items.map(term => ({ url: `/${taxonomy.path}/${term.slug}`, updatedAt: term.updatedAt }));
121
+ }
122
+ const entries = /^([a-z][a-z0-9_]{0,40})-(\d{1,4})\.xml$/.exec(file);
123
+ if (!entries) return null;
124
+ const page = Number(entries[2]);
125
+ if (page < 1) return null;
126
+ try { cms.collection(entries[1]!); } catch { return null; }
127
+ const urls = await cms.sitemapEntries(entries[1]!, { offset: (page - 1) * PER_FILE, limit: PER_FILE });
128
+ if (page !== 1 && !urls.length) return null;
129
+ const alternates = withAlternates(urls, await cms.languages());
130
+ return urls.map(entry => ({ url: entry.url, updatedAt: entry.updatedAt, ...(entry.image ? { image: entry.image } : {}), ...(alternates.has(entry.id) ? { alternates: alternates.get(entry.id)! } : {}) }));
131
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The browser's part of a stat block: the number counts up from zero when the block scrolls
3
+ * into view, in the digits and separators it was written with ("1,250", "4.9", "12 000").
4
+ * Reduced motion, or a browser without observers, shows the number as it is.
5
+ */
6
+ const enhanced = new WeakSet<HTMLElement>();
7
+
8
+ /** The parts of a written number: its digits, the grouping separator, and the decimal separator with its digits. */
9
+ export function parseStat(value: string): { target: number; group: string; decimal: string; decimals: number } | null {
10
+ const text = value.trim();
11
+ if (!/^[0-9][0-9., ]*$/.test(text)) return null;
12
+ const separators = [...text.matchAll(/[., ]/g)].map(match => ({ char: match[0], at: match.index! }));
13
+ const last = separators.at(-1);
14
+ // The last separator is the decimal point when what follows it is not a group of three digits.
15
+ const decimal = last && last.char !== ' ' && text.length - last.at - 1 !== 3 ? last.char : '';
16
+ const integerPart = decimal ? text.slice(0, last!.at) : text;
17
+ const fraction = decimal ? text.slice(last!.at + 1).replace(/\D/g, '') : '';
18
+ const group = separators.find(separator => separator.char !== decimal || !decimal)?.char ?? '';
19
+ const digits = integerPart.replace(/\D/g, '');
20
+ const target = Number(`${digits || '0'}.${fraction || '0'}`);
21
+ return Number.isFinite(target) ? { target, group: decimal && group === decimal ? '' : group, decimal, decimals: fraction.length } : null;
22
+ }
23
+
24
+ /** A number written like the original: grouped by threes with its separator, and its decimals. */
25
+ export function formatStat(value: number, shape: { group: string; decimal: string; decimals: number }): string {
26
+ const [whole, fraction = ''] = value.toFixed(shape.decimals).split('.');
27
+ const grouped = shape.group ? whole!.replace(/\B(?=(\d{3})+(?!\d))/g, shape.group) : whole!;
28
+ return shape.decimals ? `${grouped}${shape.decimal || '.'}${fraction}` : grouped;
29
+ }
30
+
31
+ export function enhanceStat(root: HTMLElement): void {
32
+ if (enhanced.has(root)) return;
33
+ enhanced.add(root);
34
+ const number = root.querySelector<HTMLElement>('.cms-stat-number');
35
+ const shape = number ? parseStat(number.dataset.value ?? number.textContent ?? '') : null;
36
+ if (!number || !shape || root.dataset.animate !== 'true' || typeof IntersectionObserver === 'undefined' || matchMedia('(prefers-reduced-motion: reduce)').matches) return;
37
+ const written = number.textContent ?? '';
38
+ const duration = 1400;
39
+ const run = () => {
40
+ const start = performance.now();
41
+ const frame = (now: number) => {
42
+ const progress = Math.min((now - start) / duration, 1);
43
+ const eased = 1 - Math.pow(1 - progress, 3);
44
+ number.textContent = progress < 1 ? formatStat(shape.target * eased, shape) : written;
45
+ if (progress < 1) requestAnimationFrame(frame);
46
+ };
47
+ requestAnimationFrame(frame);
48
+ };
49
+ number.textContent = formatStat(0, shape);
50
+ const observer = new IntersectionObserver(entries => {
51
+ if (!entries.some(entry => entry.isIntersecting)) return;
52
+ observer.disconnect();
53
+ run();
54
+ }, { threshold: 0.3 });
55
+ observer.observe(root);
56
+ }
@@ -0,0 +1,252 @@
1
+ /**
2
+ * A block's Style tab, shared by the entry editor, Appearance → Widgets and the editor on the
3
+ * public site: colors from the theme's palette or a color of the block's own, spacing and font
4
+ * size from its presets, text alignment, for containers an advanced background (a gradient
5
+ * preset, an image or a video from the library, an overlay), and under Advanced the block's ID,
6
+ * HTML anchor and class names. Values are preset slugs (or hex colors, media IDs and flags);
7
+ * `blockStyleAttributes` renders them. Client-safe.
8
+ */
9
+ import { component, html, type TemplateResult } from '@cossackframework/renderer';
10
+ import { ColorPicker, Icon, Input, NativeSelect, Popover, Tabs } from '@cossackframework/ui';
11
+ import { BACKGROUND_SIZES, blockIdProblem, CUSTOM_COLOR, TEXT_ALIGNMENTS, type BlockStyle, type Preset, type StyleProperty, type ThemePresets } from '@cossackframework/cms';
12
+ import type { EditorBlock } from './editor';
13
+ import { mediaControl, type MediaPreview } from './field-controls';
14
+ import { icon } from './icons';
15
+
16
+ export type BlockTab = 'general' | 'style';
17
+
18
+ /** What the Style tab edits: the block's `style`, the layout extras, and the block's ID. */
19
+ export interface StyleValues {
20
+ style: BlockStyle;
21
+ layout: { anchor?: string; className?: string; nosnippet?: boolean };
22
+ /** The block's `_id` as the editor typed it; applied when it is valid and no other block of the field has it. */
23
+ id?: string;
24
+ }
25
+
26
+ /** Media for the advanced background: previews of the files, and the screen's chooser for the image or the video. */
27
+ export interface StyleMediaHooks {
28
+ previews: Record<string, MediaPreview>;
29
+ choose(property: 'image' | 'video'): void;
30
+ }
31
+
32
+ /** What the Style tab needs to know besides the values. */
33
+ export interface StyleControlOptions {
34
+ /** The IDs of the field's other blocks, which the block's ID may not repeat. Without it the ID control stays out. */
35
+ taken?: ReadonlySet<string>;
36
+ /** How a background image or video is chosen. Without it those two controls stay out. */
37
+ media?: StyleMediaHooks;
38
+ }
39
+
40
+ /** The style values of a block as editors hold it. */
41
+ export function styleValues(block: Pick<EditorBlock, 'style' | 'layout'> & { _id?: string }): StyleValues {
42
+ return { style: { ...block.style }, layout: { anchor: block.layout?.anchor ?? '', className: block.layout?.className ?? '', nosnippet: block.layout?.nosnippet === true }, ...(block._id ? { id: block._id } : {}) };
43
+ }
44
+
45
+ /** The ID a block takes from the Style tab's values: the typed one when it is valid and free, else the block's own. */
46
+ export function blockIdOf(block: { _id: string }, values: StyleValues, taken?: ReadonlySet<string>): string {
47
+ const id = values.id?.trim() ?? '';
48
+ return id && id !== block._id && !blockIdProblem(id, taken) ? id : block._id;
49
+ }
50
+
51
+ /** A block with the Style tab's values applied, its hide list kept; `taken` lets a new ID through only when no other block has it. */
52
+ export function withStyle<T extends Pick<EditorBlock, 'style' | 'layout'> & { _id: string }>(block: T, values: StyleValues, taken?: ReadonlySet<string>): T {
53
+ // An empty value, an off flag or a cleared choice is no value.
54
+ const style = Object.fromEntries(Object.entries(values.style).filter(([, value]) => value !== undefined && value !== null && value !== '' && value !== false)) as BlockStyle;
55
+ const anchor = values.layout.anchor?.trim() ?? '';
56
+ const className = values.layout.className?.trim() ?? '';
57
+ const { anchor: _anchor, className: _className, nosnippet: _nosnippet, ...rest } = block.layout ?? {};
58
+ return { ...block, _id: blockIdOf(block, values, taken), style, layout: { ...rest, ...(anchor ? { anchor } : {}), ...(className ? { className } : {}), ...(values.layout.nosnippet ? { nosnippet: true } : {}) } };
59
+ }
60
+
61
+ const ALIGN_ICONS: Record<(typeof TEXT_ALIGNMENTS)[number], string> = { left: 'align-left', center: 'align-horizontal-center', right: 'align-right' };
62
+ const ALIGN_LABELS: Record<(typeof TEXT_ALIGNMENTS)[number], string> = { left: 'Align left', center: 'Align center', right: 'Align right' };
63
+ /** The swatch of no color: a slash. */
64
+ const NONE = 'background: linear-gradient(135deg, transparent 45%, var(--destructive) 45%, var(--destructive) 55%, transparent 55%)';
65
+ const SIZE_LABELS: Record<(typeof BACKGROUND_SIZES)[number], string> = { cover: 'Fill the block', contain: 'Fit inside', auto: 'As uploaded' };
66
+
67
+ /** The two tabs over a block's settings. */
68
+ export function blockTabs(active: BlockTab, pick: (tab: BlockTab) => void, idPrefix: string, content: Record<BlockTab, TemplateResult>): TemplateResult {
69
+ return component(Tabs, {
70
+ id: idPrefix, label: __('Block settings'), value: active, variant: 'underline',
71
+ onValueChange: (value: string) => pick(value as BlockTab),
72
+ items: [
73
+ { value: 'general', label: __('General'), content: content.general },
74
+ { value: 'style', label: __('Style'), content: content.style },
75
+ ],
76
+ });
77
+ }
78
+
79
+ /**
80
+ * The Style tab's controls for the properties the block supports. `change` receives the whole
81
+ * values each time, so a screen keeps them as it keeps a form's values.
82
+ */
83
+ export function styleControls(values: StyleValues, supports: readonly StyleProperty[], presets: Required<ThemePresets>, idPrefix: string, change: (values: StyleValues) => void, options: StyleControlOptions = {}): TemplateResult {
84
+ const has = (property: StyleProperty) => supports.includes(property);
85
+ const set = (property: StyleProperty, value: unknown) => change({ ...values, style: { ...values.style, [property]: value === '' || value === false || value === null ? undefined : value } as BlockStyle });
86
+ const setLayout = (key: 'anchor' | 'className', value: string) => change({ ...values, layout: { ...values.layout, [key]: value } });
87
+ const colors = (property: 'background' | 'text' | 'overlay', label: string) => colorControl(`${idPrefix}-${property}`, label, presets.colors, values.style[property] ?? '', value => set(property, value));
88
+ const select = (property: 'padding' | 'margin' | 'fontSize', label: string, options: readonly Preset[]) => {
89
+ const id = `${idPrefix}-${property}`;
90
+ return html`<div class="min-w-0 space-y-1">
91
+ <label for=${id} class="block text-xs font-medium text-foreground">${label}</label>
92
+ ${component(NativeSelect, { id, '@change': (event: Event) => set(property, (event.target as HTMLSelectElement).value) }, html`
93
+ <option value="" ?selected=${!values.style[property]}>${__('Default')}</option>
94
+ ${options.map(preset => html`<option value=${preset.slug} ?selected=${preset.slug === values.style[property]}>${preset.name}</option>`)}`)}
95
+ </div>`;
96
+ };
97
+ const short = [
98
+ ...(has('padding') ? [select('padding', __('Padding'), presets.spacing)] : []),
99
+ ...(has('margin') ? [select('margin', __('Margin'), presets.spacing)] : []),
100
+ ...(has('fontSize') ? [select('fontSize', __('Font size'), presets.fontSizes)] : []),
101
+ ...(has('align') ? [alignControl(values.style.align ?? '', value => set('align', value))] : []),
102
+ ];
103
+ const idTyped = values.id?.trim() ?? '';
104
+ const idError = options.taken && idTyped ? blockIdProblem(idTyped, options.taken) : undefined;
105
+ return html`<div class="space-y-3" data-style-controls>
106
+ ${!supports.length ? html`<p class="text-sm text-muted-foreground">${__('This block has no style settings.')}</p>` : null}
107
+ ${has('background') ? colors('background', __('Background')) : null}
108
+ ${(['gradient', 'image', 'video', 'overlay'] as const).some(has) ? advancedBackground(values.style, supports, presets, idPrefix, set, colors, options.media) : null}
109
+ ${has('text') ? colors('text', __('Text color')) : null}
110
+ ${short.length ? html`<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">${short}</div>` : null}
111
+ <details class="rounded-md border border-border">
112
+ <summary class="cursor-pointer px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground">${__('Advanced')}</summary>
113
+ <div class="grid gap-3 border-t border-border p-3 sm:grid-cols-2">
114
+ ${options.taken ? html`<div class="min-w-0 space-y-1 sm:col-span-2">
115
+ <label for=${`${idPrefix}-id`} class="block text-xs font-medium text-foreground">${__('Block ID')}</label>
116
+ ${component(Input, { id: `${idPrefix}-id`, type: 'text', maxlength: 40, 'aria-invalid': idError ? 'true' : 'false', '.value': values.id ?? '',
117
+ // Applied when the field is left, not on every keystroke: a half-typed ID would re-key the block each time.
118
+ '@change': (event: Event) => change({ ...values, id: (event.target as HTMLInputElement).value.trim() }) })}
119
+ ${idError ? html`<p role="alert" class="text-xs text-destructive">${__(idError)}</p>`
120
+ : html`<p class="text-xs text-muted-foreground">${__('For code and the API: letters, digits, _ or -, unique in this field. Themes and bindings read the block by it ({{ $.content#id.field }}); notes on the block stay with its old ID.')}</p>`}
121
+ </div>` : null}
122
+ <div class="min-w-0 space-y-1">
123
+ <label for=${`${idPrefix}-anchor`} class="block text-xs font-medium text-foreground">${__('HTML anchor')}</label>
124
+ ${component(Input, { id: `${idPrefix}-anchor`, type: 'text', maxlength: 60, '.value': values.layout.anchor ?? '', '@input': (event: Event) => setLayout('anchor', (event.target as HTMLInputElement).value) })}
125
+ <p class="text-xs text-muted-foreground">${__('Lets links jump to this block: a letter, then letters, digits, _ or -.')}</p>
126
+ </div>
127
+ <div class="min-w-0 space-y-1">
128
+ <label for=${`${idPrefix}-class`} class="block text-xs font-medium text-foreground">${__('Additional classes')}</label>
129
+ ${component(Input, { id: `${idPrefix}-class`, type: 'text', maxlength: 200, '.value': values.layout.className ?? '', '@input': (event: Event) => setLayout('className', (event.target as HTMLInputElement).value) })}
130
+ <p class="text-xs text-muted-foreground">${__('Separated by spaces, for the theme\'s stylesheet.')}</p>
131
+ </div>
132
+ <label class="flex items-center gap-2 text-xs text-foreground cursor-pointer sm:col-span-2">
133
+ <input type="checkbox" .checked=${values.layout.nosnippet === true} @change=${(event: Event) => change({ ...values, layout: { ...values.layout, nosnippet: (event.target as HTMLInputElement).checked } })}>
134
+ ${__('Keep out of snippets and AI answers (data-nosnippet)')}
135
+ </label>
136
+ </div>
137
+ </details>
138
+ </div>`;
139
+ }
140
+
141
+ /**
142
+ * The advanced background of a container, folded under the background color: a gradient preset
143
+ * over an image from the library (how it fills, repeats and scrolls), a video behind the blocks,
144
+ * and an overlay color at an opacity over them. Open while any of them is set. The image and the
145
+ * video need the screen's media chooser.
146
+ */
147
+ function advancedBackground(style: BlockStyle, supports: readonly StyleProperty[], presets: Required<ThemePresets>, idPrefix: string, set: (property: StyleProperty, value: unknown) => void,
148
+ colors: (property: 'overlay', label: string) => TemplateResult, media: StyleMediaHooks | undefined): TemplateResult {
149
+ const has = (property: StyleProperty) => supports.includes(property);
150
+ const checkbox = (property: 'imageRepeat' | 'imageFixed', label: string) => html`<label class="flex items-center gap-2 text-xs text-foreground cursor-pointer">
151
+ <input type="checkbox" .checked=${style[property] === true} @change=${(event: Event) => set(property, (event.target as HTMLInputElement).checked)}> ${label}</label>`;
152
+ const picker = (property: 'image' | 'video', label: string) => mediaControl(style[property] ?? '', value => set(property, typeof value === 'string' ? value : ''), label, false, { previews: media!.previews, choose: () => media!.choose(property) });
153
+ const opacity = typeof style.overlayOpacity === 'number' ? style.overlayOpacity : 50;
154
+ return html`<details class="rounded-md border border-border" data-advanced-background ?open=${Boolean(style.gradient || style.image || style.video || style.overlay)}>
155
+ <summary class="cursor-pointer px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground">${__('Advanced background')}</summary>
156
+ <div class="space-y-3 border-t border-border p-3">
157
+ ${has('gradient') ? gradientControl(`${idPrefix}-gradient`, presets.gradients, style.gradient ?? '', value => set('gradient', value)) : null}
158
+ ${has('image') && media ? html`<div class="space-y-2">
159
+ <span class="block text-xs font-medium text-foreground">${__('Image')}</span>
160
+ ${picker('image', __('Image'))}
161
+ ${style.image ? html`<div class="grid gap-3 sm:grid-cols-2">
162
+ <div class="min-w-0 space-y-1">
163
+ <label for=${`${idPrefix}-image-size`} class="block text-xs font-medium text-foreground">${__('Fill')}</label>
164
+ ${component(NativeSelect, { id: `${idPrefix}-image-size`, '@change': (event: Event) => set('imageSize', (event.target as HTMLSelectElement).value) }, html`
165
+ ${BACKGROUND_SIZES.map(size => html`<option value=${size} ?selected=${(style.imageSize ?? 'cover') === size}>${__(SIZE_LABELS[size])}</option>`)}`)}
166
+ </div>
167
+ <div class="space-y-1.5 self-end">${checkbox('imageRepeat', __('Repeat'))}${checkbox('imageFixed', __('Fixed while scrolling (parallax)'))}</div>
168
+ </div>
169
+ <p class="text-xs text-muted-foreground">${__('Placed at the focal point set in the media library. Fixed keeps the image in place as the page scrolls; iPhones and iPads ignore it.')}</p>` : null}
170
+ </div>` : null}
171
+ ${has('video') && media ? html`<div class="space-y-2">
172
+ <span class="block text-xs font-medium text-foreground">${__('Video')}</span>
173
+ ${picker('video', __('Video'))}
174
+ <p class="text-xs text-muted-foreground">${__('Plays muted in a loop behind the blocks, with the image as its poster. Every visitor downloads it: keep it short and compressed.')}</p>
175
+ </div>` : null}
176
+ ${has('overlay') ? html`<div class="grid gap-3 sm:grid-cols-2">
177
+ ${colors('overlay', __('Overlay'))}
178
+ ${style.overlay ? html`<div class="min-w-0 space-y-1">
179
+ <label for=${`${idPrefix}-overlay-opacity`} class="block text-xs font-medium text-foreground">${__('Overlay opacity')}: ${opacity}%</label>
180
+ <input id=${`${idPrefix}-overlay-opacity`} type="range" min="0" max="100" step="5" .value=${String(opacity)} class="block w-full" @input=${(event: Event) => set('overlayOpacity', Number((event.target as HTMLInputElement).value))}>
181
+ </div>` : null}
182
+ </div>
183
+ <p class="text-xs text-muted-foreground">${__('A color over the image or video, so the text stays readable.')}</p>` : null}
184
+ </div>
185
+ </details>`;
186
+ }
187
+
188
+ /** A gradient from the theme's presets, with a swatch of the chosen one. */
189
+ function gradientControl(id: string, gradients: readonly Preset[], value: string, set: (value: string) => void): TemplateResult {
190
+ const current = gradients.find(entry => entry.slug === value);
191
+ return html`<div class="min-w-0 space-y-1" data-gradient-control>
192
+ <label for=${id} class="block text-xs font-medium text-foreground">${__('Gradient')}</label>
193
+ <div class="flex items-center gap-2">
194
+ <span aria-hidden="true" class="inline-block h-8 w-12 shrink-0 rounded border border-border" style=${current ? `background: ${current.value}` : NONE}></span>
195
+ <div class="min-w-0 flex-1">${component(NativeSelect, { id, '@change': (event: Event) => set((event.target as HTMLSelectElement).value) }, html`
196
+ <option value="" ?selected=${!value}>${__('None')}</option>
197
+ ${gradients.map(preset => html`<option value=${preset.slug} ?selected=${preset.slug === value}>${preset.name}</option>`)}`)}</div>
198
+ </div>
199
+ </div>`;
200
+ }
201
+
202
+ /**
203
+ * A color: a box showing the current one, which opens a picker with the theme's palette (as
204
+ * swatches, with None) and a custom color (the browser's picker, or a hex code). The value is a
205
+ * preset's slug or the hex color.
206
+ */
207
+ function colorControl(id: string, label: string, colors: readonly Preset[], value: string, set: (value: string) => void): TemplateResult {
208
+ const preset = colors.find(entry => entry.slug === value);
209
+ const custom = !preset && CUSTOM_COLOR.test(value) ? value.toLowerCase() : '';
210
+ const current = preset?.value ?? custom;
211
+ // Picking from the palette is the whole choice: the picker closes. The custom color stays open while it is typed.
212
+ const pick = (slug: string) => { set(slug); (document.getElementById(`${id}-picker-content`) as HTMLElement & { hidePopover?(): void } | null)?.hidePopover?.(); };
213
+ const swatch = (slug: string, name: string, color: string | null) => html`<button type="button" role="radio" aria-checked=${value === slug ? 'true' : 'false'} title=${name} aria-label=${name}
214
+ class=${`h-7 w-7 rounded-md border cursor-pointer ${value === slug ? 'border-primary ring-2 ring-primary ring-offset-2 ring-offset-background' : 'border-border hover:border-foreground'}`}
215
+ style=${color ? `background: ${color}` : NONE}
216
+ @click=${() => pick(slug)}></button>`;
217
+ return html`<div class="space-y-1" data-color-control>
218
+ <span id=${id} class="block text-xs font-medium text-foreground">${label}</span>
219
+ ${component(Popover, {
220
+ id: `${id}-picker`, side: 'bottom', align: 'start', 'aria-labelledby': id,
221
+ class: 'w-full justify-start gap-2 rounded-md border border-input bg-background px-2 py-1.5 text-sm text-foreground hover:bg-muted',
222
+ trigger: html`<span aria-hidden="true" class="inline-block h-5 w-5 shrink-0 rounded border border-border" style=${current ? `background: ${current}` : NONE}></span>
223
+ <span class="min-w-0 truncate">${preset ? preset.name : custom || __('None')}</span>`,
224
+ contentProps: { 'aria-label': `${label}: ${__('choose a color')}`, class: 'w-72 space-y-3 text-sm' },
225
+ }, html`
226
+ <div class="space-y-1.5">
227
+ <p class="text-xs font-medium text-muted-foreground">${__('Theme colors')}</p>
228
+ ${colors.length ? html`<div role="radiogroup" aria-label=${label} class="flex flex-wrap items-center gap-1.5">
229
+ ${swatch('', __('None'), null)}
230
+ ${colors.map(entry => swatch(entry.slug, entry.name, entry.value))}
231
+ </div>` : html`<p class="text-xs text-muted-foreground">${__('The theme has no colors. Add some under Appearance → Customize.')}</p>`}
232
+ </div>
233
+ <div class="space-y-1.5">
234
+ <p class="text-xs font-medium text-muted-foreground">${__('Custom color')}</p>
235
+ <div class="flex items-center gap-2">
236
+ ${component(ColorPicker, { id: `${id}-custom`, label: `${label}: ${__('pick a color')}`, value: custom || current || '#000000', onChange: (color: string) => set(color.toLowerCase()) })}
237
+ ${component(Input, { id: `${id}-hex`, type: 'text', maxlength: 9, placeholder: '#336699', 'aria-label': `${label}: ${__('hex color')}`, '.value': custom,
238
+ '@change': (event: Event) => { const text = (event.target as HTMLInputElement).value.trim(); if (!text || CUSTOM_COLOR.test(text)) set(text.toLowerCase()); } })}
239
+ </div>
240
+ </div>`)}
241
+ </div>`;
242
+ }
243
+
244
+ /** Left, centre and right, as a toggle group. Pressing the active one clears it. */
245
+ function alignControl(value: string, set: (value: string) => void): TemplateResult {
246
+ return html`<div class="min-w-0 space-y-1">
247
+ <span class="block text-xs font-medium text-foreground">${__('Alignment')}</span>
248
+ <div role="group" class="flex gap-1">${TEXT_ALIGNMENTS.map(align => html`<button type="button" aria-pressed=${value === align ? 'true' : 'false'} title=${__(ALIGN_LABELS[align])} aria-label=${__(ALIGN_LABELS[align])}
249
+ class=${`inline-flex h-8 w-8 items-center justify-center rounded border cursor-pointer [&_svg]:size-4 ${value === align ? 'border-primary bg-primary/10 text-foreground' : 'border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground'}`}
250
+ @click=${() => set(value === align ? '' : align)}>${component(Icon, { entry: icon(ALIGN_ICONS[align]), size: 16 })}</button>`)}</div>
251
+ </div>`;
252
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The browser's part of a tabs block: the tab buttons show their panel, the arrow keys, Home and
3
+ * End move between them, and a link to a panel's id opens its tab. Without this every panel shows
4
+ * under its title, so the content is never out of reach.
5
+ */
6
+ const enhanced = new WeakSet<HTMLElement>();
7
+
8
+ export function enhanceTabs(root: HTMLElement): void {
9
+ if (enhanced.has(root)) return;
10
+ enhanced.add(root);
11
+ const tabs = [...root.querySelectorAll<HTMLButtonElement>(':scope > .cms-tablist > [role="tab"]')];
12
+ const panels = [...root.querySelectorAll<HTMLElement>(':scope > .cms-tabpanel')];
13
+ if (!tabs.length || tabs.length !== panels.length) return;
14
+ root.setAttribute('data-enhanced', '');
15
+ const select = (index: number, focus: boolean) => {
16
+ tabs.forEach((tab, at) => { tab.setAttribute('aria-selected', at === index ? 'true' : 'false'); tab.tabIndex = at === index ? 0 : -1; });
17
+ panels.forEach((panel, at) => { if (at === index) panel.setAttribute('data-active', ''); else panel.removeAttribute('data-active'); });
18
+ if (focus) tabs[index]?.focus();
19
+ };
20
+ tabs.forEach((tab, index) => {
21
+ tab.addEventListener('click', () => select(index, false));
22
+ tab.addEventListener('keydown', event => {
23
+ const moves: Record<string, number> = { ArrowRight: index + 1, ArrowDown: index + 1, ArrowLeft: index - 1, ArrowUp: index - 1, Home: 0, End: tabs.length - 1 };
24
+ const next = moves[event.key];
25
+ if (next === undefined) return;
26
+ event.preventDefault();
27
+ select((next + tabs.length) % tabs.length, true);
28
+ });
29
+ });
30
+ const open = () => {
31
+ const index = panels.findIndex(panel => panel.id && panel.id === decodeURIComponent(location.hash.slice(1)));
32
+ if (index >= 0) select(index, false);
33
+ };
34
+ open();
35
+ addEventListener('hashchange', open);
36
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * The taskbar signed-in users see along the bottom of every site page, as WordPress's toolbar
3
+ * sits along the top: the site's logo opens the dashboard's navigation, the middle holds what
4
+ * the current page offers (editing the entry, its SEO, managing its collection), then plugins'
5
+ * links, a New menu and the user's menu. An entry its editor may change offers Live Edit (in place,
6
+ * at `?edit`) and Edit (the dashboard's editor). Desktop and tablet only; the site editor's own bar
7
+ * takes over in edit mode. The site layout renders it from a `server$` resource that
8
+ * `site-taskbar.ts` builds; pages describe themselves through `c.set('cms.taskbar', …)`.
9
+ * Client-safe: visitors never get it, signed-in users' pages ship it.
10
+ */
11
+ import { component, html, type TemplateResult } from '@cossackframework/renderer';
12
+ import { Avatar, DropdownMenu, Icon, Popover } from '@cossackframework/ui';
13
+ import type { IconEntry } from '@cossackframework/solar-icons/types';
14
+ import type { SeoView } from './seo-head';
15
+ import { icon } from './icons';
16
+ import { initials, STATUS_LABELS } from './ui';
17
+
18
+ /** What a page tells the taskbar about itself, in its `init()`, before the layout renders. */
19
+ export interface TaskbarPage {
20
+ /** The entry shown, when the user may edit it; `inPlace` when the page opens its editor on `?edit`. */
21
+ entry?: { collection: string; id: string; status: string; dashboard: string; inPlace: boolean } | null;
22
+ /** No entry of theirs, but the user may change the theme's areas: `?edit` opens the frame alone. */
23
+ frame?: boolean;
24
+ /** What engines see on the page, for the SEO inspector. */
25
+ seo?: SeoView | null;
26
+ }
27
+
28
+ declare module 'hono' {
29
+ interface ContextVariableMap {
30
+ /** The page's context for the site taskbar, set by a site page's `init()`. */
31
+ 'cms.taskbar': TaskbarPage | undefined;
32
+ }
33
+ }
34
+
35
+ export interface TaskbarLink { label: string; href: string; icon?: IconEntry }
36
+
37
+ /** The taskbar's view, built on the server for the signed-in user and the page they are on. */
38
+ export interface TaskbarView {
39
+ /** `logoOnly`: the site set its own logo, which shows without the title. */
40
+ site: { title: string; logo: string; logoOnly: boolean };
41
+ /** The start menu: Dashboard, then the user's navigation modules. */
42
+ start: TaskbarLink[];
43
+ /** The current page's tools: the entry's status, the in-place editor's address, and links. */
44
+ context: { status: string | null; edit: string | null; links: TaskbarLink[] };
45
+ /** The New menu: an entry of every collection the user may create, and uploads. */
46
+ create: TaskbarLink[];
47
+ /** Links active plugins add through `ui.slots['site.taskbar']`. */
48
+ plugins: TaskbarLink[];
49
+ seo: SeoView | null;
50
+ user: { name: string; email: string; avatar: string | null; links: TaskbarLink[] };
51
+ }
52
+
53
+ const ITEM = 'inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-sm text-muted-foreground no-underline hover:bg-muted hover:text-foreground [&_svg]:size-4';
54
+ /**
55
+ * Hidden while the page's editor is open: the bar keeps its first item (the start menu) and its
56
+ * last (the user), and the editor's own controls take the middle (`SiteEditor.bar`, placed
57
+ * between `[data-taskbar-start]` and `[data-taskbar-end]`). Leaving edit mode shows them again.
58
+ */
59
+ const EDITING = '[body:has([data-site-editing])_&]:hidden';
60
+ const SEPARATOR = html`<span aria-hidden="true" class="mx-1 h-5 w-px bg-border"></span>`;
61
+
62
+ const menuLink = (link: TaskbarLink) => html`<a role="menuitem" tabindex="-1" href=${link.href} class="flex w-full items-center gap-2 rounded-sm px-3 py-2 text-sm text-foreground no-underline hover:bg-muted">
63
+ ${link.icon ? html`<span class="inline-flex text-muted-foreground [&_svg]:size-4">${component(Icon, { entry: link.icon, size: 16 })}</span>` : null}<span class="min-w-0 truncate">${__(link.label)}</span></a>`;
64
+
65
+ /** The entry's status as underlined text in the status's color, quieter than a badge on the bar. */
66
+ const STATUS_LINE: Record<string, string> = { published: 'decoration-emerald-500', scheduled: 'decoration-sky-500', pending: 'decoration-amber-500', draft: 'decoration-muted-foreground/60', trash: 'decoration-destructive' };
67
+ const statusText = (status: string) => STATUS_LABELS[status] ? html`<span data-taskbar-status=${status} class=${`inline-flex h-8 items-center px-2 text-xs font-medium text-muted-foreground underline decoration-2 underline-offset-[5px] ${STATUS_LINE[status] ?? ''}`}>${__(STATUS_LABELS[status]!)}</span>` : null;
68
+
69
+ const barLink = (link: TaskbarLink) => html`<a href=${link.href} class=${ITEM}>${link.icon ? component(Icon, { entry: link.icon, size: 16 }) : null}${__(link.label)}</a>`;
70
+
71
+ export function taskbar(view: TaskbarView, handlers: { logout(): void; error?: string }): TemplateResult {
72
+ const { context } = view;
73
+ return html`<div aria-hidden="true" class="hidden h-10 md:block"></div>
74
+ <nav data-cms-taskbar aria-label=${__('Site taskbar')} class="fixed inset-x-0 bottom-0 z-40 hidden h-10 items-center gap-0.5 border-t border-border bg-background/95 px-2 text-foreground backdrop-blur md:flex">
75
+ <span data-taskbar-start class="inline-flex shrink-0">${component(DropdownMenu, {
76
+ id: 'cms-taskbar-start', side: 'top', align: 'start', title: __('Dashboard'),
77
+ trigger: html`<span class=${`${ITEM} font-medium text-foreground`}>
78
+ ${view.site.logoOnly
79
+ ? html`<img src=${view.site.logo} alt=${view.site.title} width="24" height="24" loading="eager" class="h-6 w-auto max-w-28 shrink-0 object-contain">`
80
+ : html`<img src=${view.site.logo} alt="" width="20" height="20" loading="eager" class="h-5 w-auto max-w-20 shrink-0 object-contain">
81
+ <span class="max-w-40 truncate">${view.site.title}</span>`}</span>`,
82
+ }, html`${view.start.map(menuLink)}`)}</span>
83
+ <div class=${`contents ${EDITING}`}>
84
+ ${SEPARATOR}
85
+ ${context.status ? statusText(context.status) : null}
86
+ ${context.edit ? barLink({ label: 'Live Edit', href: context.edit, icon: icon('cursor') }) : null}
87
+ ${context.links.map(barLink)}
88
+ ${view.seo?.title ? seoInspector(view.seo) : null}
89
+ </div>
90
+ <span class="flex-1"></span>
91
+ <div class=${`contents ${EDITING}`}>
92
+ ${handlers.error ? html`<p role="alert" class="px-2 text-xs text-destructive">${handlers.error}</p>` : null}
93
+ ${view.plugins.length ? html`${view.plugins.map(barLink)}${SEPARATOR}` : null}
94
+ ${view.create.length ? component(DropdownMenu, {
95
+ id: 'cms-taskbar-new', side: 'top', align: 'end',
96
+ trigger: html`<span class=${ITEM}>${component(Icon, { entry: icon('pen-new-square'), size: 16 })}${__('New')}</span>`,
97
+ }, html`${view.create.map(menuLink)}`) : null}
98
+ </div>
99
+ <span data-taskbar-end class="inline-flex shrink-0">${component(DropdownMenu, {
100
+ id: 'cms-taskbar-user', side: 'top', align: 'end',
101
+ trigger: html`<span class=${ITEM}>${component(Avatar, { src: view.user.avatar ?? undefined, alt: '', size: 24 }, initials(view.user.name))}<span class="max-w-40 truncate text-foreground">${view.user.name}</span></span>`,
102
+ }, html`
103
+ <div class="px-3 py-2">
104
+ <div class="text-sm font-medium">${view.user.name}</div>
105
+ <div class="text-xs text-muted-foreground">${view.user.email}</div>
106
+ </div>
107
+ <div class="my-1 h-px bg-border"></div>
108
+ ${view.user.links.map(menuLink)}
109
+ <div class="my-1 h-px bg-border"></div>
110
+ <button type="button" role="menuitem" tabindex="-1" @click=${() => handlers.logout()}
111
+ class="flex w-full cursor-pointer items-center gap-2 rounded-sm border-none bg-transparent px-3 py-2 text-left text-sm text-destructive hover:bg-muted">${__('Log out')}</button>
112
+ `)}</span>
113
+ </nav>`;
114
+ }
115
+
116
+ /** What engines see on this page: the resolved title, description, robots, canonical and the structured data types. */
117
+ function seoInspector(seo: SeoView): TemplateResult {
118
+ let types: string[] = [];
119
+ try { types = ((JSON.parse(seo.jsonLd) as { '@graph'?: { '@type'?: string }[] })['@graph'] ?? []).map(node => node['@type'] ?? '').filter(Boolean); } catch { /* no graph */ }
120
+ const row = (label: string, value: string) => value ? html`<div class="grid grid-cols-[6rem_minmax(0,1fr)] gap-2"><dt class="text-muted-foreground">${label}</dt><dd class="min-w-0 break-words text-foreground">${value}</dd></div>` : null;
121
+ return component(Popover, {
122
+ id: 'cms-taskbar-seo', side: 'top', align: 'start', class: ITEM,
123
+ trigger: html`${component(Icon, { entry: icon('magnifier'), size: 16 })}${__('SEO')}`,
124
+ contentProps: { 'aria-label': __('What search engines see'), class: 'w-[min(28rem,90vw)] text-xs' },
125
+ }, html`<dl class="space-y-1.5">
126
+ ${row(__('Title'), seo.title)}
127
+ ${row(__('Description'), seo.description || `(${__('none')})`)}
128
+ ${row(__('Robots'), seo.robots || `(${__('index, follow')})`)}
129
+ ${row(__('Canonical'), seo.canonical)}
130
+ ${row(__('Image'), seo.image || `(${__('none')})`)}
131
+ ${row(__('Schema'), types.join(', ') || `(${__('none')})`)}
132
+ ${seo.markdownUrl ? html`<div class="pt-1"><a href=${seo.markdownUrl} target="_blank" rel="noopener" class="text-primary hover:underline">${__('View as Markdown')}</a></div>` : null}
133
+ </dl>`);
134
+ }