@jant/core 0.7.0 → 0.8.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 (331) hide show
  1. package/bin/commands/assets/prepare.js +3 -3
  2. package/bin/commands/db/export.js +115 -2
  3. package/bin/commands/deploy.js +11 -3
  4. package/bin/commands/{search-reindex.js → search/reindex.js} +5 -5
  5. package/bin/commands/setup.js +136 -0
  6. package/bin/commands/site/export.js +117 -68
  7. package/bin/commands/site/import.js +3074 -2
  8. package/bin/commands/site/pull-media.js +2 -6
  9. package/bin/commands/site/snapshot/export.js +18 -60
  10. package/bin/commands/site/snapshot/import.js +24 -23
  11. package/bin/commands/telegram/register-webhooks.js +48 -23
  12. package/bin/jant.js +16 -11
  13. package/bin/lib/command-registry.js +120 -0
  14. package/bin/lib/d1-query.js +87 -2
  15. package/bin/lib/hugo-markdown.js +4 -0
  16. package/bin/lib/migration-artifacts.js +19 -0
  17. package/bin/lib/renamed-arguments.js +56 -0
  18. package/bin/lib/site-pull-media.js +21 -28
  19. package/bin/lib/site-selection.js +10 -1
  20. package/bin/lib/site-snapshot.js +421 -4
  21. package/bin/lib/sql-export.js +68 -5
  22. package/bin/lib/wrangler-cli.js +9 -0
  23. package/bin/lib/zip-archive.js +187 -0
  24. package/dist/{app-K_Aa1MMn.js → app-CFsmRVJN.js} +8629 -697
  25. package/dist/client/.vite/manifest.json +20 -20
  26. package/dist/client/_assets/chunks/{create-editor-CD3FhrOB.js → create-editor-B-m7X7S5.js} +50 -46
  27. package/dist/client/_assets/chunks/{sortable-list-CgaL2jCs.js → sortable-list-BJyd-LXE.js} +1 -1
  28. package/dist/client/_assets/chunks/{unsafe-svg-0QCkP0vZ.js → unsafe-svg-BkscJx69.js} +2 -2
  29. package/dist/client/_assets/{client-GiYENVw8.css → client-BCumu1-D.css} +1 -1
  30. package/dist/client/_assets/{client-VnFxJN7G.js → client-DTLBOHqD.js} +1 -1
  31. package/dist/client/_assets/{client-auth-k8gJ6QJj.js → client-auth-D6Ix6SmE.js} +1 -1
  32. package/dist/client/_assets/{client-compose-B_kDtWkW.js → client-compose-D6rExKVK.js} +1 -1
  33. package/dist/client/_assets/{client-manage-M90aSTOk.js → client-manage-sVOkqVbH.js} +1 -1
  34. package/dist/client/_assets/{client-settings-DfYs9n1F.js → client-settings-CGR_nZ78.js} +7 -7
  35. package/dist/index.js +2 -3
  36. package/dist/node.js +8 -5
  37. package/dist/url-CKlGzvdN.js +428 -0
  38. package/package.json +13 -7
  39. package/src/__tests__/cli-commands.test.ts +144 -0
  40. package/src/__tests__/config-docs.test.ts +148 -0
  41. package/src/__tests__/dev-scripts.test.ts +203 -0
  42. package/src/__tests__/export-collection-order.test.ts +276 -0
  43. package/src/__tests__/export-feed-ids.test.ts +184 -0
  44. package/src/__tests__/export-feed-order.test.ts +294 -0
  45. package/src/__tests__/export-hugo-build.test.ts +130 -0
  46. package/src/__tests__/export-import-roundtrip.test.ts +95 -1
  47. package/src/__tests__/export-service.test.ts +611 -28
  48. package/src/__tests__/export-smart-collection.test.ts +329 -0
  49. package/src/__tests__/feed-docs.test.ts +36 -0
  50. package/src/__tests__/fixtures/releases/0.7.0/site-export/README.md +89 -0
  51. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/0x4nv/index.md +16 -0
  52. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/_index.md +41 -0
  53. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/faqyt/index.md +28 -0
  54. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +18 -0
  55. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/_index.md +4 -0
  56. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +27 -0
  57. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +32 -0
  58. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/archive/_index.md +7 -0
  59. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +27 -0
  60. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/bought-too-many-lemons-again/_index.md +34 -0
  61. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/city-walks/_index.md +11 -0
  62. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/collections/_index.md +4 -0
  63. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/current-tea-rotation/_index.md +31 -0
  64. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +27 -0
  65. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/desk-but-better/_index.md +22 -0
  66. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/e0kcg/_index.md +19 -0
  67. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/featured/_index.md +7 -0
  68. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-basho/_index.md +22 -0
  69. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-epictetus/_index.md +22 -0
  70. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-marcus-aurelius/_index.md +22 -0
  71. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-seneca/_index.md +22 -0
  72. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-thoreau/_index.md +22 -0
  73. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/2cl6d/index.md +16 -0
  74. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/3zqv7/index.md +28 -0
  75. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/5oxsv/index.md +16 -0
  76. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/_index.md +36 -0
  77. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/home-cooking/_index.md +11 -0
  78. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/_index.md +29 -0
  79. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +18 -0
  80. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/a83qu/index.md +16 -0
  81. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +19 -0
  82. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +27 -0
  83. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +27 -0
  84. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/_index.md +29 -0
  85. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/c91j0/index.md +16 -0
  86. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/qyucy/index.md +16 -0
  87. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/wsgck/index.md +16 -0
  88. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +43 -0
  89. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/reading-notes/_index.md +11 -0
  90. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +27 -0
  91. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/_index.md +41 -0
  92. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/cxiu6/index.md +16 -0
  93. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/t77ms/index.md +16 -0
  94. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +18 -0
  95. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/telk3/_index.md +27 -0
  96. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/telk3/from-thoreau-pawt2/index.md +17 -0
  97. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +32 -0
  98. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +29 -0
  99. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +27 -0
  100. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/tiny-projects/_index.md +11 -0
  101. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/useful-links/_index.md +11 -0
  102. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/weekend-notes/_index.md +11 -0
  103. package/src/__tests__/fixtures/releases/0.7.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +49 -0
  104. package/src/__tests__/fixtures/releases/0.7.0/site-export/data/jant.toml +119 -0
  105. package/src/__tests__/fixtures/releases/0.7.0/site-export/hugo.toml +43 -0
  106. package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/021801c20ab3-med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
  107. package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/0f868ce9ac84-med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
  108. package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/50c2ad911bad-med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
  109. package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/7a91f0960491-med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
  110. package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/8714116d3c8e-med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
  111. package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/8a0b4277443f-med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
  112. package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/a7d1c8a1afd9-med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
  113. package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/e25570b405f5-med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
  114. package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/e89ea4eabf01-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
  115. package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
  116. package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/custom.css +0 -0
  117. package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/favicon.ico +0 -0
  118. package/src/__tests__/fixtures/releases/0.7.0/snapshot/db.sql +218 -0
  119. package/src/__tests__/fixtures/releases/0.7.0/snapshot/meta.json +9 -0
  120. package/src/__tests__/fixtures/releases/0.7.1/site-export/README.md +89 -0
  121. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/0x4nv/index.md +16 -0
  122. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/_index.md +41 -0
  123. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/faqyt/index.md +28 -0
  124. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +18 -0
  125. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/_index.md +4 -0
  126. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +27 -0
  127. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +32 -0
  128. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/archive/_index.md +7 -0
  129. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +27 -0
  130. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/bought-too-many-lemons-again/_index.md +34 -0
  131. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/city-walks/_index.md +11 -0
  132. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/collections/_index.md +4 -0
  133. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/current-tea-rotation/_index.md +31 -0
  134. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +27 -0
  135. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/desk-but-better/_index.md +22 -0
  136. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/e0kcg/_index.md +19 -0
  137. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/featured/_index.md +7 -0
  138. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-basho/_index.md +22 -0
  139. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-epictetus/_index.md +22 -0
  140. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-marcus-aurelius/_index.md +22 -0
  141. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-seneca/_index.md +22 -0
  142. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-thoreau/_index.md +22 -0
  143. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/2cl6d/index.md +16 -0
  144. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/3zqv7/index.md +28 -0
  145. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/5oxsv/index.md +16 -0
  146. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/_index.md +36 -0
  147. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/home-cooking/_index.md +11 -0
  148. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/_index.md +29 -0
  149. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +18 -0
  150. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/a83qu/index.md +16 -0
  151. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/from-seneca-5hibo/index.md +19 -0
  152. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/mynoise-for-rainy-afternoons/_index.md +27 -0
  153. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/nts-archives-are-good-cleaning-music/_index.md +27 -0
  154. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/_index.md +29 -0
  155. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/c91j0/index.md +16 -0
  156. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/qyucy/index.md +16 -0
  157. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/wsgck/index.md +16 -0
  158. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +43 -0
  159. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/reading-notes/_index.md +11 -0
  160. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +27 -0
  161. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/_index.md +41 -0
  162. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/cxiu6/index.md +16 -0
  163. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/t77ms/index.md +16 -0
  164. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/the-soup-trick-i-always-forget/index.md +18 -0
  165. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/telk3/_index.md +27 -0
  166. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/telk3/from-thoreau-pawt2/index.md +17 -0
  167. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +32 -0
  168. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +29 -0
  169. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +27 -0
  170. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/tiny-projects/_index.md +11 -0
  171. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/useful-links/_index.md +11 -0
  172. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/weekend-notes/_index.md +11 -0
  173. package/src/__tests__/fixtures/releases/0.7.1/site-export/content/what-i-actually-use-my-notebook-for/_index.md +49 -0
  174. package/src/__tests__/fixtures/releases/0.7.1/site-export/data/jant.toml +119 -0
  175. package/src/__tests__/fixtures/releases/0.7.1/site-export/hugo.toml +43 -0
  176. package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/021801c20ab3-med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
  177. package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/0f868ce9ac84-med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
  178. package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/50c2ad911bad-med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
  179. package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/7a91f0960491-med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
  180. package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/8714116d3c8e-med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
  181. package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/8a0b4277443f-med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
  182. package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/a7d1c8a1afd9-med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
  183. package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/e25570b405f5-med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
  184. package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/e89ea4eabf01-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
  185. package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/apple-touch-icon.png +0 -0
  186. package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/custom.css +0 -0
  187. package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/favicon.ico +0 -0
  188. package/src/__tests__/fixtures/releases/0.7.1/snapshot/db.sql +322 -0
  189. package/src/__tests__/fixtures/releases/0.7.1/snapshot/meta.json +9 -0
  190. package/src/__tests__/helpers/hugo-site.ts +146 -0
  191. package/src/__tests__/helpers/site-export-import.ts +97 -0
  192. package/src/__tests__/import-site-command.test.ts +514 -2
  193. package/src/__tests__/mise-config.test.ts +75 -4
  194. package/src/__tests__/node-dev-tasks.test.ts +264 -0
  195. package/src/__tests__/release-fixtures.test.ts +132 -0
  196. package/src/__tests__/site-export-canonical-import.test.ts +113 -0
  197. package/src/__tests__/snapshot-canonical-replay.test.ts +179 -0
  198. package/src/__tests__/snapshot-settings.test.ts +97 -0
  199. package/src/__tests__/snapshot-tables.test.ts +219 -0
  200. package/src/__tests__/sql-export.test.ts +173 -0
  201. package/src/__tests__/theme-docs.test.ts +109 -0
  202. package/src/__tests__/zip-archive.test.ts +106 -0
  203. package/src/app.tsx +16 -11
  204. package/src/client/components/__tests__/jant-settings-avatar.test.ts +1 -1
  205. package/src/client/components/__tests__/jant-settings-general.test.ts +21 -1
  206. package/src/client/components/jant-repo-picker-types.ts +6 -1
  207. package/src/client/components/jant-repo-picker.ts +4 -7
  208. package/src/client/components/jant-settings-general.ts +17 -12
  209. package/src/client/tiptap/__tests__/list-editing.test.ts +224 -86
  210. package/src/client/tiptap/__tests__/mark-exit.test.ts +1 -2
  211. package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +26 -0
  212. package/src/client/tiptap/extensions.ts +0 -3
  213. package/src/client/tiptap/structural-keymap.ts +158 -47
  214. package/src/db/__tests__/d1-query.test.ts +56 -1
  215. package/src/db/rehearsal-fixtures/pg-demo-current.json +55 -0
  216. package/src/db/rehearsal-fixtures/pg-demo-current.sql +431 -0
  217. package/src/i18n/locales/public/en.po +0 -2
  218. package/src/i18n/locales/public/zh-Hans.po +0 -2
  219. package/src/i18n/locales/public/zh-Hant.po +0 -2
  220. package/src/i18n/locales/settings/en.po +8 -8
  221. package/src/i18n/locales/settings/en.ts +1 -1
  222. package/src/i18n/locales/settings/zh-Hans.po +8 -8
  223. package/src/i18n/locales/settings/zh-Hans.ts +1 -1
  224. package/src/i18n/locales/settings/zh-Hant.po +8 -8
  225. package/src/i18n/locales/settings/zh-Hant.ts +1 -1
  226. package/src/index.ts +6 -77
  227. package/src/lib/__tests__/github-sync-repo-name.test.ts +40 -0
  228. package/src/lib/__tests__/image.test.ts +27 -1
  229. package/src/lib/__tests__/markdown-to-tiptap.test.ts +105 -0
  230. package/src/lib/__tests__/markdown.test.ts +10 -0
  231. package/src/lib/__tests__/resolve-config.test.ts +67 -0
  232. package/src/lib/__tests__/schemas.test.ts +27 -1
  233. package/src/lib/__tests__/timeline.test.ts +87 -0
  234. package/src/lib/__tests__/tiptap-to-markdown.test.ts +172 -4
  235. package/src/lib/__tests__/view.test.ts +0 -46
  236. package/src/lib/discover.ts +3 -1
  237. package/src/lib/feed.ts +0 -6
  238. package/src/lib/github-sync-repo-name.ts +45 -0
  239. package/src/lib/hugo-markdown.ts +46 -0
  240. package/src/lib/image.ts +17 -4
  241. package/src/lib/markdown-manager.ts +392 -2
  242. package/src/lib/post-body-html.ts +11 -4
  243. package/src/lib/resolve-config.ts +58 -1
  244. package/src/lib/schemas.ts +50 -5
  245. package/src/lib/thread-fold.ts +3 -3
  246. package/src/lib/timeline.ts +1 -1
  247. package/src/lib/tiptap-to-markdown.ts +13 -7
  248. package/src/lib/url.ts +20 -0
  249. package/src/lib/view.ts +2 -29
  250. package/src/node/__tests__/cli-export.test.ts +2 -2
  251. package/src/node/__tests__/cli-setup.test.ts +163 -0
  252. package/src/node/__tests__/cli-site-snapshot.test.ts +73 -0
  253. package/src/node/__tests__/cli-site-token-env.test.ts +4 -1
  254. package/src/node/__tests__/cli-snapshot-meta.test.ts +84 -0
  255. package/src/node/__tests__/runtime.test.ts +38 -0
  256. package/src/node/index.ts +2 -0
  257. package/src/node/request-handler.ts +3 -1
  258. package/src/routes/api/__tests__/posts.test.ts +24 -0
  259. package/src/routes/api/__tests__/upload.test.ts +34 -0
  260. package/src/routes/api/export.ts +3 -3
  261. package/src/routes/api/internal/search-reindex.ts +1 -1
  262. package/src/routes/api/internal/sites.ts +0 -1
  263. package/src/routes/api/posts.ts +2 -0
  264. package/src/routes/api/public/posts.ts +21 -1
  265. package/src/routes/api/upload.ts +10 -3
  266. package/src/routes/compose.tsx +4 -0
  267. package/src/routes/dash/__tests__/github-sync-app.test.ts +365 -0
  268. package/src/routes/dash/settings.tsx +212 -70
  269. package/src/routes/pages/__tests__/post-page-round-trips.test.ts +211 -0
  270. package/src/routes/pages/__tests__/thread-order.test.ts +179 -0
  271. package/src/routes/pages/archive.tsx +17 -11
  272. package/src/routes/pages/featured.tsx +11 -5
  273. package/src/routes/pages/page.tsx +53 -31
  274. package/src/routes/pages/search.tsx +4 -2
  275. package/src/runtime/__tests__/readiness.test.ts +23 -0
  276. package/src/runtime/node.ts +49 -0
  277. package/src/runtime/readiness.ts +15 -0
  278. package/src/services/__tests__/bootstrap-setup-instance.test.ts +230 -0
  279. package/src/services/__tests__/custom-url.test.ts +34 -0
  280. package/src/services/__tests__/github-app-installations.test.ts +153 -0
  281. package/src/services/__tests__/github-sync-push.test.ts +46 -0
  282. package/src/services/__tests__/media.test.ts +31 -271
  283. package/src/services/__tests__/path.test.ts +56 -0
  284. package/src/services/__tests__/post-timeline.test.ts +127 -0
  285. package/src/services/__tests__/post.test.ts +74 -0
  286. package/src/services/bootstrap.ts +263 -44
  287. package/src/services/custom-url.ts +2 -2
  288. package/src/services/export-theme/layouts/_default/alias.html +27 -1
  289. package/src/services/export-theme/layouts/_default/list.html +2 -63
  290. package/src/services/export-theme/layouts/_default/rss.xml +27 -38
  291. package/src/services/export-theme/layouts/collections/list.html +3 -3
  292. package/src/services/export-theme/layouts/featured/list.html +1 -4
  293. package/src/services/export-theme/layouts/index.html +40 -26
  294. package/src/services/export-theme/layouts/partials/collection-members.html +100 -0
  295. package/src/services/export-theme/layouts/partials/collection-threads.html +33 -0
  296. package/src/services/export-theme/layouts/partials/featured-members.html +35 -0
  297. package/src/services/export-theme/layouts/partials/featured-thread.html +1 -1
  298. package/src/services/export-theme/layouts/partials/footer.html +1 -1
  299. package/src/services/export-theme/layouts/partials/head.html +1 -1
  300. package/src/services/export-theme/layouts/partials/header.html +5 -3
  301. package/src/services/export-theme/layouts/partials/jant-data.html +23 -0
  302. package/src/services/export-theme/layouts/partials/latest-members.html +48 -0
  303. package/src/services/export-theme/layouts/partials/smart-collection-members.html +129 -0
  304. package/src/services/export-theme/layouts/partials/thread-preview.html +1 -1
  305. package/src/services/export-theme/layouts/post/list.html +1 -1
  306. package/src/services/export-theme/layouts/smart_collection/list.html +24 -0
  307. package/src/services/export-theme/styles/main.css +0 -1
  308. package/src/services/export-theme/theme.toml +1 -1
  309. package/src/services/export.ts +630 -73
  310. package/src/services/github-app-installations.ts +171 -4
  311. package/src/services/github-sync.ts +69 -15
  312. package/src/services/mcp.ts +19 -1
  313. package/src/services/media.ts +9 -220
  314. package/src/services/path.ts +34 -1
  315. package/src/services/post.ts +214 -39
  316. package/src/services/site-admin.ts +3 -7
  317. package/src/services/site.ts +83 -31
  318. package/src/styles/ui.css +7 -119
  319. package/src/types/app-context.ts +16 -0
  320. package/src/types/bindings.ts +5 -0
  321. package/src/types/operations.ts +10 -0
  322. package/src/ui/dash/settings/GeneralContent.tsx +10 -8
  323. package/bin/commands/export.js +0 -118
  324. package/bin/commands/import-site.js +0 -2561
  325. package/bin/commands/migrate-text-attachments.js +0 -181
  326. package/dist/github-sync-BPAvT999.js +0 -7709
  327. package/src/client/multipart-upload.ts +0 -206
  328. package/src/client/tiptap/exitable-marks.ts +0 -73
  329. package/src/routes/api/__tests__/upload-multipart.test.ts +0 -739
  330. package/src/routes/api/internal/text-attachments.ts +0 -60
  331. package/src/routes/api/upload-multipart.ts +0 -366
