@geekity/cms 0.3.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 (238) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +870 -0
  3. package/admin/layouts/_flash.njk +5 -0
  4. package/admin/layouts/base.njk +27 -0
  5. package/admin/layouts/dashboard.njk +78 -0
  6. package/admin/layouts/document-conflict.njk +49 -0
  7. package/admin/layouts/document-editor.njk +167 -0
  8. package/admin/layouts/document-list.njk +92 -0
  9. package/admin/layouts/federation.njk +145 -0
  10. package/admin/layouts/login.njk +23 -0
  11. package/admin/layouts/placeholder.njk +10 -0
  12. package/admin/layouts/settings.njk +116 -0
  13. package/admin/layouts/setup.njk +27 -0
  14. package/admin/layouts/shell.njk +37 -0
  15. package/admin/layouts/users.njk +91 -0
  16. package/admin/static/admin.css +726 -0
  17. package/admin/static/editor.js +30 -0
  18. package/dist/admin/assets.d.ts +26 -0
  19. package/dist/admin/assets.d.ts.map +1 -0
  20. package/dist/admin/assets.js +38 -0
  21. package/dist/admin/assets.js.map +1 -0
  22. package/dist/admin/credentials.d.ts +28 -0
  23. package/dist/admin/credentials.d.ts.map +1 -0
  24. package/dist/admin/credentials.js +39 -0
  25. package/dist/admin/credentials.js.map +1 -0
  26. package/dist/admin/documents.d.ts +134 -0
  27. package/dist/admin/documents.d.ts.map +1 -0
  28. package/dist/admin/documents.js +613 -0
  29. package/dist/admin/documents.js.map +1 -0
  30. package/dist/admin/federation.d.ts +194 -0
  31. package/dist/admin/federation.d.ts.map +1 -0
  32. package/dist/admin/federation.js +299 -0
  33. package/dist/admin/federation.js.map +1 -0
  34. package/dist/admin/flash.d.ts +24 -0
  35. package/dist/admin/flash.d.ts.map +1 -0
  36. package/dist/admin/flash.js +31 -0
  37. package/dist/admin/flash.js.map +1 -0
  38. package/dist/admin/index.d.ts +23 -0
  39. package/dist/admin/index.d.ts.map +1 -0
  40. package/dist/admin/index.js +15 -0
  41. package/dist/admin/index.js.map +1 -0
  42. package/dist/admin/passwords.d.ts +49 -0
  43. package/dist/admin/passwords.d.ts.map +1 -0
  44. package/dist/admin/passwords.js +122 -0
  45. package/dist/admin/passwords.js.map +1 -0
  46. package/dist/admin/preview.d.ts +18 -0
  47. package/dist/admin/preview.d.ts.map +1 -0
  48. package/dist/admin/preview.js +83 -0
  49. package/dist/admin/preview.js.map +1 -0
  50. package/dist/admin/routes.d.ts +54 -0
  51. package/dist/admin/routes.d.ts.map +1 -0
  52. package/dist/admin/routes.js +383 -0
  53. package/dist/admin/routes.js.map +1 -0
  54. package/dist/admin/session.d.ts +44 -0
  55. package/dist/admin/session.d.ts.map +1 -0
  56. package/dist/admin/session.js +69 -0
  57. package/dist/admin/session.js.map +1 -0
  58. package/dist/admin/settings.d.ts +194 -0
  59. package/dist/admin/settings.d.ts.map +1 -0
  60. package/dist/admin/settings.js +470 -0
  61. package/dist/admin/settings.js.map +1 -0
  62. package/dist/admin/store.d.ts +407 -0
  63. package/dist/admin/store.d.ts.map +1 -0
  64. package/dist/admin/store.js +704 -0
  65. package/dist/admin/store.js.map +1 -0
  66. package/dist/admin/templates.d.ts +36 -0
  67. package/dist/admin/templates.d.ts.map +1 -0
  68. package/dist/admin/templates.js +43 -0
  69. package/dist/admin/templates.js.map +1 -0
  70. package/dist/admin/uploads.d.ts +96 -0
  71. package/dist/admin/uploads.d.ts.map +1 -0
  72. package/dist/admin/uploads.js +179 -0
  73. package/dist/admin/uploads.js.map +1 -0
  74. package/dist/admin/users.d.ts +95 -0
  75. package/dist/admin/users.d.ts.map +1 -0
  76. package/dist/admin/users.js +233 -0
  77. package/dist/admin/users.js.map +1 -0
  78. package/dist/cli.d.ts +85 -0
  79. package/dist/cli.d.ts.map +1 -0
  80. package/dist/cli.js +424 -0
  81. package/dist/cli.js.map +1 -0
  82. package/dist/config.d.ts +172 -0
  83. package/dist/config.d.ts.map +1 -0
  84. package/dist/config.js +184 -0
  85. package/dist/config.js.map +1 -0
  86. package/dist/content/document.d.ts +66 -0
  87. package/dist/content/document.d.ts.map +1 -0
  88. package/dist/content/document.js +13 -0
  89. package/dist/content/document.js.map +1 -0
  90. package/dist/content/index.d.ts +17 -0
  91. package/dist/content/index.d.ts.map +1 -0
  92. package/dist/content/index.js +10 -0
  93. package/dist/content/index.js.map +1 -0
  94. package/dist/content/markdown.d.ts +3 -0
  95. package/dist/content/markdown.d.ts.map +1 -0
  96. package/dist/content/markdown.js +39 -0
  97. package/dist/content/markdown.js.map +1 -0
  98. package/dist/content/media.d.ts +65 -0
  99. package/dist/content/media.d.ts.map +1 -0
  100. package/dist/content/media.js +143 -0
  101. package/dist/content/media.js.map +1 -0
  102. package/dist/content/parser.d.ts +24 -0
  103. package/dist/content/parser.d.ts.map +1 -0
  104. package/dist/content/parser.js +165 -0
  105. package/dist/content/parser.js.map +1 -0
  106. package/dist/content/save.d.ts +60 -0
  107. package/dist/content/save.d.ts.map +1 -0
  108. package/dist/content/save.js +103 -0
  109. package/dist/content/save.js.map +1 -0
  110. package/dist/content/slug.d.ts +25 -0
  111. package/dist/content/slug.d.ts.map +1 -0
  112. package/dist/content/slug.js +75 -0
  113. package/dist/content/slug.js.map +1 -0
  114. package/dist/content/store.d.ts +133 -0
  115. package/dist/content/store.d.ts.map +1 -0
  116. package/dist/content/store.js +411 -0
  117. package/dist/content/store.js.map +1 -0
  118. package/dist/content/sync.d.ts +146 -0
  119. package/dist/content/sync.d.ts.map +1 -0
  120. package/dist/content/sync.js +421 -0
  121. package/dist/content/sync.js.map +1 -0
  122. package/dist/content/writer.d.ts +37 -0
  123. package/dist/content/writer.d.ts.map +1 -0
  124. package/dist/content/writer.js +97 -0
  125. package/dist/content/writer.js.map +1 -0
  126. package/dist/env.d.ts +48 -0
  127. package/dist/env.d.ts.map +1 -0
  128. package/dist/env.js +2 -0
  129. package/dist/env.js.map +1 -0
  130. package/dist/federation/actor.d.ts +55 -0
  131. package/dist/federation/actor.d.ts.map +1 -0
  132. package/dist/federation/actor.js +101 -0
  133. package/dist/federation/actor.js.map +1 -0
  134. package/dist/federation/article.d.ts +83 -0
  135. package/dist/federation/article.d.ts.map +1 -0
  136. package/dist/federation/article.js +169 -0
  137. package/dist/federation/article.js.map +1 -0
  138. package/dist/federation/delivery.d.ts +90 -0
  139. package/dist/federation/delivery.d.ts.map +1 -0
  140. package/dist/federation/delivery.js +289 -0
  141. package/dist/federation/delivery.js.map +1 -0
  142. package/dist/federation/federation.d.ts +75 -0
  143. package/dist/federation/federation.d.ts.map +1 -0
  144. package/dist/federation/federation.js +190 -0
  145. package/dist/federation/federation.js.map +1 -0
  146. package/dist/federation/followers.d.ts +43 -0
  147. package/dist/federation/followers.d.ts.map +1 -0
  148. package/dist/federation/followers.js +69 -0
  149. package/dist/federation/followers.js.map +1 -0
  150. package/dist/federation/inbox.d.ts +68 -0
  151. package/dist/federation/inbox.d.ts.map +1 -0
  152. package/dist/federation/inbox.js +171 -0
  153. package/dist/federation/inbox.js.map +1 -0
  154. package/dist/federation/index.d.ts +14 -0
  155. package/dist/federation/index.d.ts.map +1 -0
  156. package/dist/federation/index.js +10 -0
  157. package/dist/federation/index.js.map +1 -0
  158. package/dist/federation/keys.d.ts +27 -0
  159. package/dist/federation/keys.d.ts.map +1 -0
  160. package/dist/federation/keys.js +60 -0
  161. package/dist/federation/keys.js.map +1 -0
  162. package/dist/federation/mount.d.ts +23 -0
  163. package/dist/federation/mount.d.ts.map +1 -0
  164. package/dist/federation/mount.js +71 -0
  165. package/dist/federation/mount.js.map +1 -0
  166. package/dist/federation/paths.d.ts +85 -0
  167. package/dist/federation/paths.d.ts.map +1 -0
  168. package/dist/federation/paths.js +97 -0
  169. package/dist/federation/paths.js.map +1 -0
  170. package/dist/index.d.ts +106 -0
  171. package/dist/index.d.ts.map +1 -0
  172. package/dist/index.js +148 -0
  173. package/dist/index.js.map +1 -0
  174. package/dist/init.d.ts +71 -0
  175. package/dist/init.d.ts.map +1 -0
  176. package/dist/init.js +125 -0
  177. package/dist/init.js.map +1 -0
  178. package/dist/web/assets.d.ts +65 -0
  179. package/dist/web/assets.d.ts.map +1 -0
  180. package/dist/web/assets.js +152 -0
  181. package/dist/web/assets.js.map +1 -0
  182. package/dist/web/context.d.ts +121 -0
  183. package/dist/web/context.d.ts.map +1 -0
  184. package/dist/web/context.js +112 -0
  185. package/dist/web/context.js.map +1 -0
  186. package/dist/web/documents.d.ts +28 -0
  187. package/dist/web/documents.d.ts.map +1 -0
  188. package/dist/web/documents.js +39 -0
  189. package/dist/web/documents.js.map +1 -0
  190. package/dist/web/feeds.d.ts +122 -0
  191. package/dist/web/feeds.d.ts.map +1 -0
  192. package/dist/web/feeds.js +229 -0
  193. package/dist/web/feeds.js.map +1 -0
  194. package/dist/web/index.d.ts +17 -0
  195. package/dist/web/index.d.ts.map +1 -0
  196. package/dist/web/index.js +10 -0
  197. package/dist/web/index.js.map +1 -0
  198. package/dist/web/negotiate.d.ts +219 -0
  199. package/dist/web/negotiate.d.ts.map +1 -0
  200. package/dist/web/negotiate.js +409 -0
  201. package/dist/web/negotiate.js.map +1 -0
  202. package/dist/web/pagination.d.ts +48 -0
  203. package/dist/web/pagination.d.ts.map +1 -0
  204. package/dist/web/pagination.js +30 -0
  205. package/dist/web/pagination.js.map +1 -0
  206. package/dist/web/render.d.ts +72 -0
  207. package/dist/web/render.d.ts.map +1 -0
  208. package/dist/web/render.js +73 -0
  209. package/dist/web/render.js.map +1 -0
  210. package/dist/web/routes.d.ts +31 -0
  211. package/dist/web/routes.d.ts.map +1 -0
  212. package/dist/web/routes.js +366 -0
  213. package/dist/web/routes.js.map +1 -0
  214. package/dist/web/templates.d.ts +34 -0
  215. package/dist/web/templates.d.ts.map +1 -0
  216. package/dist/web/templates.js +106 -0
  217. package/dist/web/templates.js.map +1 -0
  218. package/package.json +68 -0
  219. package/templates/site/content/_data/site.json +8 -0
  220. package/templates/site/content/pages/about.md +11 -0
  221. package/templates/site/content/pages/pages.json +3 -0
  222. package/templates/site/content/posts/2026-01-01-hello-world.md +34 -0
  223. package/templates/site/content/posts/posts.json +4 -0
  224. package/templates/site/geekity.config.ts +11 -0
  225. package/templates/site/gitignore +3 -0
  226. package/templates/site/server.ts +20 -0
  227. package/templates/site/tsconfig.json +18 -0
  228. package/themes/default/README.md +148 -0
  229. package/themes/default/layouts/404.njk +9 -0
  230. package/themes/default/layouts/base.njk +59 -0
  231. package/themes/default/layouts/home.njk +9 -0
  232. package/themes/default/layouts/page.njk +13 -0
  233. package/themes/default/layouts/post.njk +30 -0
  234. package/themes/default/layouts/tag.njk +19 -0
  235. package/themes/default/partials/pagination.njk +14 -0
  236. package/themes/default/partials/post-list.njk +24 -0
  237. package/themes/default/partials/tags.njk +12 -0
  238. package/themes/default/static/style.css +327 -0
