@jant/core 0.10.0 → 0.12.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.
- package/bin/commands/db/execute-file.js +1 -1
- package/bin/commands/db/export.js +1 -1
- package/bin/commands/deploy.js +179 -0
- package/bin/commands/migrate.js +4 -4
- package/bin/commands/posts/rebuild-html.js +1 -1
- package/bin/commands/reset-password.js +1 -1
- package/bin/commands/search/reindex.js +1 -1
- package/bin/commands/setup.js +4 -2
- package/bin/commands/site/export.js +3 -0
- package/bin/commands/site/import.js +178 -91
- package/bin/commands/site/pull-media.js +3 -2
- package/bin/commands/site/snapshot/export.js +3 -1
- package/bin/commands/site/snapshot/import.js +3 -2
- package/bin/commands/start.js +44 -0
- package/bin/commands/telegram/register-webhooks.js +1 -1
- package/bin/commands/uploads/cleanup.js +48 -9
- package/bin/jant.js +39 -4
- package/bin/lib/cloudflare-setup.js +499 -0
- package/bin/lib/d1-query.js +26 -1
- package/bin/lib/import-sources.js +151 -0
- package/bin/lib/node-env.js +14 -9
- package/bin/lib/r2-query.js +2 -2
- package/bin/lib/runtime-target.js +1 -1
- package/bin/lib/site-pull-media.js +56 -4
- package/bin/lib/site-snapshot.js +39 -2
- package/bin/lib/sql-export.js +66 -10
- package/dist/{app-DIVtyB4m.js → app-DSwsDBD0.js} +38257 -9662
- package/dist/client/.vite/manifest.json +38 -38
- package/dist/client/_assets/chunks/{create-editor-B-m7X7S5.js → create-editor-5Y49x7h5.js} +2 -2
- package/dist/client/_assets/chunks/{footnote-rail-CmeoVtnU.js → footnote-rail-BJwswtVQ.js} +1 -1
- package/dist/client/_assets/chunks/{settings-paths-C-ZZBTau.js → settings-paths-h6RjIe3C.js} +2 -2
- package/dist/client/_assets/chunks/{slug-format-BcIsNKz-.js → slug-format-Dsi0e9Xn.js} +1 -1
- package/dist/client/_assets/chunks/{slugify-373citbs.js → slugify-DlHLyUHS.js} +1 -1
- package/dist/client/_assets/chunks/sortable-list-DYMcJrlS.js +2 -0
- package/dist/client/_assets/chunks/unsafe-svg-DxrzM_Gb.js +2 -0
- package/dist/client/_assets/client-BaqmpPQ-.css +2 -0
- package/dist/client/_assets/client-DPByjWoU.js +296 -0
- package/dist/client/_assets/{client-auth-BpkkKTsV.js → client-auth-CPqPTX1B.js} +2 -2
- package/dist/client/_assets/client-author-CGVvrNZ8.css +2 -0
- package/dist/client/_assets/{client-compose-C-DXzcFR.js → client-compose-CzEwT5qX.js} +4 -4
- package/dist/client/_assets/{client-manage-BfT7ht4M.js → client-manage-CF7x21L4.js} +37 -37
- package/dist/client/_assets/{client-settings-CGR_nZ78.js → client-settings-DIM44Zqh.js} +2 -2
- package/dist/{url-CKlGzvdN.js → constants-DEgyqWDl.js} +340 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +33 -1
- package/dist/node.js +57 -13
- package/package.json +43 -48
- package/src/__tests__/api-docs.test.ts +168 -1
- package/src/__tests__/bin/deploy.test.ts +163 -0
- package/src/__tests__/bin/import-sources.test.ts +85 -0
- package/src/__tests__/bin/uploads-cleanup.test.ts +66 -26
- package/src/__tests__/cli-commands.test.ts +40 -0
- package/src/__tests__/config-docs.test.ts +119 -16
- package/src/__tests__/custom-url-redirects.test.ts +108 -0
- package/src/__tests__/export-collection-custom-urls.test.ts +69 -0
- package/src/__tests__/export-docs.test.ts +113 -41
- package/src/__tests__/export-feed-ids.test.ts +1 -0
- package/src/__tests__/export-format-version.test.ts +88 -0
- package/src/__tests__/export-hugo-build.test.ts +143 -8
- package/src/__tests__/export-import-roundtrip.test.ts +3 -2
- package/src/__tests__/export-service.test.ts +44 -15
- package/src/__tests__/export-smart-collection.test.ts +1 -1
- package/src/__tests__/feed-docs.test.ts +287 -21
- package/src/__tests__/feed-reply-addresses.test.ts +100 -0
- package/src/__tests__/feeds-disabled.test.ts +98 -0
- package/src/__tests__/fixtures/export-format/1.json +76 -0
- package/src/__tests__/fixtures/export-format/2.json +80 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2u5e5/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/faqyt/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/bought-too-many-lemons-again/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/city-walks/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/evf9j/_index.md +152 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/3zqv7/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/_index.md +39 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/j4v0q/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +57 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +46 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/data/jant.toml +124 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/_redirects +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/40bc6cd1f12e-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/meta.json +11 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/297kg/_index.md +14 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/2u5e5/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/faqyt/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/bought-too-many-lemons-again/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/city-walks/_index.md +14 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/evf9j/_index.md +129 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/fixture-draft/_index.md +17 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/fixture-quotes/_index.md +13 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/fixture-text-attachment/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/3zqv7/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/j4v0q/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +40 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +50 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/data/jant.toml +155 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/_redirects +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/3c46a9ea6fe0-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m50607a6e8h8gfpa8byqtt7h.md +3 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.11.0/snapshot/db.sql +339 -0
- package/src/__tests__/fixtures/releases/0.11.0/snapshot/meta.json +11 -0
- package/src/__tests__/helpers/app.ts +6 -1
- package/src/__tests__/helpers/d1-round-trips.ts +213 -0
- package/src/__tests__/helpers/export-fixtures.ts +1 -0
- package/src/__tests__/import-refused-aliases.test.ts +98 -0
- package/src/__tests__/import-site-command.test.ts +73 -8
- package/src/__tests__/package-dependencies.test.ts +123 -0
- package/src/__tests__/public-page-round-trips.test.ts +203 -0
- package/src/__tests__/public-types.test.ts +64 -0
- package/src/__tests__/release-fixtures.test.ts +79 -24
- package/src/__tests__/release-version.test.ts +84 -0
- package/src/__tests__/site-pull-media.test.ts +48 -0
- package/src/__tests__/snapshot-tables.test.ts +37 -0
- package/src/__tests__/sql-export.test.ts +21 -1
- package/src/__tests__/stored-file-headers.test.ts +94 -0
- package/src/__tests__/template-deploy-workflow.test.ts +57 -0
- package/src/__tests__/theme-docs.test.ts +113 -24
- package/src/__tests__/toolchain-versions.test.ts +54 -0
- package/src/__tests__/trailing-slash-redirect.test.ts +61 -0
- package/src/__tests__/vite-config-graph.test.ts +98 -0
- package/src/__tests__/vite-config.test.ts +32 -0
- package/src/app.tsx +96 -67
- package/src/client/__tests__/compose-bridge-image-upload.test.ts +1 -0
- package/src/client/__tests__/compose-bridge.test.ts +87 -0
- package/src/client/__tests__/compose-shortcuts.test.ts +4 -4
- package/src/client/__tests__/footnote-rail.test.ts +1 -1
- package/src/client/__tests__/lazy-entries.test.ts +1 -1
- package/src/client/__tests__/media-scroll-hint.test.ts +2 -2
- package/src/client/avatar-upload.ts +10 -10
- package/src/client/components/__tests__/jant-compose-dialog.test.ts +295 -4
- package/src/client/components/__tests__/jant-compose-editor.test.ts +34 -0
- package/src/client/components/__tests__/jant-settings-general.test.ts +0 -32
- package/src/client/components/compose-types.ts +14 -0
- package/src/client/components/jant-compose-dialog.ts +96 -41
- package/src/client/components/jant-compose-editor.ts +21 -4
- package/src/client/components/jant-config-editor.ts +4 -6
- package/src/client/components/jant-media-lightbox.ts +4 -4
- package/src/client/components/jant-settings-general.ts +0 -4
- package/src/client/components/nav-manager-types.ts +6 -5
- package/src/client/compose-bridge.ts +15 -4
- package/src/client/compose-launch.ts +4 -6
- package/src/client/compose-shortcuts.ts +1 -1
- package/src/client/footnote-rail.ts +1 -1
- package/src/client/icons.ts +5 -6
- package/src/client/lazy-entries.ts +1 -1
- package/src/client/media-scroll-hint.ts +2 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +55 -0
- package/src/client/tiptap/markdown-clipboard.ts +50 -2
- package/src/client/upload-session.ts +7 -6
- package/src/db/__tests__/backfill-external-redirects.test.ts +59 -0
- package/src/db/__tests__/backfill-featured-discover.test.ts +56 -0
- package/src/db/__tests__/d1-query.test.ts +29 -0
- package/src/db/__tests__/migration-rehearsal.test.ts +2 -2
- package/src/db/backfills/0007_restore_external_redirect_scheme.sql +20 -0
- package/src/db/backfills/0008_turn_off_featured_only_discover.sql +11 -0
- package/src/i18n/locales/public/en.po +46 -48
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +45 -46
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +45 -46
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +15 -29
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +15 -29
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +15 -29
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/index.ts +43 -2
- package/src/lib/__tests__/api-settings.test.ts +3 -3
- package/src/lib/__tests__/constants.test.ts +10 -0
- package/src/lib/__tests__/discover.test.ts +8 -9
- package/src/lib/__tests__/env-values.test.ts +125 -0
- package/src/lib/__tests__/feed-path.test.ts +29 -0
- package/src/lib/__tests__/feed.test.ts +50 -22
- package/src/lib/__tests__/filter-dimensions.test.ts +22 -8
- package/src/lib/__tests__/icons.test.ts +21 -10
- package/src/lib/__tests__/post-list-cursor.test.ts +0 -10
- package/src/lib/__tests__/rate-limit.test.ts +22 -7
- package/src/lib/__tests__/resolve-config.test.ts +5 -3
- package/src/lib/__tests__/schemas.test.ts +72 -23
- package/src/lib/__tests__/slugify.test.ts +9 -0
- package/src/lib/__tests__/startup-config.test.ts +12 -0
- package/src/lib/__tests__/storage-s3.test.ts +214 -0
- package/src/lib/__tests__/theme.test.ts +20 -1
- package/src/lib/__tests__/time.test.ts +56 -0
- package/src/lib/__tests__/timeline.test.ts +46 -0
- package/src/lib/__tests__/url-fetch.test.ts +65 -1
- package/src/lib/__tests__/url.test.ts +60 -1
- package/src/lib/api-nav-items.ts +16 -20
- package/src/lib/api-post-input.ts +34 -1
- package/src/lib/api-posts.ts +128 -24
- package/src/lib/api-public-posts.ts +31 -38
- package/src/lib/api-search.ts +49 -2
- package/src/lib/api-settings.ts +159 -54
- package/src/lib/api-threads.ts +34 -11
- package/src/lib/constants.ts +26 -0
- package/src/lib/discover.ts +7 -23
- package/src/lib/env-values.ts +140 -0
- package/src/lib/env.ts +203 -12
- package/src/lib/feed-path.ts +8 -2
- package/src/lib/feed-policy.ts +110 -7
- package/src/lib/feed.ts +69 -25
- package/src/lib/filter-dimensions.ts +17 -10
- package/src/lib/github-sync-site-config.ts +1 -0
- package/src/lib/hugo-markdown.ts +5 -6
- package/src/lib/icons.ts +96 -34
- package/src/lib/navigation.ts +4 -1
- package/src/lib/post-display.ts +13 -9
- package/src/lib/post-list-cursor.ts +33 -29
- package/src/lib/public-storage.ts +43 -0
- package/src/lib/rate-limit.ts +31 -16
- package/src/lib/render.tsx +5 -0
- package/src/lib/resolve-config.ts +16 -19
- package/src/lib/schemas.ts +248 -180
- package/src/lib/slugify.ts +6 -1
- package/src/lib/sse.ts +1 -1
- package/src/lib/startup-config.ts +20 -1
- package/src/lib/theme.ts +8 -5
- package/src/lib/thread-fold.ts +6 -0
- package/src/lib/thread-query.ts +19 -24
- package/src/lib/time.ts +137 -17
- package/src/lib/timeline.ts +76 -31
- package/src/lib/url-fetch.ts +141 -40
- package/src/lib/url.ts +86 -1
- package/src/lib/view.ts +3 -2
- package/src/middleware/__tests__/auth.test.ts +27 -0
- package/src/middleware/__tests__/cors.test.ts +54 -0
- package/src/middleware/__tests__/cross-origin.test.ts +149 -0
- package/src/middleware/__tests__/onboarding.test.ts +5 -3
- package/src/middleware/__tests__/public-content-access.test.ts +2 -42
- package/src/middleware/__tests__/secure-headers.test.ts +40 -42
- package/src/middleware/auth.ts +34 -3
- package/src/middleware/config.ts +44 -2
- package/src/middleware/cors.ts +4 -4
- package/src/middleware/cross-origin.ts +124 -0
- package/src/middleware/error-handler.ts +7 -0
- package/src/middleware/onboarding.ts +12 -3
- package/src/middleware/public-content-access.ts +3 -26
- package/src/middleware/secure-headers.ts +32 -37
- package/src/node/__tests__/cli-deploy-setup.test.ts +373 -0
- package/src/node/__tests__/cli-deploy.test.ts +55 -0
- package/src/node/__tests__/cli-migrate.test.ts +2 -2
- package/src/node/__tests__/cli-runtime-target.test.ts +13 -2
- package/src/node/__tests__/cli-site-snapshot.test.ts +57 -0
- package/src/node/__tests__/cli-snapshot-meta.test.ts +11 -1
- package/src/node/__tests__/cli-sql-export.test.ts +25 -1
- package/src/node/__tests__/cli-start.test.ts +66 -0
- package/src/node/__tests__/request-handler.test.ts +37 -0
- package/src/node/__tests__/runtime.test.ts +56 -1
- package/src/node/request-handler.ts +58 -5
- package/src/node/runtime.ts +37 -11
- package/src/preset.css +3 -3
- package/src/routes/__tests__/compose.test.ts +84 -0
- package/src/routes/api/__tests__/collections.test.ts +68 -0
- package/src/routes/api/__tests__/mcp.test.ts +164 -9
- package/src/routes/api/__tests__/media.test.ts +9 -1
- package/src/routes/api/__tests__/nav-items.test.ts +27 -1
- package/src/routes/api/__tests__/posts.test.ts +269 -78
- package/src/routes/api/__tests__/search.test.ts +17 -4
- package/src/routes/api/__tests__/settings.test.ts +119 -85
- package/src/routes/api/__tests__/telegram.test.ts +11 -6
- package/src/routes/api/__tests__/threads.test.ts +11 -0
- package/src/routes/api/__tests__/upload-response.test.ts +48 -0
- package/src/routes/api/__tests__/uploads.test.ts +35 -2
- package/src/routes/api/collections.ts +3 -3
- package/src/routes/api/custom-urls.ts +2 -1
- package/src/routes/api/export.ts +1 -0
- package/src/routes/api/internal/__tests__/post-body-html.test.ts +19 -0
- package/src/routes/api/internal/__tests__/uploads.test.ts +2 -0
- package/src/routes/api/internal/sites.ts +16 -4
- package/src/routes/api/mcp.ts +1 -0
- package/src/routes/api/media.ts +7 -8
- package/src/routes/api/nav-items.ts +2 -1
- package/src/routes/api/posts.ts +18 -24
- package/src/routes/api/public/__tests__/posts.test.ts +15 -0
- package/src/routes/api/public/__tests__/threads-collections.test.ts +12 -45
- package/src/routes/api/public/__tests__/threads.test.ts +41 -9
- package/src/routes/api/public/posts.ts +2 -2
- package/src/routes/api/public/threads.ts +16 -26
- package/src/routes/api/search.ts +7 -41
- package/src/routes/api/settings.ts +32 -28
- package/src/routes/api/smart-collections.ts +6 -1
- package/src/routes/api/threads.ts +25 -26
- package/src/routes/api/upload.ts +6 -21
- package/src/routes/api/uploads.ts +14 -20
- package/src/routes/auth/__tests__/dev.test.ts +16 -13
- package/src/routes/auth/__tests__/hosted-sso.test.ts +51 -0
- package/src/routes/auth/__tests__/setup-auth.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-discover.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-flow.test.ts +32 -0
- package/src/routes/auth/__tests__/setup-rate-limit.test.ts +72 -0
- package/src/routes/auth/__tests__/setup-steps.test.ts +2 -0
- package/src/routes/auth/__tests__/signin.test.ts +167 -2
- package/src/routes/auth/dev.ts +4 -6
- package/src/routes/auth/hosted-sso.ts +9 -6
- package/src/routes/auth/setup.tsx +35 -5
- package/src/routes/auth/signin.tsx +96 -1
- package/src/routes/compose.tsx +47 -47
- package/src/routes/dash/__tests__/settings-avatar.test.ts +59 -4
- package/src/routes/dash/__tests__/settings-demo-locks.test.ts +147 -0
- package/src/routes/dash/custom-urls.tsx +2 -0
- package/src/routes/dash/settings.tsx +79 -32
- package/src/routes/feed/__tests__/feed.test.ts +93 -3
- package/src/routes/feed/__tests__/sitemap.test.ts +42 -0
- package/src/routes/feed/feed.ts +130 -175
- package/src/routes/feed/sitemap.ts +9 -7
- package/src/routes/pages/__tests__/archive-years.test.ts +45 -0
- package/src/routes/pages/__tests__/collection-routing.test.ts +40 -0
- package/src/routes/pages/__tests__/collections.test.ts +3 -0
- package/src/routes/pages/__tests__/language-routing.test.ts +31 -0
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +44 -12
- package/src/routes/pages/__tests__/search.test.ts +5 -2
- package/src/routes/pages/__tests__/thread-gap.test.ts +207 -0
- package/src/routes/pages/archive.tsx +69 -111
- package/src/routes/pages/brand.tsx +1 -0
- package/src/routes/pages/collection.tsx +86 -120
- package/src/routes/pages/collections.tsx +2 -0
- package/src/routes/pages/featured.tsx +7 -2
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/latest.tsx +6 -2
- package/src/routes/pages/new.tsx +1 -0
- package/src/routes/pages/page.tsx +113 -66
- package/src/routes/pages/search.tsx +8 -4
- package/src/routes/pages/smart-collection.tsx +11 -70
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/pages/theme-sample.tsx +1 -0
- package/src/runtime/__tests__/readiness.test.ts +16 -0
- package/src/runtime/cloudflare.ts +2 -3
- package/src/runtime/index.ts +3 -1
- package/src/runtime/node.ts +3 -5
- package/src/runtime/readiness.ts +5 -0
- package/src/services/__tests__/auth.test.ts +115 -0
- package/src/services/__tests__/collection.test.ts +11 -4
- package/src/services/__tests__/github-sync-webhook.test.ts +78 -0
- package/src/services/__tests__/hosted-handoff.test.ts +208 -1
- package/src/services/__tests__/media.test.ts +47 -27
- package/src/services/__tests__/navigation.test.ts +67 -15
- package/src/services/__tests__/post.test.ts +103 -56
- package/src/services/__tests__/search.test.ts +38 -0
- package/src/services/__tests__/settings.test.ts +2 -14
- package/src/services/__tests__/smart-collection.test.ts +2 -2
- package/src/services/__tests__/telegram-ingest.test.ts +113 -0
- package/src/services/__tests__/thread.test.ts +26 -11
- package/src/services/auth.ts +36 -4
- package/src/services/collection.ts +141 -76
- package/src/services/custom-url.ts +11 -4
- package/src/services/export-theme/assets/client-site.css +1 -1
- package/src/services/export-theme/assets/client-site.js +2 -2
- package/src/services/export-theme/layouts/_default/baseof.html +1 -1
- package/src/services/export-theme/layouts/collection/single.html +1 -1
- package/src/services/export-theme/layouts/partials/featured-thread.html +8 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/media-gallery.html +6 -3
- package/src/services/export-theme/layouts/smart_collection/list.html +1 -1
- package/src/services/export-theme/styles/main.css +3 -3
- package/src/services/export.ts +70 -20
- package/src/services/github-sync.ts +10 -10
- package/src/services/hosted-handoff.ts +106 -6
- package/src/services/index.ts +3 -1
- package/src/services/language.ts +33 -0
- package/src/services/mcp.ts +176 -438
- package/src/services/media.ts +69 -21
- package/src/services/navigation.ts +19 -4
- package/src/services/path.ts +45 -3
- package/src/services/post.ts +460 -400
- package/src/services/search.ts +22 -3
- package/src/services/settings.ts +40 -11
- package/src/services/site-admin.ts +1 -0
- package/src/services/smart-collection.ts +10 -3
- package/src/services/telegram.ts +23 -6
- package/src/services/thread.ts +11 -3
- package/src/services/upload-session.ts +14 -15
- package/src/styles/components.css +2 -2
- package/src/styles/site-media.css +2 -2
- package/src/styles/tokens.css +19 -22
- package/src/styles/ui-author.css +73 -94
- package/src/styles/ui.css +62 -62
- package/src/types/app-context.ts +10 -1
- package/src/types/bindings.ts +11 -0
- package/src/types/config.ts +4 -4
- package/src/types/constants.ts +20 -0
- package/src/types/props.ts +34 -8
- package/src/types/views.ts +28 -13
- package/src/ui/color-themes.ts +6 -5
- package/src/ui/dash/settings/GeneralContent.tsx +0 -22
- package/src/ui/dash/settings/__tests__/GeneralContent.test.tsx +0 -21
- package/src/ui/feed/CuratedThreadPreview.tsx +7 -2
- package/src/ui/feed/LinkCard.tsx +1 -2
- package/src/ui/feed/NoteCard.tsx +1 -2
- package/src/ui/feed/QuoteCard.tsx +2 -2
- package/src/ui/feed/ThreadPreview.tsx +6 -6
- package/src/ui/feed/TimelineFeed.tsx +1 -7
- package/src/ui/feed/__tests__/thread-preview.test.ts +123 -10
- package/src/ui/feed/__tests__/timeline-cards.test.ts +18 -1
- package/src/ui/layouts/BaseLayout.tsx +5 -0
- package/src/ui/pages/ArchivePage.tsx +35 -35
- package/src/ui/pages/BrandPage.tsx +1 -1
- package/src/ui/pages/CollectionPage.tsx +1 -2
- package/src/ui/pages/CollectionsPage.tsx +2 -2
- package/src/ui/pages/ComposePage.tsx +1 -1
- package/src/ui/pages/FeaturedPage.tsx +1 -1
- package/src/ui/pages/HomePage.tsx +1 -1
- package/src/ui/pages/PostPage.tsx +1 -1
- package/src/ui/pages/SearchPage.tsx +1 -1
- package/src/ui/pages/SmartCollectionPage.tsx +4 -5
- package/src/ui/pages/SubscribePage.tsx +3 -5
- package/src/ui/pages/ThemeSamplePage.tsx +1 -1
- package/src/ui/shared/CollectionDirectory.tsx +2 -2
- package/src/ui/shared/CollectionsManager.tsx +1 -1
- package/src/ui/shared/CopyField.tsx +1 -1
- package/src/ui/shared/Icon.tsx +5 -5
- package/src/ui/shared/IconSprite.tsx +10 -11
- package/src/ui/shared/MediaGallery.tsx +1 -1
- package/src/ui/shared/custom-icons.ts +38 -7
- package/src/ui/shared/icon-collector.ts +7 -5
- package/src/vendor/datastar.js +9 -1956
- package/src/vendor/datastar.js.map +4 -4
- package/dist/client/_assets/chunks/sortable-list-BJyd-LXE.js +0 -2
- package/dist/client/_assets/chunks/unsafe-svg-DU_DNMy5.js +0 -2
- package/dist/client/_assets/client-D4AT9Iqr.js +0 -295
- package/dist/client/_assets/client-DRuw7XCt.css +0 -2
- package/dist/client/_assets/client-author-DQ8R-8KR.css +0 -2
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
assertPublicHttpUrl,
|
|
4
|
+
assertResolvesPublic,
|
|
5
|
+
fetchImageBytes,
|
|
6
|
+
isPrivateAddress,
|
|
7
|
+
} from "../url-fetch.js";
|
|
3
8
|
import { ValidationError } from "../errors.js";
|
|
4
9
|
|
|
10
|
+
// Every host resolves to a public address unless a test says otherwise, so
|
|
11
|
+
// no test depends on real DNS.
|
|
12
|
+
const lookup = vi.hoisted(() =>
|
|
13
|
+
vi.fn(async (_host: string, _options?: unknown) => [
|
|
14
|
+
{ address: "93.184.215.14", family: 4 },
|
|
15
|
+
]),
|
|
16
|
+
);
|
|
17
|
+
vi.mock("node:dns/promises", () => ({ lookup, default: { lookup } }));
|
|
18
|
+
|
|
5
19
|
describe("assertPublicHttpUrl", () => {
|
|
6
20
|
it("accepts public http(s) URLs", () => {
|
|
7
21
|
expect(assertPublicHttpUrl("https://example.com/a.png").href).toBe(
|
|
@@ -29,6 +43,11 @@ describe("assertPublicHttpUrl", () => {
|
|
|
29
43
|
["link-local v6", "http://[fe80::1]/a.png"],
|
|
30
44
|
["ULA v6", "http://[fd00::1]/a.png"],
|
|
31
45
|
["v4-mapped private v6", "http://[::ffff:10.0.0.1]/a.png"],
|
|
46
|
+
["trailing-dot localhost", "http://localhost./a.png"],
|
|
47
|
+
["v4-compatible loopback v6", "http://[::7f00:1]/a.png"],
|
|
48
|
+
["NAT64 loopback", "http://[64:ff9b::7f00:1]/a.png"],
|
|
49
|
+
["6to4 private", "http://[2002:a00:1::1]/a.png"],
|
|
50
|
+
["multicast v4", "http://224.0.0.1/a.png"],
|
|
32
51
|
])("rejects %s", (_label, url) => {
|
|
33
52
|
expect(() => assertPublicHttpUrl(url)).toThrow(ValidationError);
|
|
34
53
|
});
|
|
@@ -38,6 +57,51 @@ describe("assertPublicHttpUrl", () => {
|
|
|
38
57
|
});
|
|
39
58
|
});
|
|
40
59
|
|
|
60
|
+
describe("isPrivateAddress", () => {
|
|
61
|
+
it.each([
|
|
62
|
+
"8.8.8.8",
|
|
63
|
+
"2606:4700::1111",
|
|
64
|
+
"64:ff9b::808:808",
|
|
65
|
+
"2002:808:808::1",
|
|
66
|
+
])("treats %s as public", (address) => {
|
|
67
|
+
expect(isPrivateAddress(address)).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it.each(["127.0.0.1", "::1", "fc00::1", "not:an:address::::"])(
|
|
71
|
+
"treats %s as private",
|
|
72
|
+
(address) => {
|
|
73
|
+
expect(isPrivateAddress(address)).toBe(true);
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe("assertResolvesPublic", () => {
|
|
79
|
+
it("refuses a name that resolves to a private address", async () => {
|
|
80
|
+
lookup.mockResolvedValueOnce([{ address: "127.0.0.1", family: 4 }]);
|
|
81
|
+
|
|
82
|
+
await expect(
|
|
83
|
+
assertResolvesPublic(new URL("http://127.0.0.1.nip.io/a.png")),
|
|
84
|
+
).rejects.toThrow("private address");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("refuses a name when any of its addresses is private", async () => {
|
|
88
|
+
lookup.mockResolvedValueOnce([
|
|
89
|
+
{ address: "93.184.215.14", family: 4 },
|
|
90
|
+
{ address: "::1", family: 6 },
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
await expect(
|
|
94
|
+
assertResolvesPublic(new URL("https://example.com/a.png")),
|
|
95
|
+
).rejects.toThrow("private address");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("accepts a name that resolves only to public addresses", async () => {
|
|
99
|
+
await expect(
|
|
100
|
+
assertResolvesPublic(new URL("https://example.com/a.png")),
|
|
101
|
+
).resolves.toBeUndefined();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
41
105
|
describe("fetchImageBytes", () => {
|
|
42
106
|
afterEach(() => {
|
|
43
107
|
vi.restoreAllMocks();
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
2
|
import {
|
|
3
|
-
extractDomain,
|
|
4
3
|
extractDisplayDomain,
|
|
4
|
+
extractDomain,
|
|
5
5
|
isFullUrl,
|
|
6
6
|
isSafeAbsoluteUrl,
|
|
7
7
|
looksLikeAddress,
|
|
8
8
|
normalizePath,
|
|
9
|
+
normalizeRedirectTarget,
|
|
10
|
+
redirectTargetHref,
|
|
11
|
+
redirectTargetPath,
|
|
9
12
|
sanitizeRichTextHref,
|
|
10
13
|
sanitizeUrl,
|
|
11
14
|
stripSitePathPrefix,
|
|
12
15
|
toInternalPath,
|
|
13
16
|
toSameSitePath,
|
|
17
|
+
withRequestQuery,
|
|
14
18
|
} from "../url.js";
|
|
15
19
|
|
|
16
20
|
describe("extractDomain", () => {
|
|
@@ -329,3 +333,58 @@ describe("toInternalPath", () => {
|
|
|
329
333
|
expect(toInternalPath("/", SITE)).toBe("/");
|
|
330
334
|
});
|
|
331
335
|
});
|
|
336
|
+
|
|
337
|
+
describe("redirect targets", () => {
|
|
338
|
+
it("stores an address off the site as given, and a path in registry form", () => {
|
|
339
|
+
expect(normalizeRedirectTarget(" https://Example.com/Page?q=A ")).toBe(
|
|
340
|
+
"https://example.com/Page?q=A",
|
|
341
|
+
);
|
|
342
|
+
expect(normalizeRedirectTarget("/Archive//2024/?format=Note#top")).toBe(
|
|
343
|
+
"archive/2024?format=Note#top",
|
|
344
|
+
);
|
|
345
|
+
expect(normalizeRedirectTarget("new-path")).toBe("new-path");
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it("gives back an address and the registry path a target names", () => {
|
|
349
|
+
expect(redirectTargetHref("archive?format=note")).toBe(
|
|
350
|
+
"/archive?format=note",
|
|
351
|
+
);
|
|
352
|
+
expect(redirectTargetHref("https://example.com/")).toBe(
|
|
353
|
+
"https://example.com/",
|
|
354
|
+
);
|
|
355
|
+
expect(redirectTargetPath("archive?format=note")).toBe("archive");
|
|
356
|
+
expect(redirectTargetPath("https://example.com/")).toBeNull();
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
describe("withRequestQuery", () => {
|
|
361
|
+
it("carries the request's query string to a path on the site", () => {
|
|
362
|
+
expect(
|
|
363
|
+
withRequestQuery("/notes", "https://blog.example/More-Notes?sort=oldest"),
|
|
364
|
+
).toBe("/notes?sort=oldest");
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it("leaves a target alone when the request has no query string", () => {
|
|
368
|
+
expect(withRequestQuery("/notes", "https://blog.example/more-notes")).toBe(
|
|
369
|
+
"/notes",
|
|
370
|
+
);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it("keeps a target's own query string and fragment", () => {
|
|
374
|
+
expect(
|
|
375
|
+
withRequestQuery("/archive?format=note", "https://blog.example/a?page=2"),
|
|
376
|
+
).toBe("/archive?format=note");
|
|
377
|
+
expect(
|
|
378
|
+
withRequestQuery("/post#reply", "https://blog.example/a?page=2"),
|
|
379
|
+
).toBe("/post#reply");
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it("leaves a target off the site as given", () => {
|
|
383
|
+
expect(
|
|
384
|
+
withRequestQuery(
|
|
385
|
+
"https://example.com/page",
|
|
386
|
+
"https://blog.example/a?x=1",
|
|
387
|
+
),
|
|
388
|
+
).toBe("https://example.com/page");
|
|
389
|
+
});
|
|
390
|
+
});
|
package/src/lib/api-nav-items.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* Navigation item responses for the author API.
|
|
3
3
|
*
|
|
4
4
|
* Every field is listed here and in docs/API.md's Navigation Items table;
|
|
5
|
-
* nothing reaches a response by being a column.
|
|
6
|
-
*
|
|
5
|
+
* nothing reaches a response by being a column. Every field is always there,
|
|
6
|
+
* and one that doesn't apply to the item's type is `null`, as on directory
|
|
7
|
+
* items and custom URLs. The owning site is left out: a response always comes
|
|
8
|
+
* from the site it was asked of.
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
11
|
import type { NavItem } from "../types.js";
|
|
@@ -12,21 +14,21 @@ export interface ApiNavItemResponse {
|
|
|
12
14
|
id: string;
|
|
13
15
|
type: NavItem["type"];
|
|
14
16
|
/** `system` items only. */
|
|
15
|
-
systemKey
|
|
17
|
+
systemKey: NonNullable<NavItem["systemKey"]> | null;
|
|
16
18
|
/** `collection` items only. */
|
|
17
|
-
collectionId
|
|
19
|
+
collectionId: string | null;
|
|
18
20
|
/** `smart_collection` items only. */
|
|
19
|
-
smartCollectionId
|
|
21
|
+
smartCollectionId: string | null;
|
|
20
22
|
/** `page` items only. */
|
|
21
|
-
postId
|
|
23
|
+
postId: string | null;
|
|
22
24
|
/** The author's label, or `""` to follow the target. */
|
|
23
25
|
label: string;
|
|
24
26
|
url: string;
|
|
25
27
|
/**
|
|
26
|
-
* The target's current title, shown when `label` is empty.
|
|
28
|
+
* The target's current title, shown when `label` is empty. `null` for
|
|
27
29
|
* `link` and `system` items, which have no target to follow.
|
|
28
30
|
*/
|
|
29
|
-
targetTitle
|
|
31
|
+
targetTitle: string | null;
|
|
30
32
|
placement: NavItem["placement"];
|
|
31
33
|
position: string;
|
|
32
34
|
createdAt: number;
|
|
@@ -37,7 +39,7 @@ export interface ApiNavItemResponse {
|
|
|
37
39
|
* One navigation item as the author API returns it.
|
|
38
40
|
*
|
|
39
41
|
* @param item - The navigation item, with its target's title resolved
|
|
40
|
-
* @returns The navigation item response; target fields
|
|
42
|
+
* @returns The navigation item response; target fields `null` outside the item's type
|
|
41
43
|
* @example
|
|
42
44
|
* return c.json({ navItems: items.map(toApiNavItem) });
|
|
43
45
|
*/
|
|
@@ -45,19 +47,13 @@ export function toApiNavItem(item: NavItem): ApiNavItemResponse {
|
|
|
45
47
|
return {
|
|
46
48
|
id: item.id,
|
|
47
49
|
type: item.type,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
...(item.smartCollectionId !== undefined
|
|
53
|
-
? { smartCollectionId: item.smartCollectionId }
|
|
54
|
-
: {}),
|
|
55
|
-
...(item.postId !== undefined ? { postId: item.postId } : {}),
|
|
50
|
+
systemKey: item.systemKey ?? null,
|
|
51
|
+
collectionId: item.collectionId ?? null,
|
|
52
|
+
smartCollectionId: item.smartCollectionId ?? null,
|
|
53
|
+
postId: item.postId ?? null,
|
|
56
54
|
label: item.label,
|
|
57
55
|
url: item.url,
|
|
58
|
-
|
|
59
|
-
? { targetTitle: item.targetTitle }
|
|
60
|
-
: {}),
|
|
56
|
+
targetTitle: item.targetTitle ?? null,
|
|
61
57
|
placement: item.placement,
|
|
62
58
|
position: item.position,
|
|
63
59
|
createdAt: item.createdAt,
|
|
@@ -14,7 +14,12 @@ import type { PostAttachmentDeps, SummaryConfig } from "../services/post.js";
|
|
|
14
14
|
import type { StorageDriver } from "./storage.js";
|
|
15
15
|
import type { AppConfig } from "../types/config.js";
|
|
16
16
|
import type { CreatePost, UpdatePost } from "../types.js";
|
|
17
|
-
import
|
|
17
|
+
import {
|
|
18
|
+
postFormatIssues,
|
|
19
|
+
type CreatePostApiSchema,
|
|
20
|
+
type UpdatePostApiSchema,
|
|
21
|
+
} from "./schemas.js";
|
|
22
|
+
import { ValidationError } from "./errors.js";
|
|
18
23
|
|
|
19
24
|
type CreatePostApiBody = z.infer<typeof CreatePostApiSchema>;
|
|
20
25
|
type UpdatePostApiBody = z.infer<typeof UpdatePostApiSchema>;
|
|
@@ -121,3 +126,31 @@ export function postWriteDeps(deps: {
|
|
|
121
126
|
},
|
|
122
127
|
};
|
|
123
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Refuse an update that sends a field the post's format doesn't allow.
|
|
132
|
+
*
|
|
133
|
+
* Create checks this in the schema, where the format is in the body. An update
|
|
134
|
+
* may leave the format out, so the check needs the post's current one: a
|
|
135
|
+
* `sourceName` sent to a note would otherwise land in its title.
|
|
136
|
+
*
|
|
137
|
+
* @param body - A body `UpdatePostApiSchema` accepted
|
|
138
|
+
* @param currentFormat - The post's format before the update
|
|
139
|
+
* @throws {ValidationError} On the first field the format doesn't allow
|
|
140
|
+
* @example
|
|
141
|
+
* assertUpdateFitsFormat(body, existing.format);
|
|
142
|
+
*/
|
|
143
|
+
export function assertUpdateFitsFormat(
|
|
144
|
+
body: UpdatePostApiBody,
|
|
145
|
+
currentFormat: string,
|
|
146
|
+
): void {
|
|
147
|
+
const [issue] = postFormatIssues(body.format ?? currentFormat, body, {
|
|
148
|
+
complete: false,
|
|
149
|
+
});
|
|
150
|
+
if (issue) {
|
|
151
|
+
throw new ValidationError(issue.message, {
|
|
152
|
+
fieldErrors: { [issue.path]: [issue.message] },
|
|
153
|
+
formErrors: [],
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
package/src/lib/api-posts.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { AppConfig } from "../types/config.js";
|
|
|
5
5
|
import type { Media, Post, Status } from "../types.js";
|
|
6
6
|
import { getPostDisplayTitle } from "./post-meta.js";
|
|
7
7
|
import { getImageUrl, getMediaUrl, getPublicUrlForProvider } from "./image.js";
|
|
8
|
+
import type { PostContent } from "./schemas.js";
|
|
9
|
+
import { tiptapJsonToMarkdown } from "./tiptap-to-markdown.js";
|
|
8
10
|
import { toPublicPath } from "./url.js";
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -32,9 +34,14 @@ export interface ApiPostResponse {
|
|
|
32
34
|
* a URL, not a name.
|
|
33
35
|
*/
|
|
34
36
|
displayTitle: string;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
/** TipTap JSON. Left out when the read asked for `content: "markdown"`. */
|
|
38
|
+
body?: string | null;
|
|
39
|
+
/** Left out when the read asked for `content: "markdown"`. */
|
|
40
|
+
bodyHtml?: string | null;
|
|
41
|
+
/** Left out when the read asked for `content: "markdown"`. */
|
|
42
|
+
bodyText?: string | null;
|
|
43
|
+
/** Only when the read asked for `content: "markdown"`. */
|
|
44
|
+
bodyMarkdown?: string | null;
|
|
38
45
|
quoteText: string | null;
|
|
39
46
|
summary: string | null;
|
|
40
47
|
rating: number | null;
|
|
@@ -180,6 +187,63 @@ export function toApiAttachment(
|
|
|
180
187
|
};
|
|
181
188
|
}
|
|
182
189
|
|
|
190
|
+
/**
|
|
191
|
+
* A post body as Markdown, or null for a historical body that isn't TipTap
|
|
192
|
+
* JSON. One unreadable row answers null and is logged, rather than failing a
|
|
193
|
+
* whole page of posts.
|
|
194
|
+
*
|
|
195
|
+
* @param postId - The post, named in the log line
|
|
196
|
+
* @param body - The stored TipTap JSON
|
|
197
|
+
* @returns The Markdown, or null
|
|
198
|
+
* @example
|
|
199
|
+
* toBodyMarkdown(post.id, post.body); // "Hello **world**"
|
|
200
|
+
*/
|
|
201
|
+
export function toBodyMarkdown(postId: string, body: string): string | null {
|
|
202
|
+
try {
|
|
203
|
+
return tiptapJsonToMarkdown(body);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
// eslint-disable-next-line no-console -- A skipped body must leave a trace
|
|
206
|
+
console.error(
|
|
207
|
+
`Couldn't convert the body of post ${postId} to Markdown`,
|
|
208
|
+
error,
|
|
209
|
+
);
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The body fields a read returns: the stored and rendered forms, or with
|
|
216
|
+
* `content: "markdown"` the Markdown alone.
|
|
217
|
+
*
|
|
218
|
+
* @param post - The Post
|
|
219
|
+
* @param content - The body format the read asked for
|
|
220
|
+
* @returns The body fields
|
|
221
|
+
* @example
|
|
222
|
+
* toApiPostBody(post, "markdown"); // { bodyMarkdown: "…" }
|
|
223
|
+
*/
|
|
224
|
+
function toApiPostBody(
|
|
225
|
+
post: Post,
|
|
226
|
+
content: PostContent | undefined,
|
|
227
|
+
): Pick<ApiPostResponse, "body" | "bodyHtml" | "bodyText" | "bodyMarkdown"> {
|
|
228
|
+
if (content === "markdown") {
|
|
229
|
+
return {
|
|
230
|
+
bodyMarkdown: post.body ? toBodyMarkdown(post.id, post.body) : null,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
return { body: post.body, bodyHtml: post.bodyHtml, bodyText: post.bodyText };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* One Post's author response, from what was read about it in its page's batch.
|
|
238
|
+
*
|
|
239
|
+
* @param post - The Post
|
|
240
|
+
* @param extras - Its Thread's post count, attachments, and collections
|
|
241
|
+
* @param options - `content: "markdown"` returns `bodyMarkdown` in place of
|
|
242
|
+
* `body`, `bodyHtml`, and `bodyText`
|
|
243
|
+
* @returns The response
|
|
244
|
+
* @example
|
|
245
|
+
* toApiPost(post, { threadPostCount: 1 });
|
|
246
|
+
*/
|
|
183
247
|
export function toApiPost(
|
|
184
248
|
post: Post,
|
|
185
249
|
extras: {
|
|
@@ -187,6 +251,7 @@ export function toApiPost(
|
|
|
187
251
|
attachments?: ReturnType<typeof toApiAttachment>[];
|
|
188
252
|
collectionIds?: string[];
|
|
189
253
|
},
|
|
254
|
+
options: { content?: PostContent } = {},
|
|
190
255
|
): ApiPostResponse {
|
|
191
256
|
// Quotes name their source where other formats carry a title and link.
|
|
192
257
|
const source =
|
|
@@ -206,9 +271,7 @@ export function toApiPost(
|
|
|
206
271
|
// A short name for this Post wherever it is referenced from somewhere
|
|
207
272
|
// else — notes are usually untitled, so the client cannot just read `title`.
|
|
208
273
|
displayTitle: getPostDisplayTitle(post),
|
|
209
|
-
|
|
210
|
-
bodyHtml: post.bodyHtml,
|
|
211
|
-
bodyText: post.bodyText,
|
|
274
|
+
...toApiPostBody(post, options.content),
|
|
212
275
|
quoteText: post.quoteText,
|
|
213
276
|
summary: post.summary,
|
|
214
277
|
rating: post.rating,
|
|
@@ -233,6 +296,14 @@ export interface ApiPostResponseDeps {
|
|
|
233
296
|
appConfig: AppConfig;
|
|
234
297
|
}
|
|
235
298
|
|
|
299
|
+
/** What else {@link loadApiPostResponses} puts on each response. */
|
|
300
|
+
export interface ApiPostResponseOptions {
|
|
301
|
+
/** Add each Post's shared Thread collections. */
|
|
302
|
+
collectionIds?: boolean;
|
|
303
|
+
/** `markdown` returns each body as Markdown. */
|
|
304
|
+
content?: PostContent;
|
|
305
|
+
}
|
|
306
|
+
|
|
236
307
|
/**
|
|
237
308
|
* API responses for Posts already loaded. Attachments, Thread Post counts,
|
|
238
309
|
* and (when asked) Thread collections are each read in one batch for the
|
|
@@ -240,7 +311,8 @@ export interface ApiPostResponseDeps {
|
|
|
240
311
|
*
|
|
241
312
|
* @param deps - Services and app config; a request's `c.var` or an MCP context
|
|
242
313
|
* @param posts - Posts to respond with, in order
|
|
243
|
-
* @param options - `collectionIds` adds each Post's shared Thread collections
|
|
314
|
+
* @param options - `collectionIds` adds each Post's shared Thread collections;
|
|
315
|
+
* `content: "markdown"` returns each body as Markdown
|
|
244
316
|
* @returns One response per Post, in the same order
|
|
245
317
|
* @example
|
|
246
318
|
* const responses = await loadApiPostResponses(c.var, page.posts);
|
|
@@ -248,7 +320,7 @@ export interface ApiPostResponseDeps {
|
|
|
248
320
|
export async function loadApiPostResponses(
|
|
249
321
|
deps: ApiPostResponseDeps,
|
|
250
322
|
posts: Post[],
|
|
251
|
-
options:
|
|
323
|
+
options: ApiPostResponseOptions = {},
|
|
252
324
|
): Promise<ApiPostResponse[]> {
|
|
253
325
|
if (posts.length === 0) return [];
|
|
254
326
|
const { services, appConfig } = deps;
|
|
@@ -257,24 +329,30 @@ export async function loadApiPostResponses(
|
|
|
257
329
|
services.media.getByPostIds(postIds),
|
|
258
330
|
services.posts.countThreadPosts(posts.map((post) => post.threadId)),
|
|
259
331
|
options.collectionIds
|
|
260
|
-
? services.collections.
|
|
332
|
+
? services.collections.getCollectionsByThreadIds(
|
|
333
|
+
posts.map((post) => post.threadId),
|
|
334
|
+
)
|
|
261
335
|
: Promise.resolve(null),
|
|
262
336
|
]);
|
|
263
337
|
|
|
264
338
|
return posts.map((post) =>
|
|
265
|
-
toApiPost(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
339
|
+
toApiPost(
|
|
340
|
+
post,
|
|
341
|
+
{
|
|
342
|
+
threadPostCount: threadPostCounts.get(post.threadId) ?? 0,
|
|
343
|
+
attachments: (mediaMap.get(post.id) ?? []).map((media) =>
|
|
344
|
+
toApiAttachment(media, appConfig),
|
|
345
|
+
),
|
|
346
|
+
...(collectionsMap
|
|
347
|
+
? {
|
|
348
|
+
collectionIds: (collectionsMap.get(post.threadId) ?? []).map(
|
|
349
|
+
(collection) => collection.id,
|
|
350
|
+
),
|
|
351
|
+
}
|
|
352
|
+
: {}),
|
|
353
|
+
},
|
|
354
|
+
{ content: options.content },
|
|
355
|
+
),
|
|
278
356
|
);
|
|
279
357
|
}
|
|
280
358
|
|
|
@@ -283,7 +361,7 @@ export async function loadApiPostResponses(
|
|
|
283
361
|
*
|
|
284
362
|
* @param deps - Services and app config
|
|
285
363
|
* @param post - The Post
|
|
286
|
-
* @param options -
|
|
364
|
+
* @param options - As for {@link loadApiPostResponses}
|
|
287
365
|
* @returns The Post's response
|
|
288
366
|
* @example
|
|
289
367
|
* return c.json(await loadApiPostResponse(c.var, post));
|
|
@@ -291,9 +369,35 @@ export async function loadApiPostResponses(
|
|
|
291
369
|
export async function loadApiPostResponse(
|
|
292
370
|
deps: ApiPostResponseDeps,
|
|
293
371
|
post: Post,
|
|
294
|
-
options:
|
|
372
|
+
options: ApiPostResponseOptions = {},
|
|
295
373
|
): Promise<ApiPostResponse> {
|
|
296
374
|
const [response] = await loadApiPostResponses(deps, [post], options);
|
|
297
375
|
if (!response) throw new Error(`No response built for post ${post.id}`);
|
|
298
376
|
return response;
|
|
299
377
|
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* One Post as `GET /api/posts/:id` and `jant_posts_get` answer it: the
|
|
381
|
+
* response, its Thread's collections, and its place in the Thread.
|
|
382
|
+
*
|
|
383
|
+
* @param deps - Services and app config
|
|
384
|
+
* @param post - The Post
|
|
385
|
+
* @param options - `content: "markdown"` returns the body as Markdown
|
|
386
|
+
* @returns The Post's response with `collectionIds` and `threadPosition`
|
|
387
|
+
* @example
|
|
388
|
+
* return c.json(await loadApiPostDetail(c.var, post));
|
|
389
|
+
*/
|
|
390
|
+
export async function loadApiPostDetail(
|
|
391
|
+
deps: ApiPostResponseDeps,
|
|
392
|
+
post: Post,
|
|
393
|
+
options: { content?: PostContent } = {},
|
|
394
|
+
): Promise<ApiPostResponse & { threadPosition: number }> {
|
|
395
|
+
const [response, threadPosition] = await Promise.all([
|
|
396
|
+
loadApiPostResponse(deps, post, {
|
|
397
|
+
collectionIds: true,
|
|
398
|
+
content: options.content,
|
|
399
|
+
}),
|
|
400
|
+
deps.services.posts.getThreadPosition(post.id),
|
|
401
|
+
]);
|
|
402
|
+
return { ...response, threadPosition };
|
|
403
|
+
}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import type { Services } from "../services/index.js";
|
|
9
9
|
import type { AppConfig } from "../types/config.js";
|
|
10
10
|
import type { Collection, Media, Post } from "../types.js";
|
|
11
|
+
import type { PostContent } from "./schemas.js";
|
|
11
12
|
import { getCollectionPagePath } from "./collection-paths.js";
|
|
12
|
-
import { toApiAttachment } from "./api-posts.js";
|
|
13
|
-
import {
|
|
14
|
-
import { toPublicPath } from "./url.js";
|
|
13
|
+
import { toApiAttachment, toBodyMarkdown } from "./api-posts.js";
|
|
14
|
+
import { getPostPath, toPublicPath } from "./url.js";
|
|
15
15
|
import { getImageUrl, getMediaUrl, getPublicUrlForProvider } from "./image.js";
|
|
16
16
|
|
|
17
17
|
export type PublicPostBaseResponse = {
|
|
@@ -72,33 +72,22 @@ export type PublicPostMarkdownResponse = PublicPostBaseResponse & {
|
|
|
72
72
|
bodyMarkdown: string | null;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
+
/** What the public API's responses read besides the Posts themselves. */
|
|
76
|
+
export interface PublicResponseDeps {
|
|
77
|
+
services: Pick<Services, "media" | "posts" | "collections" | "paths">;
|
|
78
|
+
appConfig: AppConfig;
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
export type PublicPostResponse =
|
|
76
82
|
PublicPostRenderedResponse | PublicPostMarkdownResponse;
|
|
77
83
|
|
|
78
|
-
/**
|
|
79
|
-
* The public Markdown for a post, or null for a historical body that isn't
|
|
80
|
-
* TipTap JSON. One unreadable row answers null and is logged, rather than
|
|
81
|
-
* failing the whole listing; `bodyHtml` still falls back to stored HTML.
|
|
82
|
-
*/
|
|
83
|
-
function toPublicBodyMarkdown(postId: string, body: string): string | null {
|
|
84
|
-
try {
|
|
85
|
-
return tiptapJsonToMarkdown(body);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
// eslint-disable-next-line no-console -- A skipped body must leave a trace
|
|
88
|
-
console.error(
|
|
89
|
-
`Couldn't convert the body of post ${postId} to Markdown`,
|
|
90
|
-
error,
|
|
91
|
-
);
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
84
|
/**
|
|
97
85
|
* One Post's reading view, from its attachments, its Thread's collections, and
|
|
98
86
|
* its Thread's Post count.
|
|
99
87
|
*
|
|
100
88
|
* @param post - The Post
|
|
101
|
-
* @param related - What was read about it in the same batch as its page
|
|
89
|
+
* @param related - What was read about it in the same batch as its page;
|
|
90
|
+
* `aliasPath` is its oldest custom path, its permalink when it has one
|
|
102
91
|
* @param appConfig - Media URLs and the site path prefix
|
|
103
92
|
* @param options - `content: "markdown"` returns `bodyMarkdown` instead of the
|
|
104
93
|
* rendered body
|
|
@@ -112,9 +101,10 @@ export function toPublicPost(
|
|
|
112
101
|
media: Media[];
|
|
113
102
|
collections: Collection[];
|
|
114
103
|
threadPostCount: number;
|
|
104
|
+
aliasPath?: string | null;
|
|
115
105
|
},
|
|
116
106
|
appConfig: AppConfig,
|
|
117
|
-
options?: { content?:
|
|
107
|
+
options?: { content?: PostContent },
|
|
118
108
|
): PublicPostResponse {
|
|
119
109
|
const {
|
|
120
110
|
r2PublicUrl,
|
|
@@ -149,7 +139,10 @@ export function toPublicPost(
|
|
|
149
139
|
status: "published" as const,
|
|
150
140
|
visibility: post.visibility,
|
|
151
141
|
slug: post.slug,
|
|
152
|
-
permalink: toPublicPath(
|
|
142
|
+
permalink: toPublicPath(
|
|
143
|
+
getPostPath(post.slug, related.aliasPath),
|
|
144
|
+
sitePathPrefix,
|
|
145
|
+
),
|
|
153
146
|
quoteText: post.quoteText,
|
|
154
147
|
summary: post.summary,
|
|
155
148
|
rating: post.rating,
|
|
@@ -181,9 +174,7 @@ export function toPublicPost(
|
|
|
181
174
|
const contentFields =
|
|
182
175
|
options?.content === "markdown"
|
|
183
176
|
? {
|
|
184
|
-
bodyMarkdown: post.body
|
|
185
|
-
? toPublicBodyMarkdown(post.id, post.body)
|
|
186
|
-
: null,
|
|
177
|
+
bodyMarkdown: post.body ? toBodyMarkdown(post.id, post.body) : null,
|
|
187
178
|
}
|
|
188
179
|
: {
|
|
189
180
|
bodyHtml: post.bodyHtml,
|
|
@@ -219,29 +210,31 @@ export function toPublicPost(
|
|
|
219
210
|
* const responses = await loadPublicPostResponses(c.var, page.posts, {});
|
|
220
211
|
*/
|
|
221
212
|
export async function loadPublicPostResponses(
|
|
222
|
-
deps:
|
|
223
|
-
services: Pick<Services, "media" | "posts" | "collections">;
|
|
224
|
-
appConfig: AppConfig;
|
|
225
|
-
},
|
|
213
|
+
deps: PublicResponseDeps,
|
|
226
214
|
posts: Post[],
|
|
227
|
-
options: { content?:
|
|
215
|
+
options: { content?: PostContent } = {},
|
|
228
216
|
): Promise<PublicPostResponse[]> {
|
|
229
217
|
if (posts.length === 0) return [];
|
|
230
218
|
const { services, appConfig } = deps;
|
|
231
219
|
const postIds = posts.map((post) => post.id);
|
|
232
|
-
const [mediaMap, collectionsMap, threadPostCounts] =
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
220
|
+
const [mediaMap, collectionsMap, threadPostCounts, aliases] =
|
|
221
|
+
await Promise.all([
|
|
222
|
+
services.media.getByPostIds(postIds),
|
|
223
|
+
services.collections.getCollectionsByThreadIds(
|
|
224
|
+
posts.map((post) => post.threadId),
|
|
225
|
+
),
|
|
226
|
+
services.posts.countThreadPosts(posts.map((post) => post.threadId)),
|
|
227
|
+
services.paths.getPostAliases(postIds),
|
|
228
|
+
]);
|
|
237
229
|
|
|
238
230
|
return posts.map((post) =>
|
|
239
231
|
toPublicPost(
|
|
240
232
|
post,
|
|
241
233
|
{
|
|
242
234
|
media: mediaMap.get(post.id) ?? [],
|
|
243
|
-
collections: collectionsMap.get(post.
|
|
235
|
+
collections: collectionsMap.get(post.threadId) ?? [],
|
|
244
236
|
threadPostCount: threadPostCounts.get(post.threadId) ?? 0,
|
|
237
|
+
aliasPath: aliases.get(post.id)?.[0],
|
|
245
238
|
},
|
|
246
239
|
appConfig,
|
|
247
240
|
options,
|