@@ -1,28 +1,42 @@
1
- {{ define "main" }} {{- $pageSize := .Site.Params.page_size | default 10 -}} {{-
2
- /* Root posts are branch bundles (kind=section), so we iterate .Site.Pages, not
3
- .Site.RegularPages. */ -}} {{- $allPosts := where .Site.Pages "Type" "post" -}}
4
- {{- $pinned := where $allPosts "Params.pinned_at" "ne" nil -}} {{- $pinned =
5
- $pinned.ByDate.Reverse -}} {{- $public := where $allPosts "Params.visibility"
6
- "public" -}} {{- $public = where $public "Params.pinned_at" nil -}} {{- $main :=
7
- $public.ByDate.Reverse -}} {{- $paginator := .Paginate $main $pageSize -}}
8
-
9
- <section class="home">
10
- {{- if and (eq $paginator.PageNumber 1) $pinned -}}
11
- <div class="post-list post-list-pinned" aria-label="Pinned posts">
12
- {{- range $i, $p := $pinned -}} {{- if gt $i 0 -}}
13
- <hr class="feed-divider" aria-hidden="true" />
14
- {{- end -}} {{ partial "thread-preview.html" $p }} {{- end -}}
15
- </div>
16
- {{- end -}} {{- if $paginator.Pages -}}
17
- <div class="post-list post-list-main">
18
- {{- range $i, $p := $paginator.Pages -}} {{- if gt $i 0 -}}
19
- <hr class="feed-divider" aria-hidden="true" />
20
- {{- end -}} {{ partial "thread-preview.html" $p }} {{- end -}}
21
- </div>
22
- {{ partial "pagination.html" $paginator }} {{- else if not $pinned -}}
23
- <p class="empty-state">
24
- Nothing published yet. Write your first post to get started.
25
- </p>
1
+ {{ define "main" }}
2
+ {{- /*
3
+ The home page lists Latest the way Jant's does: one list, pinned roots
4
+ first, paginated as a whole (`latest-members`). The pinned roots on a
5
+ page, which only lead the list, keep a block of their own.
6
+ */ -}}
7
+ {{- $pageSize := .Site.Params.page_size | default 10 -}}
8
+ {{- $paginator := .Paginate (partial "latest-members.html" (dict "feed" false)) $pageSize -}}
9
+ {{- $pinned := slice -}}
10
+ {{- $main := slice -}}
11
+ {{- range $paginator.Pages -}}
12
+ {{- if .Params.pinned_at -}}
13
+ {{- $pinned = $pinned | append . -}}
14
+ {{- else -}}
15
+ {{- $main = $main | append . -}}
16
+ {{- end -}}
26
17
  {{- end -}}