@@ -0,0 +1,26 @@
1
+ import type { StaticAsset } from '../web/assets.ts';
2
+ /**
3
+ * Where the admin's own files live: stylesheets and, later, whatever the
4
+ * editor needs. Resolved from this module rather than the working directory,
5
+ * like the templates beside them.
6
+ */
7
+ export declare const ADMIN_STATIC_DIR: string;
8
+ /**
9
+ * URL prefix the admin's files are served under.
10
+ *
11
+ * The leading underscore keeps it out of the way of the screens: `/admin/posts`
12
+ * is a screen and `/admin/_static/admin.css` never can be.
13
+ */
14
+ export declare const ADMIN_ASSET_PREFIX = "/admin/_static/";
15
+ /** How long a browser may keep an admin asset. One hour, as for a theme's. */
16
+ export declare const ADMIN_ASSET_MAX_AGE = 3600;
17
+ /** One file under {@link ADMIN_STATIC_DIR}, or `undefined`. */
18
+ export declare function findAdminAsset(relative: string): StaticAsset | undefined;
19
+ /**
20
+ * Answer a request for an admin asset.
21
+ *
22
+ * Returns `undefined` when there is no such file, so the caller can fall
23
+ * through to whatever it does with an unknown URL.
24
+ */
25
+ export declare function adminAssetResponse(relative: string, ifNoneMatch: string | undefined): Response | undefined;
26
+ //# sourceMappingURL=assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/admin/assets.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAE9B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,oBAA6B,CAAC;AAE7D,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,QAAQ,GAAG,SAAS,CAQtB"}
@@ -0,0 +1,38 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import { assetNotModified, assetResponse, findAsset, matchesEtag } from '../web/assets.js';
3
+ import { ADMIN_PREFIX } from './session.js';
4
+ /**
5
+ * Where the admin's own files live: stylesheets and, later, whatever the
6
+ * editor needs. Resolved from this module rather than the working directory,
7
+ * like the templates beside them.
8
+ */
9
+ export const ADMIN_STATIC_DIR = fileURLToPath(new URL('../../admin/static/', import.meta.url));
10
+ /**
11
+ * URL prefix the admin's files are served under.
12
+ *
13
+ * The leading underscore keeps it out of the way of the screens: `/admin/posts`
14
+ * is a screen and `/admin/_static/admin.css` never can be.
15
+ */
16
+ export const ADMIN_ASSET_PREFIX = `${ADMIN_PREFIX}/_static/`;
17
+ /** How long a browser may keep an admin asset. One hour, as for a theme's. */
18
+ export const ADMIN_ASSET_MAX_AGE = 3600;
19
+ /** One file under {@link ADMIN_STATIC_DIR}, or `undefined`. */
20
+ export function findAdminAsset(relative) {
21
+ return findAsset(relative, [ADMIN_STATIC_DIR]);
22
+ }
23
+ /**
24
+ * Answer a request for an admin asset.
25
+ *
26
+ * Returns `undefined` when there is no such file, so the caller can fall
27
+ * through to whatever it does with an unknown URL.
28
+ */
29
+ export function adminAssetResponse(relative, ifNoneMatch) {
30
+ const asset = findAdminAsset(relative);
31
+ if (asset === undefined)
32
+ return undefined;
33
+ const options = { maxAge: ADMIN_ASSET_MAX_AGE };
34
+ return matchesEtag(ifNoneMatch, asset.etag)
35
+ ? assetNotModified(asset, options)
36
+ : assetResponse(asset, options);
37
+ }
38
+ //# sourceMappingURL=assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/admin/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAW,aAAa,CACnD,IAAI,GAAG,CAAC,qBAAqB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAChD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,YAAY,WAAW,CAAC;AAE7D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAExC,+DAA+D;AAC/D,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAgB,EAChB,WAA+B;IAE/B,MAAM,KAAK,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE1C,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAChD,OAAO,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC;QACzC,CAAC,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC;QAClC,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The rules a username and a password have to satisfy, in one place.
3
+ *
4
+ * There are two doors into the users table — the first-run setup form and
5
+ * `geekity user add` — and an account the CLI made has to be one the form
6
+ * would have accepted. Keeping the rules here rather than in the route module
7
+ * is what makes that true by construction instead of by memory.
8
+ */
9
+ /** The shortest password either door accepts. */
10
+ export declare const MINIMUM_PASSWORD_LENGTH = 8;
11
+ /** How long a username may be. */
12
+ export declare const MAXIMUM_USERNAME_LENGTH = 64;
13
+ /**
14
+ * What a username may be made of: no spaces, and no punctuation that would
15
+ * later need escaping in a URL, a shell or a template.
16
+ */
17
+ export declare const USERNAME_PATTERN: RegExp;
18
+ /** What is wrong with a username, or `undefined` when nothing is. */
19
+ export declare function usernameProblem(username: string): string | undefined;
20
+ /** What is wrong with a password, or `undefined` when nothing is. */
21
+ export declare function passwordProblem(password: string): string | undefined;
22
+ /**
23
+ * The first thing wrong with a proposed account, or `undefined` when it is
24
+ * acceptable. The username is reported first, so the message names the first
25
+ * thing to fix rather than the last.
26
+ */
27
+ export declare function credentialProblem(username: string, password: string): string | undefined;
28
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/admin/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,iDAAiD;AACjD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,kCAAkC;AAClC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AAEzD,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMpE;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGpE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAExF"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The rules a username and a password have to satisfy, in one place.
3
+ *
4
+ * There are two doors into the users table — the first-run setup form and
5
+ * `geekity user add` — and an account the CLI made has to be one the form
6
+ * would have accepted. Keeping the rules here rather than in the route module
7
+ * is what makes that true by construction instead of by memory.
8
+ */
9
+ /** The shortest password either door accepts. */
10
+ export const MINIMUM_PASSWORD_LENGTH = 8;
11
+ /** How long a username may be. */
12
+ export const MAXIMUM_USERNAME_LENGTH = 64;
13
+ /**
14
+ * What a username may be made of: no spaces, and no punctuation that would
15
+ * later need escaping in a URL, a shell or a template.
16
+ */
17
+ export const USERNAME_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
18
+ /** What is wrong with a username, or `undefined` when nothing is. */
19
+ export function usernameProblem(username) {
20
+ if (USERNAME_PATTERN.test(username))
21
+ return undefined;
22
+ return (`A username is 1 to ${String(MAXIMUM_USERNAME_LENGTH)} letters, digits, dots, dashes or ` +
23
+ 'underscores.');
24
+ }
25
+ /** What is wrong with a password, or `undefined` when nothing is. */
26
+ export function passwordProblem(password) {
27
+ if (password.length >= MINIMUM_PASSWORD_LENGTH)
28
+ return undefined;
29
+ return `A password is at least ${String(MINIMUM_PASSWORD_LENGTH)} characters.`;
30
+ }
31
+ /**
32
+ * The first thing wrong with a proposed account, or `undefined` when it is
33
+ * acceptable. The username is reported first, so the message names the first
34
+ * thing to fix rather than the last.
35
+ */
36
+ export function credentialProblem(username, password) {
37
+ return usernameProblem(username) ?? passwordProblem(password);
38
+ }
39
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/admin/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,iDAAiD;AACjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,kCAAkC;AAClC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAEzD,qEAAqE;AACrE,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAC;IACtD,OAAO,CACL,sBAAsB,MAAM,CAAC,uBAAuB,CAAC,oCAAoC;QACzF,cAAc,CACf,CAAC;AACJ,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,QAAQ,CAAC,MAAM,IAAI,uBAAuB;QAAE,OAAO,SAAS,CAAC;IACjE,OAAO,0BAA0B,MAAM,CAAC,uBAAuB,CAAC,cAAc,CAAC;AACjF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,QAAgB;IAClE,OAAO,eAAe,CAAC,QAAQ,CAAC,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,134 @@
1
+ import type { Context, Hono } from 'hono';
2
+ import type { Document, DocumentType } from '../content/document.ts';
3
+ import type { ContentStore, ListAllOptions } from '../content/store.ts';
4
+ import type { GeekityEnv } from '../env.ts';
5
+ /**
6
+ * Everything that differs between the posts screens and the pages screens.
7
+ *
8
+ * Posts and pages are the same screens over the same store with two knobs
9
+ * turned: a post carries a date and tags, a page carries neither. Keeping the
10
+ * difference in data rather than in two copies of the code is what lets
11
+ * `/admin/pages` be one call to {@link mountDocumentScreens}.
12
+ */
13
+ export interface DocumentKind {
14
+ /** Which documents these screens show. */
15
+ type: DocumentType;
16
+ /** The navigation section they mark as current. */
17
+ section: string;
18
+ /** Root of the screens, e.g. `/admin/posts`. */
19
+ basePath: string;
20
+ /** How one of them is named in a sentence, e.g. `post`. */
21
+ singular: string;
22
+ /** The heading over the listing, e.g. `Posts`. */
23
+ plural: string;
24
+ /** Whether a document of this kind has a publish date. */
25
+ dated: boolean;
26
+ /** Whether a document of this kind carries tags. */
27
+ tagged: boolean;
28
+ /**
29
+ * Whether the editor offers the `eleventyExcludeFromCollections` flag. doc-2
30
+ * mirrors it for pages that should not list; a post is in the archive by
31
+ * definition and has no use for it.
32
+ */
33
+ excludable: boolean;
34
+ }
35
+ /**
36
+ * The Eleventy key that keeps a document out of every collection.
37
+ *
38
+ * The CMS does not model it — it is not in `KNOWN_FRONT_MATTER_KEYS` — so the
39
+ * parser leaves it in {@link Document.extra} and the editor reads and writes it
40
+ * there, alongside every other key somebody added by hand.
41
+ */
42
+ export declare const EXCLUDE_KEY = "eleventyExcludeFromCollections";
43
+ /** The posts screens: dated, tagged, filed under `posts/`. */
44
+ export declare const POST_KIND: DocumentKind;
45
+ /** The pages screens: standing content, no date prefix and no taxonomy. */
46
+ export declare const PAGE_KIND: DocumentKind;
47
+ /** The URL of the editor for one document. */
48
+ export declare function editorPath(kind: DocumentKind, slug: string): string;
49
+ /** The URL of the editor for a document that does not exist yet. */
50
+ export declare function newEditorPath(kind: DocumentKind): string;
51
+ /** The four views of a listing doc-5 asks for. */
52
+ export type DocumentFilter = 'all' | 'published' | 'draft' | 'trash';
53
+ /** The filters, in the order they are shown. */
54
+ export declare const DOCUMENT_FILTERS: readonly DocumentFilter[];
55
+ /** How many rows one page of a listing holds. */
56
+ export declare const DOCUMENTS_PER_PAGE = 25;
57
+ /** The filter a query string asked for, defaulting to everything live. */
58
+ export declare function documentFilter(value: string | undefined): DocumentFilter;
59
+ /** {@link ContentStore.listAll} options for one kind and one filter. */
60
+ export declare function listOptionsFor(kind: DocumentKind, filter: DocumentFilter): ListAllOptions;
61
+ /** How {@link mountDocumentScreens} renders one admin template. */
62
+ export type AdminRender = (c: Context<GeekityEnv>, template: string, context?: Record<string, unknown>) => Response;
63
+ /** What {@link mountDocumentScreens} needs from the admin around it. */
64
+ export interface MountDocumentScreensOptions {
65
+ /** Which documents the screens are for. */
66
+ kind: DocumentKind;
67
+ /** The admin's renderer, which injects the chrome, the CSRF token and the flash. */
68
+ render: AdminRender;
69
+ }
70
+ /**
71
+ * Register the listing and the editor for one kind of document.
72
+ *
73
+ * Both `/admin/posts` and `/admin/pages` are this function with a different
74
+ * {@link DocumentKind}: the screens, the templates and the write path are
75
+ * shared, and the kind decides what a file is called, whether the form has a
76
+ * date and tags, and which section of the navigation marks itself.
77
+ */
78
+ export declare function mountDocumentScreens(app: Hono<GeekityEnv>, options: MountDocumentScreensOptions): void;
79
+ /** A comma-separated tag field as a list, without the blanks and the repeats. */
80
+ export declare function splitTags(value: string): string[];
81
+ /**
82
+ * A submitted return path, when it is one this admin could have rendered.
83
+ *
84
+ * Only paths under `/admin/` are honoured, and only ones that cannot be read
85
+ * as another host, so the value cannot be used to bounce somebody off the site.
86
+ */
87
+ export declare function returnPath(value: string): string | undefined;
88
+ /** The editor's fields, as strings, which is what a form has. */
89
+ export interface EditorForm {
90
+ title: string;
91
+ slug: string;
92
+ permalink: string;
93
+ date: string;
94
+ tags: string;
95
+ description: string;
96
+ draft: boolean;
97
+ /** Whether `eleventyExcludeFromCollections` is set. Pages only. */
98
+ exclude: boolean;
99
+ body: string;
100
+ /** The hash of the file the form was filled in from; empty for a new one. */
101
+ hash: string;
102
+ }
103
+ /** The editor for a document that does not exist yet. */
104
+ export declare function blankForm(kind: DocumentKind): EditorForm;
105
+ /** The editor for a document that does. */
106
+ export declare function formFor(document: Document): EditorForm;
107
+ /**
108
+ * The document of this kind with this slug.
109
+ *
110
+ * The index's slug lookup is across both kinds and is not unique, so a direct
111
+ * hit is only taken when it is of the right kind; otherwise the listing is
112
+ * searched, trash included, because the editor is where a trashed document is
113
+ * restored from.
114
+ */
115
+ export declare function findBySlug(store: ContentStore, kind: DocumentKind, slug: string): Document | undefined;
116
+ /** What the listing template shows for one document. */
117
+ export interface DocumentRow {
118
+ title: string;
119
+ slug: string;
120
+ author: string | undefined;
121
+ tags: string;
122
+ date: string | undefined;
123
+ /** The most recent change to the document, for a kind with no publish date. */
124
+ updated: string | undefined;
125
+ draft: boolean;
126
+ trashed: boolean;
127
+ /** Where the editor for it lives. */
128
+ editUrl: string;
129
+ /** Its public URL, or `undefined` when the public site would not serve it. */
130
+ viewUrl: string | undefined;
131
+ }
132
+ /** The URL of one view of a listing. Page one is the listing's own URL. */
133
+ export declare function listingUrl(kind: DocumentKind, filter: DocumentFilter, page?: number): string;
134
+ //# sourceMappingURL=documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/admin/documents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,QAAQ,EAAmB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKtF,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAQ5C;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,IAAI,EAAE,YAAY,CAAC;IACnB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,KAAK,EAAE,OAAO,CAAC;IACf,oDAAoD;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,mCAAmC,CAAC;AAE5D,8DAA8D;A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