tinyzoo 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (391) hide show
  1. package/LICENSE +10 -0
  2. package/README.md +46 -2
  3. package/app/app.config.ts +35 -0
  4. package/app/assets/brand/characters/bright/bird.svg +1 -0
  5. package/app/assets/brand/characters/bright/bunny.svg +1 -0
  6. package/app/assets/brand/characters/bright/elephant.svg +1 -0
  7. package/app/assets/brand/characters/bright/fox.svg +1 -0
  8. package/app/assets/brand/characters/bright/frog.svg +1 -0
  9. package/app/assets/brand/characters/bright/octopus.svg +1 -0
  10. package/app/assets/brand/characters/muted/bee.svg +1 -0
  11. package/app/assets/brand/characters/muted/bird.svg +1 -0
  12. package/app/assets/brand/characters/muted/butterfly.svg +1 -0
  13. package/app/assets/brand/characters/muted/chick.svg +1 -0
  14. package/app/assets/brand/characters/muted/cow.svg +1 -0
  15. package/app/assets/brand/characters/muted/deer.svg +1 -0
  16. package/app/assets/brand/characters/muted/duck.svg +1 -0
  17. package/app/assets/brand/characters/muted/elephant.svg +1 -0
  18. package/app/assets/brand/characters/muted/fox.svg +1 -0
  19. package/app/assets/brand/characters/muted/hedgehog.svg +1 -0
  20. package/app/assets/brand/characters/muted/koala.svg +1 -0
  21. package/app/assets/brand/characters/muted/ladybug.svg +1 -0
  22. package/app/assets/brand/characters/muted/lion.svg +1 -0
  23. package/app/assets/brand/characters/muted/mouse.svg +1 -0
  24. package/app/assets/brand/characters/muted/octopus.svg +1 -0
  25. package/app/assets/brand/characters/muted/owl.svg +1 -0
  26. package/app/assets/brand/characters/muted/panda.svg +1 -0
  27. package/app/assets/brand/characters/muted/penguin.svg +1 -0
  28. package/app/assets/brand/characters/muted/pig.svg +1 -0
  29. package/app/assets/brand/characters/muted/poodle.svg +1 -0
  30. package/app/assets/brand/characters/muted/raccoon.svg +1 -0
  31. package/app/assets/brand/characters/muted/seal.svg +1 -0
  32. package/app/assets/brand/characters/muted/sheep.svg +1 -0
  33. package/app/assets/brand/characters/muted/snail.svg +1 -0
  34. package/app/assets/brand/characters/muted/turtle.svg +1 -0
  35. package/app/assets/brand/characters/muted/whale.svg +1 -0
  36. package/app/assets/brand/logo/favicon.svg +1 -0
  37. package/app/assets/brand/logo/logo-primary-reversed.svg +1 -0
  38. package/app/assets/brand/logo/logo-primary.svg +1 -0
  39. package/app/assets/brand/logo/mascot-reversed.svg +1 -0
  40. package/app/assets/brand/logo/mascot.svg +1 -0
  41. package/app/assets/brand/logo/wordmark-reversed.svg +1 -0
  42. package/app/assets/brand/logo/wordmark.svg +1 -0
  43. package/app/assets/css/cms-admin.css +607 -0
  44. package/app/components/CmsBlocks.vue +30 -0
  45. package/app/components/CmsCell.vue +16 -0
  46. package/app/components/CmsCellBadge.vue +18 -0
  47. package/app/components/CmsCellBlocks.vue +9 -0
  48. package/app/components/CmsCellBoolean.vue +12 -0
  49. package/app/components/CmsCellCode.vue +7 -0
  50. package/app/components/CmsCellColor.vue +13 -0
  51. package/app/components/CmsCellDate.vue +10 -0
  52. package/app/components/CmsCellExcerpt.vue +21 -0
  53. package/app/components/CmsCellGallery.vue +10 -0
  54. package/app/components/CmsCellGroup.vue +23 -0
  55. package/app/components/CmsCellNumber.vue +7 -0
  56. package/app/components/CmsCellRelation.vue +8 -0
  57. package/app/components/CmsCellText.vue +12 -0
  58. package/app/components/CmsCellThumb.vue +18 -0
  59. package/app/components/CmsConfirmDialog.vue +55 -0
  60. package/app/components/CmsContent.vue +103 -0
  61. package/app/components/CmsDayPicker.vue +44 -0
  62. package/app/components/CmsEmptyState.vue +35 -0
  63. package/app/components/CmsField.vue +111 -0
  64. package/app/components/CmsFieldBlocks.vue +353 -0
  65. package/app/components/CmsFieldBoolean.vue +8 -0
  66. package/app/components/CmsFieldColor.vue +42 -0
  67. package/app/components/CmsFieldDate.vue +131 -0
  68. package/app/components/CmsFieldGallery.vue +114 -0
  69. package/app/components/CmsFieldGroup.vue +53 -0
  70. package/app/components/CmsFieldMedia.vue +219 -0
  71. package/app/components/CmsFieldNumber.vue +11 -0
  72. package/app/components/CmsFieldRelationMany.vue +54 -0
  73. package/app/components/CmsFieldRelationOne.vue +47 -0
  74. package/app/components/CmsFieldRichText.vue +45 -0
  75. package/app/components/CmsFieldSelect.vue +41 -0
  76. package/app/components/CmsFieldSlug.vue +46 -0
  77. package/app/components/CmsFieldText.vue +75 -0
  78. package/app/components/CmsFormSections.vue +150 -0
  79. package/app/components/CmsHighlight.vue +22 -0
  80. package/app/components/CmsImage.vue +39 -0
  81. package/app/components/CmsLinkPicker.vue +122 -0
  82. package/app/components/CmsLinkTarget.vue +35 -0
  83. package/app/components/CmsListFilters.vue +107 -0
  84. package/app/components/CmsLiveNotice.vue +64 -0
  85. package/app/components/CmsLoadError.vue +24 -0
  86. package/app/components/CmsMascot.vue +10 -0
  87. package/app/components/CmsMediaLibrary.vue +114 -0
  88. package/app/components/CmsMediaPreview.vue +34 -0
  89. package/app/components/CmsMediaThumb.vue +22 -0
  90. package/app/components/CmsMoment.vue +42 -0
  91. package/app/components/CmsNav.vue +39 -0
  92. package/app/components/CmsPage.vue +86 -0
  93. package/app/components/CmsPasswordInput.vue +22 -0
  94. package/app/components/CmsPresence.vue +29 -0
  95. package/app/components/CmsPreviewPanel.vue +131 -0
  96. package/app/components/CmsPublishReview.vue +102 -0
  97. package/app/components/CmsRevisions.vue +195 -0
  98. package/app/components/CmsRichTextEditor.vue +290 -0
  99. package/app/components/CmsSearch.vue +99 -0
  100. package/app/components/CmsSection.vue +20 -0
  101. package/app/components/CmsSingletonForm.vue +283 -0
  102. package/app/components/CmsStatusBadge.vue +21 -0
  103. package/app/components/CmsTime.vue +16 -0
  104. package/app/components/CmsTranslationRef.vue +27 -0
  105. package/app/components/CmsTreeList.vue +453 -0
  106. package/app/components/CmsUnsavedText.vue +34 -0
  107. package/app/components/CmsWordmark.vue +10 -0
  108. package/app/composables/useCmsAdminHead.ts +18 -0
  109. package/app/composables/useCmsCollab.ts +165 -0
  110. package/app/composables/useCmsConfirm.ts +39 -0
  111. package/app/composables/useCmsEntryActions.ts +75 -0
  112. package/app/composables/useCmsFocus.ts +13 -0
  113. package/app/composables/useCmsForm.ts +273 -0
  114. package/app/composables/useCmsI18n.ts +185 -0
  115. package/app/composables/useCmsLinkTargets.ts +84 -0
  116. package/app/composables/useCmsLive.ts +199 -0
  117. package/app/composables/useCmsSearch.ts +62 -0
  118. package/app/composables/useCmsSeo.ts +99 -0
  119. package/app/composables/useCmsSignedIn.ts +24 -0
  120. package/app/composables/useCmsUiLocale.ts +24 -0
  121. package/app/i18n/cs.ts +781 -0
  122. package/app/i18n/de.ts +781 -0
  123. package/app/i18n/en.ts +782 -0
  124. package/app/i18n/types.ts +22 -0
  125. package/app/layouts/admin.vue +224 -0
  126. package/app/layouts/cms-auth.vue +37 -0
  127. package/app/middleware/cms-api-not-a-page.global.ts +10 -0
  128. package/app/middleware/cms-auth.global.ts +16 -0
  129. package/app/pages/admin/[entity]/[id].vue +1109 -0
  130. package/app/pages/admin/[entity]/index.vue +733 -0
  131. package/app/pages/admin/account.vue +117 -0
  132. package/app/pages/admin/forgot.vue +50 -0
  133. package/app/pages/admin/index.vue +184 -0
  134. package/app/pages/admin/invite/[token].vue +73 -0
  135. package/app/pages/admin/login.vue +84 -0
  136. package/app/pages/admin/media.vue +494 -0
  137. package/app/pages/admin/privacy.vue +193 -0
  138. package/app/pages/admin/reset/[token].vue +52 -0
  139. package/app/pages/admin/setup.vue +87 -0
  140. package/app/pages/admin/styleguide.vue +261 -0
  141. package/app/pages/admin/team.vue +258 -0
  142. package/app/plugins/cmsLivePreview.client.ts +20 -0
  143. package/app/plugins/cmsSignedOut.client.ts +31 -0
  144. package/app/utils/cmsBlockType.ts +11 -0
  145. package/app/utils/cmsBrand.ts +38 -0
  146. package/app/utils/cmsDiff.ts +83 -0
  147. package/app/utils/cmsFetch.ts +7 -0
  148. package/app/utils/cmsFocusInvalid.ts +22 -0
  149. package/app/utils/cmsIssues.ts +128 -0
  150. package/app/utils/cmsJson.ts +28 -0
  151. package/app/utils/cmsMedia.ts +63 -0
  152. package/app/utils/cmsSections.ts +154 -0
  153. package/app/utils/cmsTime.ts +41 -0
  154. package/cli/backup.ts +713 -0
  155. package/cli/breaking.ts +174 -0
  156. package/cli/content-migrate.ts +239 -0
  157. package/cli/db.ts +86 -0
  158. package/cli/export.ts +336 -0
  159. package/cli/generate.ts +146 -0
  160. package/cli/import.ts +643 -0
  161. package/cli/index.ts +140 -0
  162. package/cli/links-convert.ts +291 -0
  163. package/cli/seed-engine.ts +705 -0
  164. package/cli/seed.ts +339 -0
  165. package/cli/status.ts +49 -0
  166. package/cli/tar.ts +304 -0
  167. package/cli/transfer.ts +677 -0
  168. package/cli/up.ts +27 -0
  169. package/cli/upgrade.ts +60 -0
  170. package/cli/versions.ts +60 -0
  171. package/forms/components/CmsForm.vue +186 -0
  172. package/forms/index.ts +203 -0
  173. package/forms/messages.ts +104 -0
  174. package/forms/retention.ts +48 -0
  175. package/forms/server/form.get.ts +12 -0
  176. package/forms/server/form.post.ts +109 -0
  177. package/forms/server/formSettings.ts +12 -0
  178. package/forms/server/forms.ts +127 -0
  179. package/module.ts +373 -0
  180. package/nuxt.config.ts +43 -0
  181. package/package.json +99 -3
  182. package/server/api/cms/[entity]/[id]/revisions/[rev].get.ts +19 -0
  183. package/server/api/cms/[entity]/[id]/revisions/index.get.ts +14 -0
  184. package/server/api/cms/[entity]/[id].delete.ts +52 -0
  185. package/server/api/cms/[entity]/[id].get.ts +21 -0
  186. package/server/api/cms/[entity]/[id].patch.ts +116 -0
  187. package/server/api/cms/[entity]/_export.get.ts +69 -0
  188. package/server/api/cms/[entity]/_move.post.ts +81 -0
  189. package/server/api/cms/[entity]/_order.post.ts +49 -0
  190. package/server/api/cms/[entity]/_tree.get.ts +41 -0
  191. package/server/api/cms/[entity]/index.get.ts +62 -0
  192. package/server/api/cms/[entity]/index.post.ts +38 -0
  193. package/server/api/cms/[entity]/options.get.ts +55 -0
  194. package/server/api/cms/_auth/accept.post.ts +33 -0
  195. package/server/api/cms/_auth/forgot.post.ts +39 -0
  196. package/server/api/cms/_auth/invite/[token].get.ts +18 -0
  197. package/server/api/cms/_auth/login.post.ts +42 -0
  198. package/server/api/cms/_auth/logout.post.ts +7 -0
  199. package/server/api/cms/_auth/me.get.ts +5 -0
  200. package/server/api/cms/_auth/me.patch.ts +32 -0
  201. package/server/api/cms/_auth/password.post.ts +29 -0
  202. package/server/api/cms/_auth/reset.post.ts +34 -0
  203. package/server/api/cms/_auth/setup.post.ts +46 -0
  204. package/server/api/cms/_auth/status.get.ts +18 -0
  205. package/server/api/cms/_collab/session.get.ts +30 -0
  206. package/server/api/cms/_collab/socket.ts +51 -0
  207. package/server/api/cms/_collab/unsaved.delete.ts +16 -0
  208. package/server/api/cms/_graph.get.ts +20 -0
  209. package/server/api/cms/_links/resolve.post.ts +17 -0
  210. package/server/api/cms/_links.get.ts +81 -0
  211. package/server/api/cms/_live.ts +30 -0
  212. package/server/api/cms/_media/[id]/usage.get.ts +14 -0
  213. package/server/api/cms/_media/[id].delete.ts +29 -0
  214. package/server/api/cms/_media/[id].get.ts +13 -0
  215. package/server/api/cms/_media/[id].patch.ts +64 -0
  216. package/server/api/cms/_media/exists.post.ts +15 -0
  217. package/server/api/cms/_media/img/[id]/[file].get.ts +42 -0
  218. package/server/api/cms/_media/index.get.ts +44 -0
  219. package/server/api/cms/_media/index.post.ts +147 -0
  220. package/server/api/cms/_media/raw/[...key].get.ts +85 -0
  221. package/server/api/cms/_media/raw/[...key].head.ts +2 -0
  222. package/server/api/cms/_overview.get.ts +87 -0
  223. package/server/api/cms/_preview.post.ts +17 -0
  224. package/server/api/cms/_privacy/delete.post.ts +14 -0
  225. package/server/api/cms/_privacy/export.post.ts +25 -0
  226. package/server/api/cms/_privacy/lookup.post.ts +27 -0
  227. package/server/api/cms/_search.get.ts +17 -0
  228. package/server/api/cms/_singleton/[name].get.ts +19 -0
  229. package/server/api/cms/_singleton/[name].put.ts +76 -0
  230. package/server/api/cms/_users/[id]/resend.post.ts +25 -0
  231. package/server/api/cms/_users/[id].delete.ts +21 -0
  232. package/server/api/cms/_users/[id].patch.ts +45 -0
  233. package/server/api/cms/_users/index.get.ts +28 -0
  234. package/server/api/cms/_users/index.post.ts +39 -0
  235. package/server/api/content/[entity]/[slug].get.ts +74 -0
  236. package/server/api/content/[entity]/index.get.ts +100 -0
  237. package/server/api/content/_global/[name].get.ts +23 -0
  238. package/server/api/content/_search.get.ts +28 -0
  239. package/server/api/content/_sitemap.get.ts +8 -0
  240. package/server/api/content/_tree/[entity].get.ts +31 -0
  241. package/server/api/content-types.ts.get.ts +17 -0
  242. package/server/api/health/live.get.ts +10 -0
  243. package/server/api/health/ready.get.ts +21 -0
  244. package/server/api/openapi.get.ts +48 -0
  245. package/server/api/openapi.json.get.ts +32 -0
  246. package/server/db/driver.ts +8 -0
  247. package/server/mail/mailer.ts +43 -0
  248. package/server/middleware/cms-0-headers.ts +37 -0
  249. package/server/middleware/cms-0-migrate-gate.ts +14 -0
  250. package/server/middleware/cms-csrf.ts +28 -0
  251. package/server/middleware/cms-limits.ts +20 -0
  252. package/server/middleware/cms-redirects.ts +21 -0
  253. package/server/middleware/cms-session.ts +41 -0
  254. package/server/middleware/cms-z-plugin-access.ts +15 -0
  255. package/server/plugins/cms-0-config-check.ts +35 -0
  256. package/server/plugins/cms-changes.ts +53 -0
  257. package/server/plugins/cms-content-etag.ts +21 -0
  258. package/server/plugins/cms-errors.ts +45 -0
  259. package/server/plugins/cms-migrate.ts +5 -0
  260. package/server/plugins/cms-plugins.ts +17 -0
  261. package/server/plugins/cms-search.ts +12 -0
  262. package/server/plugins/cms-setup-code.ts +15 -0
  263. package/server/routes/sitemap.xml.get.ts +25 -0
  264. package/server/store/redis.ts +95 -0
  265. package/server/store/types.ts +21 -0
  266. package/server/tasks/cms/retention.ts +10 -0
  267. package/server/tasks/cms/scheduled.ts +10 -0
  268. package/server/tasks/cms/search-reindex.ts +12 -0
  269. package/server/utils/cmsAudit.ts +29 -0
  270. package/server/utils/cmsAuth.ts +143 -0
  271. package/server/utils/cmsBlocks.ts +47 -0
  272. package/server/utils/cmsChanges.ts +222 -0
  273. package/server/utils/cmsCollab.ts +286 -0
  274. package/server/utils/cmsCollabServer.ts +451 -0
  275. package/server/utils/cmsCollate.ts +27 -0
  276. package/server/utils/cmsContent.ts +376 -0
  277. package/server/utils/cmsCrud.ts +361 -0
  278. package/server/utils/cmsCsv.ts +24 -0
  279. package/server/utils/cmsDb.ts +23 -0
  280. package/server/utils/cmsDemo.ts +36 -0
  281. package/server/utils/cmsEmails.ts +125 -0
  282. package/server/utils/cmsErrors.ts +40 -0
  283. package/server/utils/cmsFold.ts +17 -0
  284. package/server/utils/cmsImageSizes.ts +51 -0
  285. package/server/utils/cmsJson.ts +6 -0
  286. package/server/utils/cmsLinkAddress.ts +50 -0
  287. package/server/utils/cmsLinks.ts +248 -0
  288. package/server/utils/cmsListQuery.ts +93 -0
  289. package/server/utils/cmsLive.ts +392 -0
  290. package/server/utils/cmsLocales.ts +96 -0
  291. package/server/utils/cmsMail.ts +28 -0
  292. package/server/utils/cmsMediaGc.ts +188 -0
  293. package/server/utils/cmsMediaKeys.ts +62 -0
  294. package/server/utils/cmsMigrate.ts +86 -0
  295. package/server/utils/cmsPreviewDraft.ts +72 -0
  296. package/server/utils/cmsPrivacy.ts +176 -0
  297. package/server/utils/cmsPublished.ts +57 -0
  298. package/server/utils/cmsRange.ts +38 -0
  299. package/server/utils/cmsRateLimit.ts +82 -0
  300. package/server/utils/cmsRedirects.ts +160 -0
  301. package/server/utils/cmsRetention.ts +61 -0
  302. package/server/utils/cmsRevisions.ts +103 -0
  303. package/server/utils/cmsScheduler.ts +45 -0
  304. package/server/utils/cmsScrub.ts +107 -0
  305. package/server/utils/cmsSearch.ts +354 -0
  306. package/server/utils/cmsSession.ts +102 -0
  307. package/server/utils/cmsSetupCode.ts +97 -0
  308. package/server/utils/cmsSitemap.ts +176 -0
  309. package/server/utils/cmsStorage.ts +580 -0
  310. package/server/utils/cmsStore.ts +109 -0
  311. package/server/utils/cmsTooMany.ts +9 -0
  312. package/server/utils/cmsTranslationWrite.ts +186 -0
  313. package/server/utils/cmsTree.ts +251 -0
  314. package/server/utils/cmsTreeAddress.ts +65 -0
  315. package/server/utils/cmsUpload.ts +197 -0
  316. package/server/utils/cmsWebhooks.ts +101 -0
  317. package/shared/json.ts +11 -0
  318. package/shared/richtext-editor.ts +56 -0
  319. package/shared/richtext-normalize.ts +33 -0
  320. package/shared/richtext-paste.ts +151 -0
  321. package/shared/storage-delivery.ts +53 -0
  322. package/src/blocks.ts +624 -0
  323. package/src/changes.ts +54 -0
  324. package/src/content-shape.ts +340 -0
  325. package/src/deprecate.ts +64 -0
  326. package/src/descriptor.ts +149 -0
  327. package/src/docs.ts +27 -0
  328. package/src/emitter.ts +94 -0
  329. package/src/entity.ts +624 -0
  330. package/src/errorReport.ts +41 -0
  331. package/src/fields.ts +465 -0
  332. package/src/i18n.ts +26 -0
  333. package/src/index.ts +54 -0
  334. package/src/linkref.ts +31 -0
  335. package/src/links.ts +179 -0
  336. package/src/locales.ts +39 -0
  337. package/src/media.ts +48 -0
  338. package/src/migrate.ts +236 -0
  339. package/src/openapi.ts +377 -0
  340. package/src/paths.ts +88 -0
  341. package/src/plugin.ts +505 -0
  342. package/src/presets.ts +230 -0
  343. package/src/richtext.ts +88 -0
  344. package/src/sdk.ts +181 -0
  345. package/src/search.ts +312 -0
  346. package/src/seed.ts +225 -0
  347. package/src/setupCode.ts +30 -0
  348. package/src/system.ts +219 -0
  349. package/src/tree.ts +421 -0
  350. package/src/upgrades.ts +137 -0
  351. package/starter/.env.example +10 -0
  352. package/starter/README.md +65 -0
  353. package/starter/app/app.config.ts +10 -0
  354. package/starter/app/app.vue +12 -0
  355. package/starter/app/assets/css/main.css +15 -0
  356. package/starter/app/components/global/BlockContact.vue +15 -0
  357. package/starter/app/components/global/BlockCta.vue +15 -0
  358. package/starter/app/components/global/BlockHero.vue +23 -0
  359. package/starter/app/components/global/BlockImage.vue +13 -0
  360. package/starter/app/components/global/BlockText.vue +12 -0
  361. package/starter/app/composables/useSite.ts +77 -0
  362. package/starter/app/error.vue +28 -0
  363. package/starter/app/layouts/default.vue +106 -0
  364. package/starter/app/lib/cms-content.ts +152 -0
  365. package/starter/app/pages/[...slug].vue +66 -0
  366. package/starter/app/pages/hledat.vue +59 -0
  367. package/starter/app/pages/index.vue +20 -0
  368. package/starter/cms.config.ts +137 -0
  369. package/starter/compose.yaml +15 -0
  370. package/starter/drizzle.config.ts +8 -0
  371. package/starter/gitignore.txt +8 -0
  372. package/starter/nuxt.config.ts +13 -0
  373. package/starter/package.json +38 -0
  374. package/starter/scripts/typecheck.mjs +38 -0
  375. package/starter/seed/index.ts +297 -0
  376. package/starter/seed/media/about.jpg +0 -0
  377. package/starter/seed/media/hero.jpg +0 -0
  378. package/starter/seed/media/logo.png +0 -0
  379. package/starter/seed/media/news-bread.jpg +0 -0
  380. package/starter/seed/media/news-morning.jpg +0 -0
  381. package/starter/server/db/migrations/0000_init.sql +269 -0
  382. package/starter/server/db/migrations/0001_page_tree.sql +5 -0
  383. package/starter/server/db/migrations/0002_opening_hours_per_language.sql +1 -0
  384. package/starter/server/db/migrations/meta/0000_snapshot.json +1890 -0
  385. package/starter/server/db/migrations/meta/0001_snapshot.json +1887 -0
  386. package/starter/server/db/migrations/meta/0002_snapshot.json +1893 -0
  387. package/starter/server/db/migrations/meta/_journal.json +27 -0
  388. package/starter/server/db/schema.ts +253 -0
  389. package/starter/server/plugins/sitemap.ts +11 -0
  390. package/starter/server/routes/robots.txt.get.ts +12 -0
  391. package/starter/tsconfig.json +9 -0
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Upgrade steps: the data work of an upgrade that a schema migration cannot express.
3
+ *
4
+ * `tinyzoo generate` only writes the schema half of a change (`ALTER TABLE …`). When a
5
+ * change also needs data — a backfill, an extension, rows that must exist — the package
6
+ * ships a step for it, and every site picks it up the same way: at start
7
+ * (`NUXT_CMS_MIGRATIONS_ON_START`) or with `tinyzoo up`, inside the same transaction
8
+ * and advisory lock as the site's own migrations. See docs/upgrading.md ("For tinyzoo
9
+ * maintainers") for when to write one.
10
+ *
11
+ * Bookkeeping lives in `cms_upgrades`, created by the runner itself with
12
+ * `CREATE TABLE IF NOT EXISTS`. It is package-owned bookkeeping, like drizzle's
13
+ * `__drizzle_migrations`, and is deliberately NOT emitted into the host's schema.ts:
14
+ * it has to exist before the first host migration runs (a `before` step may be what
15
+ * makes that migration possible), a host migration would only be able to create it
16
+ * after the fact, and a host that drops or renames it would silently re-run every
17
+ * step. (Do not use `drizzle-kit push` on a site: it would propose dropping it.)
18
+ */
19
+ import type { SqlRunner } from './migrate'
20
+ import { pluginUpgradeSteps } from './plugin'
21
+
22
+ export interface UpgradeContext {
23
+ /** Runs SQL inside the migration transaction (and under its advisory lock). */
24
+ run: SqlRunner
25
+ /**
26
+ * Every statement of the host migrations this run applies (empty when there is
27
+ * nothing to apply) — what `when` looks at to tell whether a step matters now.
28
+ */
29
+ pendingStatements: string[]
30
+ /** No host migration had been applied before this run: an empty database. */
31
+ freshInstall: boolean
32
+ }
33
+
34
+ export interface UpgradeStep {
35
+ /** Stable and unique, kebab-case (`<plugin>:<id>` for a plugin's step). Never change it once released: it is what gets recorded. */
36
+ id: string
37
+ /** The version that introduced the step: tinyzoo's, or the plugin's own for a plugin's step. */
38
+ since: string
39
+ /** One line, plain language: what the step does and why. */
40
+ description: string
41
+ /** `before`: ahead of the site's pending migrations. `after`: once they have been applied. */
42
+ phase: 'before' | 'after'
43
+ /**
44
+ * On an empty database a step is recorded as applied without running (a backfill
45
+ * has nothing to fill). Set `'run'` for a step the migrations themselves depend on,
46
+ * such as enabling an extension.
47
+ */
48
+ freshInstall?: 'skip' | 'run'
49
+ /**
50
+ * Whether the step matters in this run. A step without `when` runs once and is
51
+ * then recorded. A step with `when` runs every time `when` is true — so it must be
52
+ * idempotent — because a later migration may need it again.
53
+ */
54
+ when?: (ctx: UpgradeContext) => boolean | Promise<boolean>
55
+ /** Must be idempotent: running it twice leaves the same result as once. */
56
+ run: (ctx: UpgradeContext) => void | Promise<void>
57
+ }
58
+
59
+ export interface StepOutcome {
60
+ id: string
61
+ /** false: recorded as applied without running (fresh install). */
62
+ ran: boolean
63
+ }
64
+
65
+ /** Package-owned bookkeeping table; see the header comment. */
66
+ export const UPGRADES_TABLE_SQL = 'CREATE TABLE IF NOT EXISTS "cms_upgrades" ("id" text PRIMARY KEY, "since" text, "applied_at" timestamptz DEFAULT now())'
67
+
68
+ // tinyzoo's own steps are `kebab-case`; a plugin's are `<plugin>:<kebab-case>` (see plugin.ts).
69
+ const STEP_ID = /^([a-z][a-z0-9]*(-[a-z0-9]+)*:)?[a-z0-9][a-z0-9-]*$/
70
+
71
+ /** Throws on a malformed or duplicated step; plugins hand in their own lists. */
72
+ export function assertValidSteps(steps: UpgradeStep[]): void {
73
+ const seen = new Set<string>()
74
+ for (const s of steps) {
75
+ if (!STEP_ID.test(s.id)) throw new Error(`Upgrade step id "${s.id}" must be kebab-case (letters, digits, dashes)`)
76
+ if (seen.has(s.id)) throw new Error(`Two upgrade steps share the id "${s.id}"`)
77
+ seen.add(s.id)
78
+ if (s.phase !== 'before' && s.phase !== 'after') throw new Error(`Upgrade step "${s.id}" needs phase 'before' or 'after'`)
79
+ }
80
+ }
81
+
82
+ /** Is the step relevant now, given what has been recorded? (Used by the runner and by `status`.) */
83
+ export async function stepIsDue(step: UpgradeStep, ctx: UpgradeContext, done: ReadonlySet<string>): Promise<boolean> {
84
+ if (step.when) return Boolean(await step.when(ctx))
85
+ return !done.has(step.id)
86
+ }
87
+
88
+ /**
89
+ * Run the steps of one phase in list order. Steps already recorded are skipped (unless
90
+ * they have a `when`, which decides every time); on a fresh install they are recorded
91
+ * without running unless they set `freshInstall: 'run'`.
92
+ */
93
+ export async function runUpgradeSteps(
94
+ phase: UpgradeStep['phase'],
95
+ steps: UpgradeStep[],
96
+ ctx: UpgradeContext,
97
+ done: Set<string>,
98
+ ): Promise<StepOutcome[]> {
99
+ const outcomes: StepOutcome[] = []
100
+ for (const step of steps) {
101
+ if (step.phase !== phase) continue
102
+ if (!(await stepIsDue(step, ctx, done))) continue
103
+ const ran = !ctx.freshInstall || step.freshInstall === 'run'
104
+ if (ran) await step.run(ctx)
105
+ if (!done.has(step.id)) {
106
+ await ctx.run('insert into "cms_upgrades" ("id", "since") values ($1, $2) on conflict ("id") do nothing', [step.id, step.since])
107
+ done.add(step.id)
108
+ }
109
+ outcomes.push({ id: step.id, ran })
110
+ }
111
+ return outcomes
112
+ }
113
+
114
+ /**
115
+ * The steps tinyzoo itself ships. Plugins contribute theirs next to these (namespaced
116
+ * `<plugin>:<id>`, see `pluginUpgradeSteps`; `allUpgradeSteps` is the whole list); the
117
+ * runner takes it as a parameter.
118
+ */
119
+ export const CORE_UPGRADE_STEPS: UpgradeStep[] = [
120
+ {
121
+ id: 'enable-pg-trgm',
122
+ since: '0.2.0',
123
+ description: 'Enable the pg_trgm extension that the search index needs',
124
+ phase: 'before',
125
+ // The first migration of a new site may already create a trigram index.
126
+ freshInstall: 'run',
127
+ // Trigram indexes (the search index) need pg_trgm: a trusted extension the database
128
+ // owner may enable, shipped with standard Postgres images (CloudNativePG included).
129
+ when: ({ pendingStatements }) => pendingStatements.some((s) => s.includes('gin_trgm_ops')),
130
+ run: async ({ run }) => { await run('CREATE EXTENSION IF NOT EXISTS pg_trgm') },
131
+ },
132
+ ]
133
+
134
+ /** tinyzoo's steps and those of the plugins, in that order (plugins in registration order). */
135
+ export function allUpgradeSteps(plugins: readonly import('./plugin').CmsPlugin[] = []): UpgradeStep[] {
136
+ return [...CORE_UPGRADE_STEPS, ...pluginUpgradeSteps(plugins)]
137
+ }
@@ -0,0 +1,10 @@
1
+ # Copy to .env for development.
2
+ DATABASE_URL=postgres://site:site@localhost:5433/site
3
+ # At least 32 characters; signs the admin's sessions.
4
+ NUXT_SESSION_PASSWORD=change-me-to-a-long-random-string-32-chars-min
5
+ # The website's address (emails, sitemap). In development it comes from the request.
6
+ # NUXT_CMS_PUBLIC_URL=https://www.example.cz
7
+ # Who hears about new form messages when nobody is set in the admin.
8
+ # NUXT_CMS_FORMS_NOTIFY_TO=office@example.cz
9
+ # The port the database in compose.yaml is published on (default 5433). Change it together with the port in DATABASE_URL.
10
+ # SITE_PG_PORT=5433
@@ -0,0 +1,65 @@
1
+ # A website with tinyzoo
2
+
3
+ The website and its CMS in one Nuxt app. Editors work at **/admin**; the pages read
4
+ the content from the CMS.
5
+
6
+ ## Start
7
+
8
+ ```bash
9
+ pnpm install
10
+ cp .env.example .env
11
+ docker compose up -d # the database
12
+ pnpm db:migrate # create the tables
13
+ pnpm dev # → http://localhost:3000/admin
14
+ ```
15
+
16
+ The first visit to `/admin` creates the first administrator.
17
+
18
+ **Demo content.** The starter comes with a small bakery's content in Czech and English
19
+ (`seed/index.ts`: pages, news, menus, settings, pictures). With `pnpm dev` running, in a
20
+ second terminal:
21
+
22
+ ```bash
23
+ SEED_EMAIL=you@example.com SEED_PASSWORD='a long password' pnpm seed
24
+ ```
25
+
26
+ On a new site this creates the first administrator with those details (after the first
27
+ visit to `/admin`, use that account's). Running it again changes nothing; `pnpm seed
28
+ --dry-run` shows what it would do and `pnpm seed --reset` removes the demo content and
29
+ writes it fresh. Replace the texts and pictures with your own, or delete `seed/` when the
30
+ site has its real content.
31
+
32
+ Without the demo content, make the first content yourself:
33
+
34
+ 1. **Pages** → create a page with the address `home`. It becomes the home page.
35
+ 2. **Navigation** → add links to the main menu (pick pages instead of typing addresses).
36
+ 3. **Site settings** → name, contacts, opening hours.
37
+ 4. **Forms** → who gets an email about messages from the contact form.
38
+
39
+ ## Change what editors can write
40
+
41
+ Everything editors can write is in `cms.config.ts`. After a change:
42
+
43
+ ```bash
44
+ pnpm db:generate # writes the SQL for the change (review it)
45
+ pnpm db:migrate # applies it
46
+ pnpm cms:client # the typed client (app/lib/cms-content.ts)
47
+ ```
48
+
49
+ The block components are typed from that client: rename a block's field and `pnpm typecheck`
50
+ points at every component that still uses the old name.
51
+
52
+ ## Where things are
53
+
54
+ | | |
55
+ |---|---|
56
+ | `cms.config.ts` | content model: settings, pages and their blocks, news, menus, forms |
57
+ | `app/components/global/Block*.vue` | how each block looks (`hero` → `BlockHero.vue`) |
58
+ | `app/pages/[...slug].vue` | pages, the news list and news items, in Czech and English |
59
+ | `app/layouts/default.vue` | header with the menu and the language switcher, footer with contacts and opening hours |
60
+ | `app/composables/useSite.ts` | the visitor's language, the site settings and menus, the page being shown, the language switcher |
61
+ | `server/plugins/sitemap.ts`, `server/routes/robots.txt.get.ts` | the home page as `/` in the sitemap; `robots.txt` |
62
+ | `seed/index.ts`, `seed/media/` | the demo content and its pictures (`pnpm seed`) |
63
+
64
+ Components from the CMS you can use anywhere: `<CmsBlocks>`, `<CmsImage>`,
65
+ `<CmsContent>` (rich text), `<CmsNav>`, `<CmsForm>`, and `useCmsSeo()`.
@@ -0,0 +1,10 @@
1
+ export default defineAppConfig({
2
+ cms: {
3
+ // The admin's name (top left) and languages. Change to the client's name.
4
+ admin: {
5
+ name: { en: 'My website', cs: 'Můj web' },
6
+ siteUrl: '/',
7
+ defaultLocale: 'cs',
8
+ },
9
+ },
10
+ })
@@ -0,0 +1,12 @@
1
+ <script setup lang="ts">
2
+ // Nuxt UI's own words ("Close", "Previous month"…) follow the admin's language on /admin pages.
3
+ const uiLocale = useCmsUiLocale()
4
+ </script>
5
+
6
+ <template>
7
+ <UApp :locale="uiLocale">
8
+ <NuxtLayout>
9
+ <NuxtPage />
10
+ </NuxtLayout>
11
+ </UApp>
12
+ </template>
@@ -0,0 +1,15 @@
1
+ @import "tailwindcss";
2
+ @import "@nuxt/ui";
3
+
4
+ /* Tailwind must also scan the CMS's own components (the admin, <CmsForm>…). */
5
+ @source "../../../node_modules/tinyzoo/app";
6
+
7
+ /* The website's look: change freely. The admin keeps its own. */
8
+ @theme {
9
+ --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
10
+ }
11
+
12
+ /* Long words and addresses wrap instead of pushing the page wider on phones. */
13
+ @layer base {
14
+ h1, h2, h3, p, li, dd, figcaption { overflow-wrap: anywhere; }
15
+ }
@@ -0,0 +1,15 @@
1
+ <script setup lang="ts">
2
+ // Block "Contact form": the ContactForm from cms.config.ts; messages arrive in the admin.
3
+ // Typed from the generated client (see BlockHero.vue).
4
+ import type { Page } from '~/lib/cms-content'
5
+
6
+ defineProps<{ block: Extract<Page['sections'][number], { type: 'contact' }> }>()
7
+ const locale = useSiteLocale()
8
+ </script>
9
+
10
+ <template>
11
+ <section class="mx-auto max-w-xl px-4 py-12">
12
+ <h2 v-if="block.heading" class="text-2xl font-semibold mb-6">{{ block.heading }}</h2>
13
+ <CmsForm name="contactForm" :locale="locale" />
14
+ </section>
15
+ </template>
@@ -0,0 +1,15 @@
1
+ <script setup lang="ts">
2
+ // Block "Call to action": a heading and one button. Typed from the generated client (see BlockHero.vue).
3
+ import type { Page } from '~/lib/cms-content'
4
+
5
+ defineProps<{ block: Extract<Page['sections'][number], { type: 'cta' }> }>()
6
+ </script>
7
+
8
+ <template>
9
+ <section class="mx-auto max-w-5xl px-4 py-12">
10
+ <div class="flex flex-col items-start gap-4 rounded-2xl bg-inverted px-8 py-10 text-inverted sm:flex-row sm:items-center sm:justify-between">
11
+ <h2 class="text-2xl font-semibold">{{ block.heading }}</h2>
12
+ <UButton v-if="block.buttonUrl" :to="siteHref(block.buttonUrl)" color="neutral" variant="solid" size="lg" class="bg-default text-highlighted hover:bg-default/90">{{ block.buttonLabel }}</UButton>
13
+ </div>
14
+ </section>
15
+ </template>
@@ -0,0 +1,23 @@
1
+ <script setup lang="ts">
2
+ // Block "Opening" (hero): see cms.config.ts. Change the look freely.
3
+ // The props come from the generated client (app/lib/cms-content.ts, `pnpm cms:client`): rename
4
+ // or remove a field in cms.config.ts, regenerate, and this file stops type-checking until
5
+ // the template follows.
6
+ import type { Page } from '~/lib/cms-content'
7
+
8
+ defineProps<{ block: Extract<Page['sections'][number], { type: 'hero' }> }>()
9
+ </script>
10
+
11
+ <template>
12
+ <section class="relative overflow-hidden bg-muted/40">
13
+ <div class="mx-auto grid max-w-5xl items-center gap-8 px-4 py-16 md:grid-cols-2">
14
+ <div>
15
+ <h1 class="text-4xl font-bold leading-tight sm:text-5xl">{{ block.heading }}</h1>
16
+ <p v-if="block.text" class="mt-4 text-lg text-muted whitespace-pre-line">{{ block.text }}</p>
17
+ <UButton v-if="block.buttonLabel && block.buttonUrl" :to="siteHref(block.buttonUrl)" size="lg" class="mt-6">{{ block.buttonLabel }}</UButton>
18
+ </div>
19
+ <!-- from md up the picture fills half of a 64rem column (about 30rem), below that the screen -->
20
+ <CmsImage v-if="block.image" :media="block.image" eager sizes="(min-width: 768px) 30rem, 100vw" class="aspect-[4/3] w-full rounded-xl object-cover" />
21
+ </div>
22
+ </section>
23
+ </template>
@@ -0,0 +1,13 @@
1
+ <script setup lang="ts">
2
+ // Block "Picture": one picture with a caption. Typed from the generated client (see BlockHero.vue).
3
+ import type { Page } from '~/lib/cms-content'
4
+
5
+ defineProps<{ block: Extract<Page['sections'][number], { type: 'image' }> }>()
6
+ </script>
7
+
8
+ <template>
9
+ <figure v-if="block.image" class="mx-auto max-w-5xl px-4 py-8">
10
+ <CmsImage :media="block.image" sizes="(min-width: 1024px) 62rem, 100vw" class="w-full rounded-xl" />
11
+ <figcaption v-if="block.caption" class="mt-2 text-sm text-muted text-center">{{ block.caption }}</figcaption>
12
+ </figure>
13
+ </template>
@@ -0,0 +1,12 @@
1
+ <script setup lang="ts">
2
+ // Block "Text": rich text written in the admin. Typed from the generated client (see BlockHero.vue).
3
+ import type { Page } from '~/lib/cms-content'
4
+
5
+ defineProps<{ block: Extract<Page['sections'][number], { type: 'text' }> }>()
6
+ </script>
7
+
8
+ <template>
9
+ <section class="mx-auto max-w-5xl px-4 py-10">
10
+ <CmsContent :doc="block.body" class="prose max-w-3xl" />
11
+ </section>
12
+ </template>
@@ -0,0 +1,77 @@
1
+ // The visitor's language (from the address: /en/… is English) and the site-wide
2
+ // content every page needs: settings and menus. Fetched once, shared by all pages.
3
+ export function useSiteLocale() {
4
+ const route = useRoute()
5
+ return computed(() => (route.path === '/en' || route.path.startsWith('/en/') ? 'en' : 'cs'))
6
+ }
7
+
8
+ export async function useSite() {
9
+ const locale = useSiteLocale()
10
+ const [{ data: settings }, { data: nav }] = await Promise.all([
11
+ useFetch<{ item: any }>('/api/content/_global/siteSettings', { query: { locale }, key: 'site-settings' }),
12
+ useFetch<{ item: any }>('/api/content/_global/navigation', { query: { locale }, key: 'site-nav' }),
13
+ ])
14
+ return { locale, settings: computed(() => settings.value?.item ?? null), nav: computed(() => nav.value?.item ?? null) }
15
+ }
16
+
17
+ // The site's languages, as in `locales` of cms.config.ts (add a language in both places).
18
+ // `home` is the address of the home page in that language.
19
+ export const SITE_LANGUAGES = [
20
+ { code: 'cs', label: 'Čeština', home: '/', news: '/aktuality', search: '/hledat' },
21
+ { code: 'en', label: 'English', home: '/en', news: '/en/news', search: '/en/search' },
22
+ ] as const
23
+
24
+ /** An address from the content API as the website writes it: the home page (address `home`) is `/`, or `/en`. */
25
+ export function siteHref(path: string): string {
26
+ return path.replace(/^((?:\/[a-z]{2})?)\/home$/, '$1') || '/'
27
+ }
28
+
29
+ /**
30
+ * The page the visitor is on: a page from blocks (/o-nas, /en/about), the news list or one
31
+ * news item, read from the content API. The page, and the language switcher in the layout,
32
+ * ask for it with the same key, so it is fetched once.
33
+ */
34
+ export async function useSitePage() {
35
+ const route = useRoute()
36
+ const locale = useSiteLocale()
37
+ // Only the addresses [...slug].vue and index.vue draw; /hledat and the error page have nothing to read.
38
+ const reads = computed(() => route.name === 'slug' || route.name === 'index')
39
+ const parts = computed(() => {
40
+ const all = ([] as string[]).concat(route.params.slug ?? []).filter(Boolean)
41
+ return locale.value === 'en' ? all.slice(1) : all
42
+ })
43
+ const newsBase = computed(() => (locale.value === 'en' ? 'news' : 'aktuality'))
44
+ const kind = computed<'page' | 'news' | 'article'>(() => (parts.value[0] === newsBase.value ? (parts.value[1] ? 'article' : 'news') : 'page'))
45
+ const url = computed(() => kind.value === 'news'
46
+ ? '/api/content/news'
47
+ : kind.value === 'article' ? `/api/content/news/${parts.value[1]}` : `/api/content/page/${encodeURIComponent(parts.value.join('/') || 'home')}`)
48
+ // A draft is previewed with ?preview, which has to survive every redirect on the way.
49
+ const query = computed(() => ({
50
+ locale: locale.value,
51
+ ...('preview' in route.query ? { preview: '' } : {}),
52
+ ...(kind.value === 'news' ? { sort: 'publishedAt', limit: 20 } : {}),
53
+ }))
54
+ const { data, error } = await useAsyncData<any>(
55
+ () => `site:${route.fullPath}`,
56
+ // (the address is built from the visitor's: not one of the typed internal routes)
57
+ () => (reads.value ? ($fetch as (url: string, opts: { query: Record<string, unknown> }) => Promise<any>)(url.value, { query: query.value }) : Promise.resolve(null)),
58
+ )
59
+ return { parts, kind, data, error, reads, item: computed(() => (kind.value === 'news' ? null : data.value?.item ?? null)) }
60
+ }
61
+
62
+ /**
63
+ * The language switcher: for each language, the same page in it (an address the content API
64
+ * gives as the item's `paths`), else that language's home page.
65
+ */
66
+ export async function useLanguageSwitch() {
67
+ const route = useRoute()
68
+ const locale = useSiteLocale()
69
+ const { kind, item, reads } = await useSitePage()
70
+ return computed(() => SITE_LANGUAGES.map((l) => {
71
+ let href: string = l.home
72
+ if (reads.value && kind.value === 'news') href = l.news
73
+ else if (reads.value && item.value?.paths?.[l.code]) href = siteHref(item.value.paths[l.code])
74
+ else if (route.name === 'hledat') href = l.search + (route.query.q ? `?q=${encodeURIComponent(String(route.query.q))}` : '')
75
+ return { ...l, href, current: l.code === locale.value }
76
+ }))
77
+ }
@@ -0,0 +1,28 @@
1
+ <script setup lang="ts">
2
+ // The website's error page (a missing address, a server error), inside the site's own
3
+ // header and footer, in the visitor's language.
4
+ import type { NuxtError } from '#app'
5
+
6
+ const props = defineProps<{ error: NuxtError }>()
7
+ const route = useRoute()
8
+ const en = computed(() => route.path === '/en' || route.path.startsWith('/en/'))
9
+ const missing = computed(() => props.error.statusCode === 404)
10
+ useHead({ title: () => (missing.value ? (en.value ? 'Page not found' : 'Stránka nenalezena') : (en.value ? 'Something went wrong' : 'Něco se pokazilo')) })
11
+ </script>
12
+
13
+ <template>
14
+ <UApp>
15
+ <NuxtLayout>
16
+ <section class="mx-auto max-w-2xl px-4 py-24 text-center">
17
+ <p class="text-sm font-semibold text-muted">{{ error.statusCode }}</p>
18
+ <h1 class="mt-2 text-3xl font-bold">
19
+ {{ missing ? (en ? 'This page doesn’t exist' : 'Tahle stránka tu není') : (en ? 'Something went wrong' : 'Něco se pokazilo') }}
20
+ </h1>
21
+ <p class="mt-3 text-muted">
22
+ {{ missing ? (en ? 'It may have moved, or the address has a typo.' : 'Možná se přesunula, nebo je v adrese překlep.') : (en ? 'Please try again in a moment.' : 'Zkuste to prosím za chvíli znovu.') }}
23
+ </p>
24
+ <UButton class="mt-8" size="lg" @click="clearError({ redirect: en ? '/en' : '/' })">{{ en ? 'Go to the home page' : 'Na úvodní stránku' }}</UButton>
25
+ </section>
26
+ </NuxtLayout>
27
+ </UApp>
28
+ </template>
@@ -0,0 +1,106 @@
1
+ <script setup lang="ts">
2
+ const { locale, settings, nav } = await useSite()
3
+ const languages = await useLanguageSwitch()
4
+ // A link the editor picked from the pages leads to the page's address; the home page is / here, not /home.
5
+ const menu = <T extends { url: string | null }>(links: T[] | null | undefined): T[] => (links ?? []).map((l) => ({ ...l, url: l.url ? siteHref(l.url) : l.url }))
6
+ const home = computed(() => (locale.value === 'en' ? '/en' : '/'))
7
+ // A long menu (more than five links) gets a row of its own under the logo instead of squeezing the header.
8
+ const wide = computed(() => (nav.value?.main ?? []).filter((l: any) => !l.sub).length > 5)
9
+ // Phones: the menu folds behind a button; it closes again on every page change.
10
+ const menuOpen = ref(false)
11
+ const route = useRoute()
12
+ watch(() => route.fullPath, () => { menuOpen.value = false })
13
+ useHead({ htmlAttrs: { lang: locale } })
14
+ </script>
15
+
16
+ <template>
17
+ <div class="min-h-dvh flex flex-col">
18
+ <header class="border-b border-default">
19
+ <div class="site-header relative mx-auto flex max-w-5xl flex-wrap items-center justify-between gap-x-6 gap-y-2 px-4 py-4" :class="wide ? 'site-header--wide' : ''">
20
+ <NuxtLink :to="home" class="flex items-center gap-2 font-semibold">
21
+ <CmsImage v-if="settings?.logo" :media="settings.logo" class="h-8 w-auto" eager />
22
+ <span>{{ settings?.siteName ?? 'Web' }}</span>
23
+ </NuxtLink>
24
+ <div class="ml-auto flex items-center gap-1 sm:order-last sm:ml-0">
25
+ <nav v-if="languages.length > 1" class="flex items-center text-sm" :aria-label="locale === 'en' ? 'Language' : 'Jazyk'">
26
+ <NuxtLink
27
+ v-for="l in languages" :key="l.code" :to="l.href" :lang="l.code" :hreflang="l.code" :title="l.label"
28
+ class="grid min-h-11 min-w-9 place-items-center px-1.5 font-medium uppercase" :class="l.current ? 'text-highlighted underline underline-offset-4' : 'text-muted hover:text-highlighted'"
29
+ :aria-current="l.current ? 'true' : undefined"
30
+ >
31
+ {{ l.code }}
32
+ <span class="sr-only"> — {{ l.label }}</span>
33
+ </NuxtLink>
34
+ </nav>
35
+ <NuxtLink :to="locale === 'en' ? '/en/search' : '/hledat'" class="grid size-11 place-items-center" :aria-label="locale === 'en' ? 'Search' : 'Hledat'">
36
+ <UIcon name="i-lucide-search" class="size-5" />
37
+ </NuxtLink>
38
+ </div>
39
+ <button
40
+ type="button" class="site-menu-button sm:hidden" :aria-expanded="menuOpen" aria-controls="site-nav"
41
+ @click="menuOpen = !menuOpen"
42
+ >
43
+ <UIcon :name="menuOpen ? 'i-lucide-x' : 'i-lucide-menu'" class="size-6" />
44
+ <span class="sr-only">{{ locale === 'en' ? 'Menu' : 'Menu' }}</span>
45
+ </button>
46
+ <CmsNav id="site-nav" :links="menu(nav?.main)" class="site-nav sm:ml-auto" :class="menuOpen ? 'site-nav--open' : ''" :aria-label="locale === 'en' ? 'Main menu' : 'Hlavní menu'" />
47
+ </div>
48
+ </header>
49
+ <main class="flex-1">
50
+ <slot />
51
+ </main>
52
+ <footer class="border-t border-default bg-muted/40">
53
+ <div class="mx-auto grid max-w-5xl gap-6 px-4 py-8 sm:grid-cols-3 text-sm">
54
+ <div>
55
+ <p class="font-semibold">{{ settings?.siteName }}</p>
56
+ <p v-if="settings?.tagline" class="text-muted">{{ settings.tagline }}</p>
57
+ </div>
58
+ <div v-if="settings?.email || settings?.phone || settings?.address" class="space-y-1">
59
+ <p v-if="settings?.address" class="whitespace-pre-line">{{ settings.address }}</p>
60
+ <p v-if="settings?.phone"><a :href="`tel:${settings.phone}`">{{ settings.phone }}</a></p>
61
+ <p v-if="settings?.email"><a :href="`mailto:${settings.email}`">{{ settings.email }}</a></p>
62
+ </div>
63
+ <dl v-if="settings?.openingHours?.length" class="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1">
64
+ <template v-for="h in settings.openingHours" :key="h.id">
65
+ <dt class="text-muted">{{ h.days }}</dt><dd>{{ h.hours }}</dd>
66
+ </template>
67
+ </dl>
68
+ <CmsNav :links="menu(nav?.footer)" class="site-nav-footer sm:col-span-3" :aria-label="locale === 'en' ? 'Footer menu' : 'Menu v patičce'" />
69
+ </div>
70
+ </footer>
71
+ </div>
72
+ </template>
73
+
74
+ <style>
75
+ /* Desktop: links in a row, a link's dropdown opens on hover or keyboard focus. */
76
+ .site-nav > ul { display: flex; gap: 0.25rem 1.25rem; flex-wrap: wrap; justify-content: flex-end; }
77
+ .site-nav li { position: relative; }
78
+ .site-nav .cms-nav__has-children > a::after, .site-nav .cms-nav__has-children > span::after { content: ""; display: inline-block; width: 0.4em; height: 0.4em; margin-left: 0.4em; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-0.2em) rotate(45deg); }
79
+ .site-nav li ul { display: none; position: absolute; top: 100%; right: 0; z-index: 10; min-width: 12rem; padding: 0.5rem 0; background: var(--ui-bg); border: 1px solid var(--ui-border); border-radius: 0.5rem; box-shadow: 0 8px 24px rgb(0 0 0 / 0.08); }
80
+ .site-nav li:hover > ul, .site-nav li:focus-within > ul { display: block; }
81
+ .site-nav li ul a { display: block; padding: 0.375rem 1rem; }
82
+ .site-nav-footer > ul { display: flex; gap: 1rem 2.5rem; flex-wrap: wrap; align-items: flex-start; }
83
+ /* A footer link with sub-links is a small column: the link as its heading, the others under it. */
84
+ .site-nav-footer li ul { margin-top: 0.375rem; display: grid; gap: 0.25rem; }
85
+ .site-nav-footer li ul a { color: var(--ui-text-muted); }
86
+ .site-nav-footer li ul a:hover { color: var(--ui-text-highlighted); }
87
+ .site-nav-footer .cms-nav__has-children > a, .site-nav-footer .cms-nav__has-children > span { font-weight: 600; }
88
+
89
+ /* Many links: the menu gets its own row under the logo and wraps there (dropdowns open from its left edge). */
90
+ @media (min-width: 640px) {
91
+ .site-header--wide .site-nav { order: 10000; flex-basis: 100%; margin-left: 0; }
92
+ .site-header--wide .site-nav > ul { justify-content: flex-start; }
93
+ .site-header--wide .site-nav li ul { right: auto; left: 0; }
94
+ }
95
+
96
+ /* Phones: one column behind the menu button, dropdown links shown under their parent. */
97
+ @media (max-width: 639px) {
98
+ .site-menu-button { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin: -0.5rem; }
99
+ .site-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: var(--ui-bg); border-bottom: 1px solid var(--ui-border); padding: 0.5rem 1rem 1rem; }
100
+ .site-nav--open { display: block; }
101
+ .site-nav > ul { flex-direction: column; gap: 0; }
102
+ .site-nav a { display: block; padding: 0.75rem 0; }
103
+ .site-nav .cms-nav__has-children > a::after, .site-nav .cms-nav__has-children > span::after { display: none; }
104
+ .site-nav li ul { display: block; position: static; min-width: 0; padding: 0 0 0 1rem; border: 0; box-shadow: none; background: none; }
105
+ }
106
+ </style>