27
- </section>
18
+
19
+ <section class="home">
20
+ {{- if $pinned -}}
21
+ <div class="post-list post-list-pinned" aria-label="Pinned posts">
22
+ {{- range $i, $p := $pinned -}}
23
+ {{- if gt $i 0 -}}<hr class="feed-divider" aria-hidden="true" />{{- end -}}
24
+ {{ partial "thread-preview.html" $p }}
25
+ {{- end -}}
26
+ </div>
27
+ {{- end -}}
28
+ {{- if $main -}}
29
+ <div class="post-list post-list-main">
30
+ {{- range $i, $p := $main -}}
31
+ {{- if gt $i 0 -}}<hr class="feed-divider" aria-hidden="true" />{{- end -}}
32
+ {{ partial "thread-preview.html" $p }}
33
+ {{- end -}}
34
+ </div>
35
+ {{- end -}}
36
+ {{- if $paginator.Pages -}}
37
+ {{ partial "pagination.html" $paginator }}
38
+ {{- else -}}
39
+ <p class="empty-state">Nothing published yet. Write your first post to get started.</p>
40
+ {{- end -}}
41
+ </section>
28
42
  {{ end }}
@@ -0,0 +1,100 @@
1
+ {{- /*
2
+ The Thread roots in a collection, in the order Jant lists them: the page
3
+ (`listCollectionThreadRootIdsForCollections` in `services/post.ts`) or the
4
+ feed (`listCollectionFeedEntriesForCollections`).
5
+
6
+ Takes a dict: `page`, the collection's section page, and `feed`, true for
7
+ its Atom feed.
8
+
9
+ A Thread belongs when its root lists the collection in `collections`.
10
+ Drafts and private roots are exported as Hugo drafts and never reach here;
11
+ they are checked again so a `--buildDrafts` preview agrees with Jant.
12
+
13
+ The page puts Threads pinned in this collection first, most recently
14
+ pinned first, then orders by `sort_order`, each order ending on the root
15
+ ID so no two Threads tie:
16
+ newest Thread activity (`last_activity_at`, else `date`), newest first
17
+ oldest the Thread's earliest published post, oldest first
18
+ rating_desc Threads with a rating before those without, by the highest
19
+ rating on any published post in the Thread, then as newest.
20
+ With fewer than two rated Threads it falls back to newest,
21
+ as Jant's page does.
22
+ The feed ignores pins and `sort_order`: Thread activity, newest first.
23
+
24
+ `src/__tests__/export-collection-order.test.ts` builds a site with Hugo
25
+ and compares the page and the feed with Jant's.
26
+ */ -}}
27
+ {{- $page := .page -}}
28
+ {{- $feed := .feed -}}
29
+ {{- $slug := $page.Params.slug | default $page.Slug -}}
30
+ {{- $roots := where (where site.Pages "Type" "post") "Kind" "section" -}}
31
+ {{- $members := slice -}}
32
+ {{- range $roots -}}
33
+ {{- $post := . -}}
34
+ {{- $params := .Params -}}
35
+ {{- $entry := false -}}
36
+ {{- range $params.collections -}}
37
+ {{- if eq .slug $slug -}}{{- $entry = . -}}{{- end -}}
38
+ {{- end -}}
39
+ {{- $visible := and (eq ($params.status | default "published") "published") (ne $params.visibility "private") -}}
40
+ {{- if and $entry $visible -}}
41
+ {{- $pinned := 0 -}}
42
+ {{- with $entry.pinned_at -}}{{- $pinned = (time.AsTime .).Unix -}}{{- end -}}
43
+ {{- $activity := $post.Date.Unix -}}
44
+ {{- with $params.last_activity_at -}}{{- $activity = (time.AsTime .).Unix -}}{{- end -}}
45
+ {{- $first := $post.Date.Unix -}}
46
+ {{- $rated := ne $params.rating nil -}}
47
+ {{- $rating := 0 -}}
48
+ {{- if $rated -}}{{- $rating = int $params.rating -}}{{- end -}}
49
+ {{- range $post.Pages -}}
50
+ {{- if eq (.Params.status | default "published") "published" -}}
51
+ {{- if lt .Date.Unix $first -}}{{- $first = .Date.Unix -}}{{- end -}}
52
+ {{- if ne .Params.rating nil -}}
53
+ {{- $rated = true -}}
54
+ {{- if gt (int .Params.rating) $rating -}}{{- $rating = int .Params.rating -}}{{- end -}}
55
+ {{- end -}}
56
+ {{- end -}}
57
+ {{- end -}}
58
+ {{- $members = $members | append (dict
59
+ "post" $post
60
+ "id" $params.id
61
+ "pinned" (cond $feed 0 $pinned)
62
+ "first" $first
63
+ "activity" $activity
64
+ "rated" $rated
65
+ "rating" $rating
66
+ ) -}}
67
+ {{- end -}}
68
+ {{- end -}}
69
+
70
+ {{- $order := "newest" -}}
71
+ {{- if not $feed -}}
72
+ {{- $order = $page.Params.sort_order | default "newest" -}}
73
+ {{- if and (eq $order "rating_desc") (le (len (where $members "rated" true)) 1) -}}
74
+ {{- $order = "newest" -}}
75
+ {{- end -}}
76
+ {{- end -}}
77
+
78
+ {{- /* One string key per Thread, fixed-width numbers first, so a single sort
79
+ orders by every key in turn. `oldest` sorts ascending, so its pin rank
80
+ counts down: the most recently pinned Thread gets the smallest. */ -}}
81
+ {{- $unpinnedRank := 99999999999 -}}
82
+ {{- $keyed := slice -}}
83
+ {{- range $members -}}
84
+ {{- $key := printf "%020d %020d %s" .pinned .activity .id -}}
85
+ {{- if eq $order "oldest" -}}
86
+ {{- $pinRank := cond (gt .pinned 0) (sub $unpinnedRank .pinned) $unpinnedRank -}}
87
+ {{- $key = printf "%020d %020d %s" $pinRank .first .id -}}
88
+ {{- else if eq $order "rating_desc" -}}
89
+ {{- $key = printf "%020d %d %02d %020d %s" .pinned (cond .rated 1 0) .rating .activity .id -}}
90
+ {{- end -}}
91
+ {{- $keyed = $keyed | append (dict "key" $key "post" .post) -}}
92
+ {{- end -}}
93
+
94
+ {{- $ordered := slice -}}
95
+ {{- if $keyed -}}
96
+ {{- range sort $keyed "key" (cond (eq $order "oldest") "asc" "desc") -}}
97
+ {{- $ordered = $ordered | append .post -}}
98
+ {{- end -}}
99
+ {{- end -}}
100
+ {{- return $ordered -}}
@@ -0,0 +1,33 @@
1
+ {{- /*
2
+ A collection page's Threads, each root with its replies in full, then the
3
+ pagination. Shared by manual and smart collections, which look the same to
4
+ a reader.
5
+
6
+ Takes a dict: `paginator`, and `empty`, the text shown when there are no
7
+ Threads.
8
+ */ -}}
9
+ {{- $paginator := .paginator -}}
10
+ {{- if $paginator.Pages -}}
11
+ <div class="post-list">
12
+ {{- range $i, $p := $paginator.Pages -}}
13
+ {{- if gt $i 0 -}}<hr class="feed-divider" aria-hidden="true" />{{- end -}}
14
+ {{- $replies := $p.Pages.ByWeight -}}
15
+ {{- $hasReplies := gt (len $replies) 0 -}}
16
+ <div class="thread thread-full{{ if $hasReplies }} thread-has-replies{{ end }}" data-slug="{{ $p.Params.slug | default $p.Slug }}">
17
+ <div class="thread-item thread-item-root">
18
+ {{ partial "post-card.html" $p }}
19
+ </div>
20
+ {{- if $hasReplies -}}
21
+ <section class="thread-replies" aria-label="Replies">
22
+ {{- range $replies -}}
23
+ {{ partial "reply.html" . }}
24
+ {{- end -}}
25
+ </section>
26
+ {{- end -}}
27
+ </div>
28
+ {{- end -}}
29
+ </div>
30
+ {{ partial "pagination.html" $paginator }}
31
+ {{- else -}}
32
+ <p class="empty-state">{{ .empty }}</p>
33
+ {{- end -}}
@@ -0,0 +1,35 @@
1
+ {{- /*
2
+ The Threads on Featured, in the order Jant lists them on the Featured page
3
+ and in `/featured/feed` (`listFeaturedThreadRootIds`): a Thread belongs
4
+ when any published post in it is featured and it is not private. Hidden
5
+ from Latest is no bar here.
6
+
7
+ Order: the newest publication among the Thread's featured posts
8
+ (`featured_sort_at`, which the export derives exactly that way), newest
9
+ first, then the root ID, newest first, so Threads whose featured posts
10
+ share a second don't tie.
11
+
12
+ `src/__tests__/export-feed-order.test.ts` builds a site with Hugo and
13
+ compares the page and the feed with Jant's.
14
+ */ -}}
15
+ {{- $roots := where (where site.Pages "Type" "post") "Kind" "section" -}}
16
+ {{- $keyed := slice -}}
17
+ {{- range $roots -}}
18
+ {{- $post := . -}}
19
+ {{- $params := .Params -}}
20
+ {{- $visible := and (eq ($params.status | default "published") "published") (ne $params.visibility "private") -}}
21
+ {{- if and $visible $params.featured_sort_at -}}
22
+ {{- $keyed = $keyed | append (dict
23
+ "key" (printf "%020d %s" (time.AsTime $params.featured_sort_at).Unix $params.id)
24
+ "post" $post
25
+ ) -}}
26
+ {{- end -}}
27
+ {{- end -}}
28
+
29
+ {{- $ordered := slice -}}
30
+ {{- if $keyed -}}
31
+ {{- range sort $keyed "key" "desc" -}}
32
+ {{- $ordered = $ordered | append .post -}}
33
+ {{- end -}}
34
+ {{- end -}}
35
+ {{- return $ordered -}}
@@ -8,7 +8,7 @@
8
8
  {{- $root := . -}}
9
9
  {{- $featuredIds := $root.Params.featured_post_ids | default slice -}}
10
10
  {{- $posts := slice $root -}}
11
- {{- range $root.Pages.ByDate -}}
11
+ {{- range $root.Pages.ByWeight -}}
12
12
  {{- $posts = $posts | append . -}}
13
13
  {{- end -}}
14
14
  {{- $lastIndex := sub (len $posts) 1 -}}
@@ -1,4 +1,4 @@
1
- {{- $jant := hugo.Data.jant -}}
1
+ {{- $jant := partial "jant-data.html" . -}}
2
2
  {{- $footerHtml := "" -}}
3
3
  {{- with $jant -}}{{- with .site_footer_html -}}{{- $footerHtml = . -}}{{- end -}}{{- end -}}
4
4
  {{- $showBranding := false -}}
@@ -1,4 +1,4 @@
1
- {{- $jant := hugo.Data.jant -}}
1
+ {{- $jant := partial "jant-data.html" . -}}
2
2
  {{- $siteTitle := .Site.Title -}}
3
3
  {{- $pageTitle := "" -}}
4
4
  {{- if .IsHome -}}
@@ -1,14 +1,16 @@
1
- {{- $jant := hugo.Data.jant -}}
1
+ {{- $jant := partial "jant-data.html" . -}}
2
2
  {{- $showAvatar := false -}}
3
3
  {{- with $jant -}}{{- if eq .show_header_avatar true -}}{{- $showAvatar = true -}}{{- end -}}{{- end -}}
4
4
  {{- $avatarUrl := "" -}}
5
5
  {{- with $jant -}}{{- with .site_avatar_url -}}{{- $avatarUrl = . -}}{{- end -}}{{- end -}}
6
6
 
7
- {{- /* Split nav items by placement: "header" (inline) vs "more" (supplemental dropdown). */ -}}
7
+ {{- /* Split nav items by placement: "header" (inline) vs "more" (supplemental dropdown).
8
+ `settings` is exported for an import back into Jant; the static site has no page for it. */ -}}
8
9
  {{- $headerItems := slice -}}
9
10
  {{- $moreItems := slice -}}
10
11
  {{- with $jant -}}{{- range .nav -}}
11
- {{- if eq .placement "more" -}}
12
+ {{- if eq .system_key "settings" -}}
13
+ {{- else if eq .placement "more" -}}
12
14
  {{- $moreItems = $moreItems | append . -}}
13
15
  {{- else -}}
14
16
  {{- $headerItems = $headerItems | append . -}}
@@ -0,0 +1,23 @@
1
+ {{- /*
2
+ Returns the `jant` table from `data/jant.toml` — nav, branding, and the
3
+ collections directory.
4
+
5
+ Hugo moved site data to `hugo.Data` in v0.160.0 and deprecated `site.Data`
6
+ in v0.156.0, so neither accessor works everywhere: `hugo.Data` is a render
7
+ error before it existed, and `site.Data` is a deprecation warning today and
8
+ a removal tomorrow. Only the taken branch of an `if` is evaluated, so
9
+ branching on the running version reads whichever one that version has.
10
+ `hugo.Version` compares semantically, not as a string.
11
+
12
+ Hugo rewrites a single `return` per template, hence the assignment rather
13
+ than a `return` in each branch. Every template reads the data through this
14
+ partial, so the day the old branch stops being worth carrying there is one
15
+ place to change.
16
+ */ -}}
17
+ {{- $data := dict -}}
18
+ {{- if ge hugo.Version "0.160.0" -}}
19
+ {{- $data = hugo.Data -}}
20
+ {{- else -}}
21
+ {{- $data = site.Data -}}
22
+ {{- end -}}
23
+ {{- return (index $data "jant") -}}
@@ -0,0 +1,48 @@
1
+ {{- /*
2
+ The Thread roots on Latest, in the order Jant lists them: the home page
3
+ (`assembleTimeline`, `posts.list`) or `/latest/feed`
4
+ (`latestFeedSelection` with `ignorePinnedSort`).
5
+
6
+ Takes a dict: `feed`, true for the Atom feed.
7
+
8
+ A root is on Latest when it is published and public: Hidden from Latest
9
+ and private roots are left out, as are drafts, which are exported as Hugo
10
+ drafts and never reach here; status and visibility are checked again so a
11
+ `--buildDrafts` preview agrees with Jant.
12
+
13
+ Order, each key after the one before it:
14
+ pinned page only: pinned roots first, most recently pinned first
15
+ activity Thread activity (`last_activity_at`, else `date`), newest
16
+ first, so a Thread that gains a reply comes back up; a quiet
17
+ reply doesn't move it, because Jant doesn't count it
18
+ ID newest first, so no two roots tie
19
+
20
+ `src/__tests__/export-feed-order.test.ts` builds a site with Hugo and
21
+ compares the page and the feed with Jant's.
22
+ */ -}}
23
+ {{- $feed := .feed -}}
24
+ {{- $roots := where (where site.Pages "Type" "post") "Kind" "section" -}}
25
+ {{- $keyed := slice -}}
26
+ {{- range $roots -}}
27
+ {{- $params := .Params -}}
28
+ {{- if and (eq ($params.status | default "published") "published") (eq $params.visibility "public") -}}
29
+ {{- $pinned := 0 -}}
30
+ {{- if not $feed -}}
31
+ {{- with $params.pinned_at -}}{{- $pinned = (time.AsTime .).Unix -}}{{- end -}}
32
+ {{- end -}}
33
+ {{- $activity := .Date.Unix -}}
34
+ {{- with $params.last_activity_at -}}{{- $activity = (time.AsTime .).Unix -}}{{- end -}}
35
+ {{- $keyed = $keyed | append (dict
36
+ "key" (printf "%020d %020d %s" $pinned $activity $params.id)
37
+ "post" .
38
+ ) -}}
39
+ {{- end -}}
40
+ {{- end -}}
41
+
42
+ {{- $ordered := slice -}}
43
+ {{- if $keyed -}}
44
+ {{- range sort $keyed "key" "desc" -}}
45
+ {{- $ordered = $ordered | append .post -}}
46
+ {{- end -}}
47
+ {{- end -}}
48
+ {{- return $ordered -}}
@@ -0,0 +1,129 @@
1
+ {{- /*
2
+ The Thread roots a smart collection's conditions select, in its order.
3
+
4
+ The same set and order Jant shows a signed-out reader on the smart
5
+ collection's page (`smartCollections.toPostFilters` handed to
6
+ `posts.list`), computed from the exported front matter so the page keeps
7
+ up with the posts in this repository. Every condition reads the root:
8
+
9
+ format `format`
10
+ title `title`; for a quote, `source_name`, which is what Jant
11
+ stores in the title column
12
+ year `date`, the publication time, in UTC
13
+ media the root's own `media` entries: `any`, `none`, or a list of
14
+ kinds, any one of which matches
15
+ replies whether the root has published replies
16
+ visibility `public` and `latest_hidden` match `visibility`; `featured`
17
+ matches a root with `featured_at`
18
+ collection a `collections` entry with that slug
19
+
20
+ Drafts and private roots are exported as Hugo drafts and never reach here;
21
+ they are checked again so a `--buildDrafts` preview agrees with Jant.
22
+
23
+ Takes a dict: `page`, the smart collection's section page, and `feed`,
24
+ true for its Atom feed.
25
+
26
+ Orders, each ending on the post ID so no two roots tie:
27
+ newest Thread activity (`last_activity_at`, else `date`), newest first
28
+ oldest publication, oldest first
29
+ rating_desc rated before unrated, higher rating first, then as newest.
30
+ On the page, fewer than two rated roots fall back to
31
+ newest, as Jant's page does; the feed keeps the stored
32
+ order, as Jant's feed does.
33
+
34
+ `src/__tests__/export-smart-collection.test.ts` builds a site with Hugo
35
+ and compares every condition and order against Jant's own list.
36
+ */ -}}
37
+ {{- $page := .page -}}
38
+ {{- $feed := .feed -}}
39
+ {{- $selection := $page.Params.selection | default dict -}}
40
+ {{- $roots := where (where site.Pages "Type" "post") "Kind" "section" -}}
41
+ {{- $members := slice -}}
42
+ {{- range $roots -}}
43
+ {{- $post := . -}}
44
+ {{- $params := .Params -}}
45
+ {{- $matches := and (eq ($params.status | default "published") "published") (ne $params.visibility "private") -}}
46
+ {{- if and $matches (isset $selection "format") -}}
47
+ {{- $matches = eq $params.format $selection.format -}}
48
+ {{- end -}}
49
+ {{- if and $matches (isset $selection "title") -}}
50
+ {{- $title := $params.title -}}
51
+ {{- if eq $params.format "quote" -}}{{- $title = $params.source_name -}}{{- end -}}
52
+ {{- $matches = eq (gt (len (string ($title | default ""))) 0) $selection.title -}}
53
+ {{- end -}}
54
+ {{- if and $matches (isset $selection "year") -}}
55
+ {{- $matches = eq $post.Date.UTC.Year (int $selection.year) -}}
56
+ {{- end -}}
57
+ {{- if and $matches (isset $selection "media") -}}
58
+ {{- $media := $params.media | default slice -}}
59
+ {{- $wanted := $selection.media -}}
60
+ {{- if reflect.IsSlice $wanted -}}
61
+ {{- $found := false -}}
62
+ {{- range $media -}}{{- if in $wanted .kind -}}{{- $found = true -}}{{- end -}}{{- end -}}
63
+ {{- $matches = $found -}}
64
+ {{- else if eq $wanted "any" -}}
65
+ {{- $matches = gt (len $media) 0 -}}
66
+ {{- else -}}
67
+ {{- $matches = eq (len $media) 0 -}}
68
+ {{- end -}}
69
+ {{- end -}}
70
+ {{- if and $matches (isset $selection "replies") -}}
71
+ {{- $matches = eq (gt (len $post.Pages) 0) $selection.replies -}}
72
+ {{- end -}}
73
+ {{- if and $matches (isset $selection "visibility") -}}
74
+ {{- if eq $selection.visibility "featured" -}}
75
+ {{- $matches = ne ($params.featured_at | default "") "" -}}
76
+ {{- else -}}
77
+ {{- $matches = eq $params.visibility $selection.visibility -}}
78
+ {{- end -}}
79
+ {{- end -}}
80
+ {{- if and $matches (isset $selection "collection") -}}
81
+ {{- $inCollection := false -}}
82
+ {{- range $params.collections -}}
83
+ {{- if eq .slug $selection.collection -}}{{- $inCollection = true -}}{{- end -}}
84
+ {{- end -}}
85
+ {{- $matches = $inCollection -}}
86
+ {{- end -}}
87
+
88
+ {{- if $matches -}}
89
+ {{- $activity := $post.Date.Unix -}}
90
+ {{- with $params.last_activity_at -}}{{- $activity = (time.AsTime .).Unix -}}{{- end -}}
91
+ {{- $rated := ne $params.rating nil -}}
92
+ {{- $rating := 0 -}}
93
+ {{- if $rated -}}{{- $rating = int $params.rating -}}{{- end -}}
94
+ {{- $members = $members | append (dict
95
+ "post" $post
96
+ "id" $params.id
97
+ "published" $post.Date.Unix
98
+ "activity" $activity
99
+ "rated" $rated
100
+ "rating" $rating
101
+ ) -}}
102
+ {{- end -}}
103
+ {{- end -}}
104
+
105
+ {{- $order := $page.Params.sort_order | default "newest" -}}
106
+ {{- if and (not $feed) (eq $order "rating_desc") (le (len (where $members "rated" true)) 1) -}}
107
+ {{- $order = "newest" -}}
108
+ {{- end -}}
109
+
110
+ {{- /* One string key per root, fixed-width numbers first, so a single sort
111
+ orders by every key in turn. */ -}}
112
+ {{- $keyed := slice -}}
113
+ {{- range $members -}}
114
+ {{- $key := printf "%020d %s" .activity .id -}}
115
+ {{- if eq $order "oldest" -}}
116
+ {{- $key = printf "%020d %s" .published .id -}}
117
+ {{- else if eq $order "rating_desc" -}}
118
+ {{- $key = printf "%d %02d %020d %s" (cond .rated 1 0) .rating .activity .id -}}
119
+ {{- end -}}
120
+ {{- $keyed = $keyed | append (dict "key" $key "post" .post) -}}
121
+ {{- end -}}
122
+
123
+ {{- $ordered := slice -}}
124
+ {{- if $keyed -}}
125
+ {{- range sort $keyed "key" (cond (eq $order "oldest") "asc" "desc") -}}
126
+ {{- $ordered = $ordered | append .post -}}
127
+ {{- end -}}
128
+ {{- end -}}
129
+ {{- return $ordered -}}
@@ -20,7 +20,7 @@
20
20
  */ -}}
21
21
  {{- $root := . -}}
22
22
  {{- $replies := where $root.Pages "Params.visibility" "public" -}}
23
- {{- $replies = $replies.ByDate -}}
23
+ {{- $replies = $replies.ByWeight -}}
24
24
  {{- $replyCount := len $replies -}}
25
25
  {{- if eq $replyCount 0 -}}
26
26
  {{ partial "post-card.html" $root }}
@@ -5,7 +5,7 @@
5
5
  {{- $media := $root.Params.media | default slice -}}
6
6
  {{- $collections := $root.Params.collections | default slice -}}
7
7
  {{- $linkUrl := $root.Params.link_url -}}
8
- {{- $replies := $root.Pages.ByDate -}}
8
+ {{- $replies := $root.Pages.ByWeight -}}
9
9
  {{- $hasReplies := gt (len $replies) 0 -}}
10
10
  <article class="thread thread-{{ $format }}{{ if $hasReplies }} thread-has-replies{{ end }}" id="{{ $slug }}" data-format="{{ $format }}" data-slug="{{ $slug }}"
11
11
  {{- if $root.Params.pinned_at }} data-post-pinned{{ end -}}
@@ -0,0 +1,24 @@
1
+ {{ define "main" }}
2
+ {{- /*
3
+ A smart collection's page (`type: smart_collection`). The members come
4
+ from its conditions, applied to the posts in this site by the
5
+ `smart-collection-members` partial.
6
+ */ -}}
7
+ {{- $posts := partial "smart-collection-members.html" (dict "page" . "feed" false) -}}
8
+ {{- $pageSize := .Site.Params.page_size | default 10 -}}
9
+ {{- $paginator := .Paginate $posts $pageSize -}}
10
+
11
+ <section class="section section-collection section-smart-collection">
12
+ <header class="section-header">
13
+ <h1 class="section-title">{{ .Title }}</h1>
14
+ {{- with .Params.summary_text -}}
15
+ <p class="section-summary">{{ . }}</p>
16
+ {{- end -}}
17
+ {{- with len $posts -}}
18
+ <p class="section-meta">{{ . }} {{ if eq . 1 }}thread{{ else }}threads{{ end }}</p>
19
+ {{- end -}}
20
+ {{ .Content }}
21
+ </header>
22
+ {{ partial "collection-threads.html" (dict "paginator" $paginator "empty" "Nothing matches these conditions yet.") }}
23
+ </section>
24
+ {{ end }}
@@ -693,7 +693,6 @@ time {
693
693
  .home-branding-credit {
694
694
  margin-top: var(--space-xl);
695
695
  padding-bottom: var(--space-xl);
696
- text-align: center;
697
696
  color: var(--site-text-secondary);
698
697
  font-size: var(--type-base);
699
698
  }
@@ -5,7 +5,7 @@ description = "Default theme packaged with Jant exports."
5
5
  homepage = "https://jant.so"
6
6
  tags = ["blog", "microblog", "minimal"]
7
7
  features = ["pagination", "aliases"]
8
- min_version = "0.160.1"
8
+ min_version = "0.147.7"
9
9
 
10
10
  [author]
11
11
  name = "Jant"