@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.
- package/bin/commands/assets/prepare.js +3 -3
- package/bin/commands/db/export.js +115 -2
- package/bin/commands/deploy.js +11 -3
- package/bin/commands/{search-reindex.js → search/reindex.js} +5 -5
- package/bin/commands/setup.js +136 -0
- package/bin/commands/site/export.js +117 -68
- package/bin/commands/site/import.js +3074 -2
- package/bin/commands/site/pull-media.js +2 -6
- package/bin/commands/site/snapshot/export.js +18 -60
- package/bin/commands/site/snapshot/import.js +24 -23
- package/bin/commands/telegram/register-webhooks.js +48 -23
- package/bin/jant.js +16 -11
- package/bin/lib/command-registry.js +120 -0
- package/bin/lib/d1-query.js +87 -2
- package/bin/lib/hugo-markdown.js +4 -0
- package/bin/lib/migration-artifacts.js +19 -0
- package/bin/lib/renamed-arguments.js +56 -0
- package/bin/lib/site-pull-media.js +21 -28
- package/bin/lib/site-selection.js +10 -1
- package/bin/lib/site-snapshot.js +421 -4
- package/bin/lib/sql-export.js +68 -5
- package/bin/lib/wrangler-cli.js +9 -0
- package/bin/lib/zip-archive.js +187 -0
- package/dist/{app-K_Aa1MMn.js → app-CFsmRVJN.js} +8629 -697
- package/dist/client/.vite/manifest.json +20 -20
- package/dist/client/_assets/chunks/{create-editor-CD3FhrOB.js → create-editor-B-m7X7S5.js} +50 -46
- package/dist/client/_assets/chunks/{sortable-list-CgaL2jCs.js → sortable-list-BJyd-LXE.js} +1 -1
- package/dist/client/_assets/chunks/{unsafe-svg-0QCkP0vZ.js → unsafe-svg-BkscJx69.js} +2 -2
- package/dist/client/_assets/{client-GiYENVw8.css → client-BCumu1-D.css} +1 -1
- package/dist/client/_assets/{client-VnFxJN7G.js → client-DTLBOHqD.js} +1 -1
- package/dist/client/_assets/{client-auth-k8gJ6QJj.js → client-auth-D6Ix6SmE.js} +1 -1
- package/dist/client/_assets/{client-compose-B_kDtWkW.js → client-compose-D6rExKVK.js} +1 -1
- package/dist/client/_assets/{client-manage-M90aSTOk.js → client-manage-sVOkqVbH.js} +1 -1
- package/dist/client/_assets/{client-settings-DfYs9n1F.js → client-settings-CGR_nZ78.js} +7 -7
- package/dist/index.js +2 -3
- package/dist/node.js +8 -5
- package/dist/url-CKlGzvdN.js +428 -0
- package/package.json +13 -7
- package/src/__tests__/cli-commands.test.ts +144 -0
- package/src/__tests__/config-docs.test.ts +148 -0
- package/src/__tests__/dev-scripts.test.ts +203 -0
- package/src/__tests__/export-collection-order.test.ts +276 -0
- package/src/__tests__/export-feed-ids.test.ts +184 -0
- package/src/__tests__/export-feed-order.test.ts +294 -0
- package/src/__tests__/export-hugo-build.test.ts +130 -0
- package/src/__tests__/export-import-roundtrip.test.ts +95 -1
- package/src/__tests__/export-service.test.ts +611 -28
- package/src/__tests__/export-smart-collection.test.ts +329 -0
- package/src/__tests__/feed-docs.test.ts +36 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/README.md +89 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/0x4nv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/faqyt/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/archive/_index.md +7 -0
- 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
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/bought-too-many-lemons-again/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/city-walks/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/collections/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/current-tea-rotation/_index.md +31 -0
- 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
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/desk-but-better/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/e0kcg/_index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/featured/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-basho/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-epictetus/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-marcus-aurelius/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-seneca/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-thoreau/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/2cl6d/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/3zqv7/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/5oxsv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/home-cooking/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/a83qu/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/c91j0/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/qyucy/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/wsgck/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +43 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/reading-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/cxiu6/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/t77ms/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/telk3/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/telk3/from-thoreau-pawt2/index.md +17 -0
- 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
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/tiny-projects/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/useful-links/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/weekend-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +49 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/data/jant.toml +119 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/hugo.toml +43 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/021801c20ab3-med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/0f868ce9ac84-med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/50c2ad911bad-med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/7a91f0960491-med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/8714116d3c8e-med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/8a0b4277443f-med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/a7d1c8a1afd9-med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/e25570b405f5-med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/e89ea4eabf01-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/snapshot/db.sql +218 -0
- package/src/__tests__/fixtures/releases/0.7.0/snapshot/meta.json +9 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/README.md +89 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/0x4nv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/faqyt/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/archive/_index.md +7 -0
- 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
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/bought-too-many-lemons-again/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/city-walks/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/collections/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/current-tea-rotation/_index.md +31 -0
- 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
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/desk-but-better/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/e0kcg/_index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/featured/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-basho/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-epictetus/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-marcus-aurelius/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-seneca/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-thoreau/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/2cl6d/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/3zqv7/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/5oxsv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/home-cooking/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/a83qu/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/from-seneca-5hibo/index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/mynoise-for-rainy-afternoons/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/nts-archives-are-good-cleaning-music/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/c91j0/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/qyucy/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/wsgck/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +43 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/reading-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/cxiu6/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/t77ms/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/the-soup-trick-i-always-forget/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/telk3/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/telk3/from-thoreau-pawt2/index.md +17 -0
- 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
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/tiny-projects/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/useful-links/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/weekend-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/what-i-actually-use-my-notebook-for/_index.md +49 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/data/jant.toml +119 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/hugo.toml +43 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/021801c20ab3-med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/0f868ce9ac84-med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/50c2ad911bad-med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/7a91f0960491-med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/8714116d3c8e-med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/8a0b4277443f-med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/a7d1c8a1afd9-med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/e25570b405f5-med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/e89ea4eabf01-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.7.1/snapshot/meta.json +9 -0
- package/src/__tests__/helpers/hugo-site.ts +146 -0
- package/src/__tests__/helpers/site-export-import.ts +97 -0
- package/src/__tests__/import-site-command.test.ts +514 -2
- package/src/__tests__/mise-config.test.ts +75 -4
- package/src/__tests__/node-dev-tasks.test.ts +264 -0
- package/src/__tests__/release-fixtures.test.ts +132 -0
- package/src/__tests__/site-export-canonical-import.test.ts +113 -0
- package/src/__tests__/snapshot-canonical-replay.test.ts +179 -0
- package/src/__tests__/snapshot-settings.test.ts +97 -0
- package/src/__tests__/snapshot-tables.test.ts +219 -0
- package/src/__tests__/sql-export.test.ts +173 -0
- package/src/__tests__/theme-docs.test.ts +109 -0
- package/src/__tests__/zip-archive.test.ts +106 -0
- package/src/app.tsx +16 -11
- package/src/client/components/__tests__/jant-settings-avatar.test.ts +1 -1
- package/src/client/components/__tests__/jant-settings-general.test.ts +21 -1
- package/src/client/components/jant-repo-picker-types.ts +6 -1
- package/src/client/components/jant-repo-picker.ts +4 -7
- package/src/client/components/jant-settings-general.ts +17 -12
- package/src/client/tiptap/__tests__/list-editing.test.ts +224 -86
- package/src/client/tiptap/__tests__/mark-exit.test.ts +1 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +26 -0
- package/src/client/tiptap/extensions.ts +0 -3
- package/src/client/tiptap/structural-keymap.ts +158 -47
- package/src/db/__tests__/d1-query.test.ts +56 -1
- package/src/db/rehearsal-fixtures/pg-demo-current.json +55 -0
- package/src/db/rehearsal-fixtures/pg-demo-current.sql +431 -0
- package/src/i18n/locales/public/en.po +0 -2
- package/src/i18n/locales/public/zh-Hans.po +0 -2
- package/src/i18n/locales/public/zh-Hant.po +0 -2
- package/src/i18n/locales/settings/en.po +8 -8
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +8 -8
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +8 -8
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/index.ts +6 -77
- package/src/lib/__tests__/github-sync-repo-name.test.ts +40 -0
- package/src/lib/__tests__/image.test.ts +27 -1
- package/src/lib/__tests__/markdown-to-tiptap.test.ts +105 -0
- package/src/lib/__tests__/markdown.test.ts +10 -0
- package/src/lib/__tests__/resolve-config.test.ts +67 -0
- package/src/lib/__tests__/schemas.test.ts +27 -1
- package/src/lib/__tests__/timeline.test.ts +87 -0
- package/src/lib/__tests__/tiptap-to-markdown.test.ts +172 -4
- package/src/lib/__tests__/view.test.ts +0 -46
- package/src/lib/discover.ts +3 -1
- package/src/lib/feed.ts +0 -6
- package/src/lib/github-sync-repo-name.ts +45 -0
- package/src/lib/hugo-markdown.ts +46 -0
- package/src/lib/image.ts +17 -4
- package/src/lib/markdown-manager.ts +392 -2
- package/src/lib/post-body-html.ts +11 -4
- package/src/lib/resolve-config.ts +58 -1
- package/src/lib/schemas.ts +50 -5
- package/src/lib/thread-fold.ts +3 -3
- package/src/lib/timeline.ts +1 -1
- package/src/lib/tiptap-to-markdown.ts +13 -7
- package/src/lib/url.ts +20 -0
- package/src/lib/view.ts +2 -29
- package/src/node/__tests__/cli-export.test.ts +2 -2
- package/src/node/__tests__/cli-setup.test.ts +163 -0
- package/src/node/__tests__/cli-site-snapshot.test.ts +73 -0
- package/src/node/__tests__/cli-site-token-env.test.ts +4 -1
- package/src/node/__tests__/cli-snapshot-meta.test.ts +84 -0
- package/src/node/__tests__/runtime.test.ts +38 -0
- package/src/node/index.ts +2 -0
- package/src/node/request-handler.ts +3 -1
- package/src/routes/api/__tests__/posts.test.ts +24 -0
- package/src/routes/api/__tests__/upload.test.ts +34 -0
- package/src/routes/api/export.ts +3 -3
- package/src/routes/api/internal/search-reindex.ts +1 -1
- package/src/routes/api/internal/sites.ts +0 -1
- package/src/routes/api/posts.ts +2 -0
- package/src/routes/api/public/posts.ts +21 -1
- package/src/routes/api/upload.ts +10 -3
- package/src/routes/compose.tsx +4 -0
- package/src/routes/dash/__tests__/github-sync-app.test.ts +365 -0
- package/src/routes/dash/settings.tsx +212 -70
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +211 -0
- package/src/routes/pages/__tests__/thread-order.test.ts +179 -0
- package/src/routes/pages/archive.tsx +17 -11
- package/src/routes/pages/featured.tsx +11 -5
- package/src/routes/pages/page.tsx +53 -31
- package/src/routes/pages/search.tsx +4 -2
- package/src/runtime/__tests__/readiness.test.ts +23 -0
- package/src/runtime/node.ts +49 -0
- package/src/runtime/readiness.ts +15 -0
- package/src/services/__tests__/bootstrap-setup-instance.test.ts +230 -0
- package/src/services/__tests__/custom-url.test.ts +34 -0
- package/src/services/__tests__/github-app-installations.test.ts +153 -0
- package/src/services/__tests__/github-sync-push.test.ts +46 -0
- package/src/services/__tests__/media.test.ts +31 -271
- package/src/services/__tests__/path.test.ts +56 -0
- package/src/services/__tests__/post-timeline.test.ts +127 -0
- package/src/services/__tests__/post.test.ts +74 -0
- package/src/services/bootstrap.ts +263 -44
- package/src/services/custom-url.ts +2 -2
- package/src/services/export-theme/layouts/_default/alias.html +27 -1
- package/src/services/export-theme/layouts/_default/list.html +2 -63
- package/src/services/export-theme/layouts/_default/rss.xml +27 -38
- package/src/services/export-theme/layouts/collections/list.html +3 -3
- package/src/services/export-theme/layouts/featured/list.html +1 -4
- package/src/services/export-theme/layouts/index.html +40 -26
- package/src/services/export-theme/layouts/partials/collection-members.html +100 -0
- package/src/services/export-theme/layouts/partials/collection-threads.html +33 -0
- package/src/services/export-theme/layouts/partials/featured-members.html +35 -0
- package/src/services/export-theme/layouts/partials/featured-thread.html +1 -1
- package/src/services/export-theme/layouts/partials/footer.html +1 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/header.html +5 -3
- package/src/services/export-theme/layouts/partials/jant-data.html +23 -0
- package/src/services/export-theme/layouts/partials/latest-members.html +48 -0
- package/src/services/export-theme/layouts/partials/smart-collection-members.html +129 -0
- package/src/services/export-theme/layouts/partials/thread-preview.html +1 -1
- package/src/services/export-theme/layouts/post/list.html +1 -1
- package/src/services/export-theme/layouts/smart_collection/list.html +24 -0
- package/src/services/export-theme/styles/main.css +0 -1
- package/src/services/export-theme/theme.toml +1 -1
- package/src/services/export.ts +630 -73
- package/src/services/github-app-installations.ts +171 -4
- package/src/services/github-sync.ts +69 -15
- package/src/services/mcp.ts +19 -1
- package/src/services/media.ts +9 -220
- package/src/services/path.ts +34 -1
- package/src/services/post.ts +214 -39
- package/src/services/site-admin.ts +3 -7
- package/src/services/site.ts +83 -31
- package/src/styles/ui.css +7 -119
- package/src/types/app-context.ts +16 -0
- package/src/types/bindings.ts +5 -0
- package/src/types/operations.ts +10 -0
- package/src/ui/dash/settings/GeneralContent.tsx +10 -8
- package/bin/commands/export.js +0 -118
- package/bin/commands/import-site.js +0 -2561
- package/bin/commands/migrate-text-attachments.js +0 -181
- package/dist/github-sync-BPAvT999.js +0 -7709
- package/src/client/multipart-upload.ts +0 -206
- package/src/client/tiptap/exitable-marks.ts +0 -73
- package/src/routes/api/__tests__/upload-multipart.test.ts +0 -739
- package/src/routes/api/internal/text-attachments.ts +0 -60
- package/src/routes/api/upload-multipart.ts +0 -366
package/src/services/export.ts
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
formatFrontMatter,
|
|
38
38
|
type HugoCollectionRef,
|
|
39
39
|
type HugoFrontMatter,
|
|
40
|
+
type HugoSmartCollectionSelection,
|
|
40
41
|
type JantMedia,
|
|
41
42
|
} from "../lib/hugo-markdown.js";
|
|
42
43
|
// Shared design tokens — single source of truth for colors, typography,
|
|
@@ -69,6 +70,8 @@ import LAYOUT_FEATURED_LIST from "./export-theme/layouts/featured/list.html?raw"
|
|
|
69
70
|
import LAYOUT_ARCHIVE_LIST from "./export-theme/layouts/archive/list.html?raw";
|
|
70
71
|
import LAYOUT_COLLECTIONS_LIST from "./export-theme/layouts/collections/list.html?raw";
|
|
71
72
|
import LAYOUT_COLLECTION_SINGLE from "./export-theme/layouts/collection/single.html?raw";
|
|
73
|
+
import LAYOUT_SMART_COLLECTION_LIST from "./export-theme/layouts/smart_collection/list.html?raw";
|
|
74
|
+
import PARTIAL_JANT_DATA from "./export-theme/layouts/partials/jant-data.html?raw";
|
|
72
75
|
import PARTIAL_HEAD from "./export-theme/layouts/partials/head.html?raw";
|
|
73
76
|
import PARTIAL_HEADER from "./export-theme/layouts/partials/header.html?raw";
|
|
74
77
|
import PARTIAL_FOOTER from "./export-theme/layouts/partials/footer.html?raw";
|
|
@@ -78,32 +81,106 @@ import PARTIAL_MEDIA_GALLERY from "./export-theme/layouts/partials/media-gallery
|
|
|
78
81
|
import PARTIAL_REPLY from "./export-theme/layouts/partials/reply.html?raw";
|
|
79
82
|
import PARTIAL_THREAD_PREVIEW from "./export-theme/layouts/partials/thread-preview.html?raw";
|
|
80
83
|
import PARTIAL_FEATURED_THREAD from "./export-theme/layouts/partials/featured-thread.html?raw";
|
|
84
|
+
import PARTIAL_SMART_COLLECTION_MEMBERS from "./export-theme/layouts/partials/smart-collection-members.html?raw";
|
|
85
|
+
import PARTIAL_COLLECTION_THREADS from "./export-theme/layouts/partials/collection-threads.html?raw";
|
|
86
|
+
import PARTIAL_COLLECTION_MEMBERS from "./export-theme/layouts/partials/collection-members.html?raw";
|
|
87
|
+
import PARTIAL_LATEST_MEMBERS from "./export-theme/layouts/partials/latest-members.html?raw";
|
|
88
|
+
import PARTIAL_FEATURED_MEMBERS from "./export-theme/layouts/partials/featured-members.html?raw";
|
|
81
89
|
import LAYOUT_RSS from "./export-theme/layouts/_default/rss.xml?raw";
|
|
82
90
|
import PARTIAL_FEED_POST_CONTENT from "./export-theme/layouts/partials/feed-post-content.xml?raw";
|
|
83
91
|
|
|
92
|
+
import { suggestSyncRepoName } from "../lib/github-sync-repo-name.js";
|
|
93
|
+
import { getPostPath, toAbsoluteSiteUrl } from "../lib/url.js";
|
|
84
94
|
import type { StorageDriver } from "../lib/storage.js";
|
|
85
95
|
import { base64ToUint8Array } from "../lib/favicon.js";
|
|
96
|
+
import { makeZip } from "client-zip";
|
|
86
97
|
import {
|
|
87
98
|
SYSTEM_NAV_KEYS,
|
|
88
99
|
isFeedNavKey,
|
|
89
100
|
type Collection,
|
|
90
101
|
type Media,
|
|
91
102
|
type NavItem,
|
|
103
|
+
type PathRecord,
|
|
92
104
|
type Post,
|
|
105
|
+
type SmartCollection,
|
|
93
106
|
type SystemNavKey,
|
|
94
107
|
} from "../types.js";
|
|
95
108
|
|
|
96
|
-
/**
|
|
97
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Format version written to `data/jant.toml` as `version`. Raise it when an
|
|
111
|
+
* export changes in a way an older `jant site import` would misread; the
|
|
112
|
+
* importer refuses a version newer than its `SUPPORTED_SITE_EXPORT_VERSION`,
|
|
113
|
+
* which a test keeps equal to this.
|
|
114
|
+
*/
|
|
115
|
+
export const SITE_EXPORT_FORMAT_VERSION = 1;
|
|
116
|
+
|
|
117
|
+
/** A file of the exported Hugo site whose text or bytes the export holds. */
|
|
118
|
+
export interface ExportContentFile {
|
|
98
119
|
path: string;
|
|
99
120
|
content: string | Uint8Array;
|
|
121
|
+
/**
|
|
122
|
+
* Scaffolding the destination owns once it exists. A fresh export always
|
|
123
|
+
* carries it — the ZIP is a new tree, and `site export` refuses a non-empty
|
|
124
|
+
* output directory — but GitHub Sync writes it only when the
|
|
125
|
+
* repository does not have it yet, so an edit there survives every later
|
|
126
|
+
* push. Deploy config is the case that needs this: the Worker name has to
|
|
127
|
+
* be corrected by hand when it does not match the Worker already serving
|
|
128
|
+
* the domain.
|
|
129
|
+
*/
|
|
130
|
+
scaffoldOnce?: boolean;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* A media file of the exported site, named but not read: the archive streams
|
|
135
|
+
* it from storage as it is written. Reading every bundled file up front held a
|
|
136
|
+
* site's media in memory, and on a Docker site with 3 GB of local media the
|
|
137
|
+
* container was killed before it answered.
|
|
138
|
+
*/
|
|
139
|
+
export interface ExportStoredFile {
|
|
140
|
+
path: string;
|
|
141
|
+
storageKey: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** A file entry in the exported Hugo site. */
|
|
145
|
+
export type ExportFile = ExportContentFile | ExportStoredFile;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @param file - An export file entry
|
|
149
|
+
* @returns Whether its bytes are still in storage
|
|
150
|
+
* @example
|
|
151
|
+
* if (isStoredExportFile(file)) await readStoredExportFile(file, storage);
|
|
152
|
+
*/
|
|
153
|
+
export function isStoredExportFile(file: ExportFile): file is ExportStoredFile {
|
|
154
|
+
return "storageKey" in file;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Read a stored export file's bytes, for a consumer that needs them whole.
|
|
159
|
+
*
|
|
160
|
+
* @param file - A stored export file
|
|
161
|
+
* @param storage - The site's storage
|
|
162
|
+
* @returns The bytes, or null when the object is gone
|
|
163
|
+
* @example
|
|
164
|
+
* const bytes = await readStoredExportFile(file, storage);
|
|
165
|
+
*/
|
|
166
|
+
export async function readStoredExportFile(
|
|
167
|
+
file: ExportStoredFile,
|
|
168
|
+
storage: StorageDriver,
|
|
169
|
+
): Promise<Uint8Array | null> {
|
|
170
|
+
const object = await storage.get(file.storageKey);
|
|
171
|
+
if (!object?.body) return null;
|
|
172
|
+
return new Uint8Array(await new Response(object.body).arrayBuffer());
|
|
100
173
|
}
|
|
101
174
|
|
|
102
175
|
export interface ExportService {
|
|
103
176
|
/** Generate a flat list of files for a complete Hugo site. */
|
|
104
177
|
generateHugoFiles(): Promise<ExportFile[]>;
|
|
105
|
-
/**
|
|
106
|
-
|
|
178
|
+
/**
|
|
179
|
+
* The Hugo site as a ZIP stream. Stored media is read from storage one file
|
|
180
|
+
* at a time as the stream is consumed, so memory stays flat whatever the
|
|
181
|
+
* size of the site; the archive switches to ZIP64 past 4 GiB.
|
|
182
|
+
*/
|
|
183
|
+
generateHugoSite(): Promise<ReadableStream<Uint8Array>>;
|
|
107
184
|
}
|
|
108
185
|
|
|
109
186
|
export interface SiteConfig {
|
|
@@ -151,6 +228,9 @@ export interface SiteConfig {
|
|
|
151
228
|
| "url"
|
|
152
229
|
| "position"
|
|
153
230
|
| "placement"
|
|
231
|
+
| "collectionId"
|
|
232
|
+
| "smartCollectionId"
|
|
233
|
+
| "postId"
|
|
154
234
|
>[];
|
|
155
235
|
/** Items per page for Hugo pagination — kept in sync with the main site's PAGE_SIZE. */
|
|
156
236
|
pageSize: number;
|
|
@@ -174,6 +254,16 @@ type ExportedCollectionDirectoryItem =
|
|
|
174
254
|
recentActivityLabel?: string | null;
|
|
175
255
|
recentActivityIso?: string | null;
|
|
176
256
|
}
|
|
257
|
+
| {
|
|
258
|
+
type: "smart_collection";
|
|
259
|
+
sequence: string;
|
|
260
|
+
slug: string;
|
|
261
|
+
title: string;
|
|
262
|
+
descriptionHtml?: string | null;
|
|
263
|
+
entryCount?: number;
|
|
264
|
+
recentActivityLabel?: string | null;
|
|
265
|
+
recentActivityIso?: string | null;
|
|
266
|
+
}
|
|
177
267
|
| {
|
|
178
268
|
type: "divider";
|
|
179
269
|
label: string | null;
|
|
@@ -183,12 +273,14 @@ type ExportedCollectionDirectoryItem =
|
|
|
183
273
|
sequence: string;
|
|
184
274
|
label: string;
|
|
185
275
|
url: string;
|
|
276
|
+
/** The link description as the author wrote it, or null if empty. */
|
|
277
|
+
description?: string | null;
|
|
186
278
|
/** Rendered HTML of the link description, or null if empty. */
|
|
187
279
|
descriptionHtml?: string | null;
|
|
188
280
|
};
|
|
189
281
|
|
|
190
282
|
interface ExportCollectionDirectorySourceItem {
|
|
191
|
-
type: "collection" | "divider" | "link";
|
|
283
|
+
type: "collection" | "smart_collection" | "divider" | "link";
|
|
192
284
|
label?: string | null;
|
|
193
285
|
url?: string | null;
|
|
194
286
|
description?: string | null;
|
|
@@ -200,6 +292,13 @@ interface ExportCollectionDirectorySourceItem {
|
|
|
200
292
|
threadCount?: number;
|
|
201
293
|
recentActivityAt?: number;
|
|
202
294
|
};
|
|
295
|
+
smartCollection?: {
|
|
296
|
+
slug: string;
|
|
297
|
+
title: string;
|
|
298
|
+
description?: string | null;
|
|
299
|
+
threadCount?: number;
|
|
300
|
+
recentActivityAt?: number;
|
|
301
|
+
};
|
|
203
302
|
}
|
|
204
303
|
|
|
205
304
|
interface SiteIconAssets {
|
|
@@ -262,6 +361,14 @@ export function createExportService(
|
|
|
262
361
|
* base64-encodes attachment bytes.
|
|
263
362
|
*/
|
|
264
363
|
bundleMedia?: boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Name of the GitHub repository this export is destined for, when it has
|
|
366
|
+
* one. It decides the Worker name in `wrangler.jsonc`: Cloudflare names a
|
|
367
|
+
* Worker after the repository it was imported from, and requires the two
|
|
368
|
+
* to match. GitHub Sync passes it; a ZIP export has no repository and
|
|
369
|
+
* falls back to the repository name Sync would suggest for the site.
|
|
370
|
+
*/
|
|
371
|
+
repoName?: string | null;
|
|
265
372
|
} = {},
|
|
266
373
|
): ExportService {
|
|
267
374
|
return {
|
|
@@ -297,6 +404,7 @@ export function createExportService(
|
|
|
297
404
|
slugMap,
|
|
298
405
|
aliasMap,
|
|
299
406
|
collectionSlugMap,
|
|
407
|
+
standalonePaths,
|
|
300
408
|
] = await Promise.all([
|
|
301
409
|
services.collections.getCollectionsByPostIds(rootPostIds),
|
|
302
410
|
services.collections.getCollectionEntriesByThreadIds(rootPostIds),
|
|
@@ -304,6 +412,7 @@ export function createExportService(
|
|
|
304
412
|
services.paths.getPostSlugMap(allPostIds),
|
|
305
413
|
services.paths.getPostAliases(rootPostIds),
|
|
306
414
|
services.paths.getCollectionSlugMap(allCollections.map((c) => c.id)),
|
|
415
|
+
services.paths.listStandalonePaths(),
|
|
307
416
|
]);
|
|
308
417
|
// Denormalized title lookup so front-matter collection refs can
|
|
309
418
|
// include a title label without templates having to resolve another
|
|
@@ -320,22 +429,48 @@ export function createExportService(
|
|
|
320
429
|
allPosts,
|
|
321
430
|
collectionsByRoot,
|
|
322
431
|
);
|
|
323
|
-
// Smart collections
|
|
324
|
-
//
|
|
325
|
-
// the
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
|
|
432
|
+
// Smart collections travel as their conditions (a section page per
|
|
433
|
+
// smart collection, below): a site importing the export recreates them,
|
|
434
|
+
// and the Hugo theme applies the same conditions to the posts it has, so
|
|
435
|
+
// the page keeps up with the repository instead of freezing the matches
|
|
436
|
+
// of the day it was exported.
|
|
437
|
+
const exportedSmartCollections: {
|
|
438
|
+
smartCollection: SmartCollection;
|
|
439
|
+
selection: HugoSmartCollectionSelection;
|
|
440
|
+
}[] = [];
|
|
441
|
+
const smartCollectionSlugMap = new Map<string, string>();
|
|
442
|
+
for (const smartCollection of collectionDirectoryData?.smartCollections ??
|
|
443
|
+
[]) {
|
|
444
|
+
const selection = toExportedSelection(
|
|
445
|
+
smartCollection.selection,
|
|
446
|
+
collectionSlugMap,
|
|
447
|
+
);
|
|
448
|
+
if (!selection) {
|
|
449
|
+
// eslint-disable-next-line no-console -- A dropped page must leave a trace
|
|
450
|
+
console.warn(
|
|
451
|
+
`Export: smart collection /${smartCollection.slug} filters by a collection that no longer exists, so it was left out.`,
|
|
452
|
+
);
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
smartCollectionSlugMap.set(smartCollection.id, smartCollection.slug);
|
|
456
|
+
exportedSmartCollections.push({ smartCollection, selection });
|
|
457
|
+
}
|
|
329
458
|
const exportableDirectoryItems: ExportCollectionDirectorySourceItem[] =
|
|
330
459
|
collectionDirectoryData?.items
|
|
331
460
|
? collectionDirectoryData.items
|
|
332
|
-
.filter(
|
|
461
|
+
.filter(
|
|
462
|
+
(item) =>
|
|
463
|
+
item.type !== "smart_collection" ||
|
|
464
|
+
(item.smartCollection !== undefined &&
|
|
465
|
+
smartCollectionSlugMap.has(item.smartCollection.id)),
|
|
466
|
+
)
|
|
333
467
|
.map((item) => ({
|
|
334
|
-
type: item.type
|
|
468
|
+
type: item.type,
|
|
335
469
|
label: item.label,
|
|
336
470
|
url: item.url,
|
|
337
471
|
description: item.description,
|
|
338
472
|
collection: item.collection,
|
|
473
|
+
smartCollection: item.smartCollection,
|
|
339
474
|
}))
|
|
340
475
|
: allCollections.map((collection) => ({
|
|
341
476
|
type: "collection" as const,
|
|
@@ -355,9 +490,14 @@ export function createExportService(
|
|
|
355
490
|
list.push(reply);
|
|
356
491
|
repliesByThread.set(reply.threadId, list);
|
|
357
492
|
}
|
|
358
|
-
//
|
|
493
|
+
// Thread order, as `posts.getThread` reads it: after the root, which
|
|
494
|
+
// leads as `_index.md`, creation time, then ID.
|
|
359
495
|
for (const list of repliesByThread.values()) {
|
|
360
|
-
list.sort(
|
|
496
|
+
list.sort(
|
|
497
|
+
(a, b) =>
|
|
498
|
+
a.createdAt - b.createdAt ||
|
|
499
|
+
(a.id < b.id ? -1 : a.id > b.id ? 1 : 0),
|
|
500
|
+
);
|
|
361
501
|
}
|
|
362
502
|
|
|
363
503
|
// 3. Build file list
|
|
@@ -408,6 +548,19 @@ export function createExportService(
|
|
|
408
548
|
});
|
|
409
549
|
}
|
|
410
550
|
|
|
551
|
+
// Smart collection landing pages: the conditions, which the theme's
|
|
552
|
+
// `smart-collection-members` partial applies to the exported posts.
|
|
553
|
+
for (const { smartCollection, selection } of exportedSmartCollections) {
|
|
554
|
+
exportFiles.push({
|
|
555
|
+
path: `content/${smartCollection.slug}/_index.md`,
|
|
556
|
+
content: await buildSmartCollectionSection(
|
|
557
|
+
smartCollection,
|
|
558
|
+
selection,
|
|
559
|
+
siteConfig.rssFeedsEnabled,
|
|
560
|
+
),
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
|
|
411
564
|
// Section + home scaffolding.
|
|
412
565
|
exportFiles.push({
|
|
413
566
|
path: "hugo.toml",
|
|
@@ -429,6 +582,7 @@ export function createExportService(
|
|
|
429
582
|
const usedSlugs = new Set<string>();
|
|
430
583
|
for (const s of slugMap.values()) usedSlugs.add(s);
|
|
431
584
|
for (const s of collectionSlugMap.values()) usedSlugs.add(s);
|
|
585
|
+
for (const s of smartCollectionSlugMap.values()) usedSlugs.add(s);
|
|
432
586
|
const hasFeaturedSection = !usedSlugs.has("featured");
|
|
433
587
|
if (hasFeaturedSection) {
|
|
434
588
|
exportFiles.push({
|
|
@@ -440,14 +594,18 @@ export function createExportService(
|
|
|
440
594
|
// Feed subscribers are the one audience the export can lose silently:
|
|
441
595
|
// their reader polls a `/feed` address that this site does not serve.
|
|
442
596
|
// With feeds off there is nothing to redirect to, and the live site had
|
|
443
|
-
// no feeds to have been subscribed to either.
|
|
444
|
-
|
|
597
|
+
// no feeds to have been subscribed to either. The author's own
|
|
598
|
+
// redirects go in too; an old feed address is often one of them.
|
|
599
|
+
const redirectSections = [
|
|
600
|
+
siteConfig.rssFeedsEnabled
|
|
601
|
+
? buildFeedRedirects(siteConfig.mainRssFeed, hasFeaturedSection)
|
|
602
|
+
: null,
|
|
603
|
+
buildCustomUrlRedirects(standalonePaths),
|
|
604
|
+
].filter((section): section is string => section !== null);
|
|
605
|
+
if (redirectSections.length > 0) {
|
|
445
606
|
exportFiles.push({
|
|
446
607
|
path: "static/_redirects",
|
|
447
|
-
content:
|
|
448
|
-
siteConfig.mainRssFeed,
|
|
449
|
-
hasFeaturedSection,
|
|
450
|
-
),
|
|
608
|
+
content: redirectSections.join("\n"),
|
|
451
609
|
});
|
|
452
610
|
}
|
|
453
611
|
|
|
@@ -460,6 +618,12 @@ export function createExportService(
|
|
|
460
618
|
siteConfig,
|
|
461
619
|
iconAssets,
|
|
462
620
|
exportedCollectionDirectoryItems,
|
|
621
|
+
{
|
|
622
|
+
postSlugs: slugMap,
|
|
623
|
+
collectionSlugs: collectionSlugMap,
|
|
624
|
+
smartCollectionSlugs: smartCollectionSlugMap,
|
|
625
|
+
standalonePaths,
|
|
626
|
+
},
|
|
463
627
|
),
|
|
464
628
|
});
|
|
465
629
|
|
|
@@ -508,6 +672,10 @@ export function createExportService(
|
|
|
508
672
|
path: "themes/jant/layouts/collection/single.html",
|
|
509
673
|
content: LAYOUT_COLLECTION_SINGLE,
|
|
510
674
|
});
|
|
675
|
+
exportFiles.push({
|
|
676
|
+
path: "themes/jant/layouts/partials/jant-data.html",
|
|
677
|
+
content: PARTIAL_JANT_DATA,
|
|
678
|
+
});
|
|
511
679
|
exportFiles.push({
|
|
512
680
|
path: "themes/jant/layouts/partials/head.html",
|
|
513
681
|
content: PARTIAL_HEAD,
|
|
@@ -544,6 +712,30 @@ export function createExportService(
|
|
|
544
712
|
path: "themes/jant/layouts/partials/featured-thread.html",
|
|
545
713
|
content: PARTIAL_FEATURED_THREAD,
|
|
546
714
|
});
|
|
715
|
+
exportFiles.push({
|
|
716
|
+
path: "themes/jant/layouts/smart_collection/list.html",
|
|
717
|
+
content: LAYOUT_SMART_COLLECTION_LIST,
|
|
718
|
+
});
|
|
719
|
+
exportFiles.push({
|
|
720
|
+
path: "themes/jant/layouts/partials/smart-collection-members.html",
|
|
721
|
+
content: PARTIAL_SMART_COLLECTION_MEMBERS,
|
|
722
|
+
});
|
|
723
|
+
exportFiles.push({
|
|
724
|
+
path: "themes/jant/layouts/partials/collection-threads.html",
|
|
725
|
+
content: PARTIAL_COLLECTION_THREADS,
|
|
726
|
+
});
|
|
727
|
+
exportFiles.push({
|
|
728
|
+
path: "themes/jant/layouts/partials/collection-members.html",
|
|
729
|
+
content: PARTIAL_COLLECTION_MEMBERS,
|
|
730
|
+
});
|
|
731
|
+
exportFiles.push({
|
|
732
|
+
path: "themes/jant/layouts/partials/latest-members.html",
|
|
733
|
+
content: PARTIAL_LATEST_MEMBERS,
|
|
734
|
+
});
|
|
735
|
+
exportFiles.push({
|
|
736
|
+
path: "themes/jant/layouts/partials/featured-members.html",
|
|
737
|
+
content: PARTIAL_FEATURED_MEMBERS,
|
|
738
|
+
});
|
|
547
739
|
exportFiles.push({
|
|
548
740
|
path: "themes/jant/layouts/_default/rss.xml",
|
|
549
741
|
content: LAYOUT_RSS,
|
|
@@ -599,22 +791,42 @@ export function createExportService(
|
|
|
599
791
|
path: ".gitignore",
|
|
600
792
|
content: buildGitignore(),
|
|
601
793
|
});
|
|
794
|
+
exportFiles.push({
|
|
795
|
+
path: WRANGLER_CONFIG_PATH,
|
|
796
|
+
content: buildWranglerConfig(siteConfig, deps.repoName),
|
|
797
|
+
scaffoldOnce: true,
|
|
798
|
+
});
|
|
602
799
|
|
|
603
800
|
return exportFiles;
|
|
604
801
|
},
|
|
605
802
|
|
|
606
803
|
async generateHugoSite() {
|
|
607
804
|
const exportFiles = await this.generateHugoFiles();
|
|
608
|
-
const
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
805
|
+
const storage = deps.storage ?? null;
|
|
806
|
+
const lastModified = new Date();
|
|
807
|
+
|
|
808
|
+
async function* entries() {
|
|
809
|
+
for (const file of exportFiles) {
|
|
810
|
+
if (!isStoredExportFile(file)) {
|
|
811
|
+
yield { name: file.path, lastModified, input: file.content };
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
const object = storage ? await storage.get(file.storageKey) : null;
|
|
816
|
+
if (!object?.body) {
|
|
817
|
+
// The archive is already streaming; say which file is missing
|
|
818
|
+
// rather than leave it out without a trace.
|
|
819
|
+
// eslint-disable-next-line no-console -- A dropped file must leave a trace
|
|
820
|
+
console.warn(
|
|
821
|
+
`Export: ${file.storageKey} is missing from storage, so ${file.path} is not in the archive.`,
|
|
822
|
+
);
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
yield { name: file.path, lastModified, input: object.body };
|
|
826
|
+
}
|
|
616
827
|
}
|
|
617
|
-
|
|
828
|
+
|
|
829
|
+
return makeZip(entries());
|
|
618
830
|
},
|
|
619
831
|
};
|
|
620
832
|
}
|
|
@@ -910,12 +1122,39 @@ async function buildThreadBundle(
|
|
|
910
1122
|
// Root aliases = historical root slugs + every reply slug (so
|
|
911
1123
|
// /{reply-slug}/ gets a Hugo alias page that redirects/anchors to
|
|
912
1124
|
// the thread root).
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1125
|
+
//
|
|
1126
|
+
// A draft or private root is not built, so its alias pages would have no
|
|
1127
|
+
// target: Hugo still writes them, `.Permalink` resolves to the empty
|
|
1128
|
+
// string, and the result is a page that redirects to itself. The thread
|
|
1129
|
+
// is unpublished, so its historical URLs are unpublished with it.
|
|
1130
|
+
const rootIsUnpublished =
|
|
1131
|
+
root.status === "draft" || root.visibility === "private";
|
|
1132
|
+
const aliases: string[] = [];
|
|
1133
|
+
if (!rootIsUnpublished) {
|
|
1134
|
+
aliases.push(...rootAliases);
|
|
1135
|
+
for (const reply of threadReplies) {
|
|
1136
|
+
const replySlug = slugMap.get(reply.id) ?? reply.slug;
|
|
1137
|
+
aliases.push(`/${replySlug}/`);
|
|
1138
|
+
}
|
|
917
1139
|
}
|
|
918
1140
|
|
|
1141
|
+
// The `<id>` Jant's feeds give this Thread's entry, kept as the string it
|
|
1142
|
+
// was. A reader recognises an entry it has seen by that string alone, and
|
|
1143
|
+
// the Hugo page's own URL differs from it — a trailing slash always, and
|
|
1144
|
+
// the slug where Jant uses a custom path — so an exported feed that used
|
|
1145
|
+
// the page URL would show every entry to every subscriber again after the
|
|
1146
|
+
// move. RFC 4287 §4.2.6 asks for exactly this: an entry's ID must not
|
|
1147
|
+
// change when its feed is migrated or exported.
|
|
1148
|
+
const siteUrl = siteConfig.siteUrl.trim();
|
|
1149
|
+
const feedId =
|
|
1150
|
+
!rootIsUnpublished && siteUrl
|
|
1151
|
+
? toAbsoluteSiteUrl(
|
|
1152
|
+
getPostPath(rootSlug, rootAliases[0]),
|
|
1153
|
+
siteUrl,
|
|
1154
|
+
siteConfig.sitePathPrefix,
|
|
1155
|
+
)
|
|
1156
|
+
: undefined;
|
|
1157
|
+
|
|
919
1158
|
// Root front matter.
|
|
920
1159
|
const rootMedia = mediaByPost.get(root.id) ?? [];
|
|
921
1160
|
const rootEmissions = rootMedia.map((m) =>
|
|
@@ -929,6 +1168,10 @@ async function buildThreadBundle(
|
|
|
929
1168
|
root.publishedAt !== null
|
|
930
1169
|
? toISOString(root.publishedAt)
|
|
931
1170
|
: toISOString(root.createdAt),
|
|
1171
|
+
created:
|
|
1172
|
+
root.publishedAt !== null && root.createdAt !== root.publishedAt
|
|
1173
|
+
? toISOString(root.createdAt)
|
|
1174
|
+
: undefined,
|
|
932
1175
|
updated:
|
|
933
1176
|
root.updatedAt && root.updatedAt !== root.publishedAt
|
|
934
1177
|
? toISOString(root.updatedAt)
|
|
@@ -944,11 +1187,9 @@ async function buildThreadBundle(
|
|
|
944
1187
|
: undefined,
|
|
945
1188
|
slug: rootSlug,
|
|
946
1189
|
type: "post",
|
|
947
|
-
draft:
|
|
948
|
-
root.status === "draft" || root.visibility === "private"
|
|
949
|
-
? true
|
|
950
|
-
: undefined,
|
|
1190
|
+
draft: rootIsUnpublished ? true : undefined,
|
|
951
1191
|
aliases: aliases.length > 0 ? aliases : undefined,
|
|
1192
|
+
feed_id: feedId,
|
|
952
1193
|
format: root.format,
|
|
953
1194
|
status: root.status,
|
|
954
1195
|
visibility: root.visibility,
|
|
@@ -978,7 +1219,7 @@ async function buildThreadBundle(
|
|
|
978
1219
|
media: rootMediaList.length > 0 ? rootMediaList : undefined,
|
|
979
1220
|
};
|
|
980
1221
|
|
|
981
|
-
const rootBody = root.body ?
|
|
1222
|
+
const rootBody = root.body ? postBodyToMarkdown(root.body, rootSlug) : "";
|
|
982
1223
|
files.push({
|
|
983
1224
|
path: `content/${rootSlug}/_index.md`,
|
|
984
1225
|
content: `${await formatFrontMatter(rootFrontMatter)}\n${rootBody}${rootBody.endsWith("\n") ? "" : "\n"}`,
|
|
@@ -994,7 +1235,7 @@ async function buildThreadBundle(
|
|
|
994
1235
|
media: rootMedia[i] as Media,
|
|
995
1236
|
}))) {
|
|
996
1237
|
if (emission.inlinePath) {
|
|
997
|
-
const file =
|
|
1238
|
+
const file = toStoredMediaFile(
|
|
998
1239
|
storage,
|
|
999
1240
|
media.storageKey,
|
|
1000
1241
|
emission.inlinePath,
|
|
@@ -1002,7 +1243,7 @@ async function buildThreadBundle(
|
|
|
1002
1243
|
if (file) files.push(file);
|
|
1003
1244
|
}
|
|
1004
1245
|
if (emission.inlinePosterPath && media.posterKey) {
|
|
1005
|
-
const posterFile =
|
|
1246
|
+
const posterFile = toStoredMediaFile(
|
|
1006
1247
|
storage,
|
|
1007
1248
|
media.posterKey,
|
|
1008
1249
|
emission.inlinePosterPath,
|
|
@@ -1011,8 +1252,8 @@ async function buildThreadBundle(
|
|
|
1011
1252
|
}
|
|
1012
1253
|
}
|
|
1013
1254
|
|
|
1014
|
-
// Replies as nested leaf bundles.
|
|
1015
|
-
for (const reply of threadReplies) {
|
|
1255
|
+
// Replies as nested leaf bundles, in Thread order.
|
|
1256
|
+
for (const [replyIndex, reply] of threadReplies.entries()) {
|
|
1016
1257
|
const replySlug = slugMap.get(reply.id) ?? reply.slug;
|
|
1017
1258
|
const replyMedia = mediaByPost.get(reply.id) ?? [];
|
|
1018
1259
|
const replyEmissions = replyMedia.map((m) =>
|
|
@@ -1026,12 +1267,17 @@ async function buildThreadBundle(
|
|
|
1026
1267
|
reply.publishedAt !== null
|
|
1027
1268
|
? toISOString(reply.publishedAt)
|
|
1028
1269
|
: toISOString(reply.createdAt),
|
|
1270
|
+
created:
|
|
1271
|
+
reply.publishedAt !== null && reply.createdAt !== reply.publishedAt
|
|
1272
|
+
? toISOString(reply.createdAt)
|
|
1273
|
+
: undefined,
|
|
1029
1274
|
updated:
|
|
1030
1275
|
reply.updatedAt && reply.updatedAt !== reply.publishedAt
|
|
1031
1276
|
? toISOString(reply.updatedAt)
|
|
1032
1277
|
: undefined,
|
|
1033
1278
|
slug: replySlug,
|
|
1034
1279
|
type: "post",
|
|
1280
|
+
weight: replyIndex + 1,
|
|
1035
1281
|
draft:
|
|
1036
1282
|
reply.status === "draft" || reply.visibility === "private"
|
|
1037
1283
|
? true
|
|
@@ -1056,7 +1302,9 @@ async function buildThreadBundle(
|
|
|
1056
1302
|
media: replyMediaList.length > 0 ? replyMediaList : undefined,
|
|
1057
1303
|
};
|
|
1058
1304
|
|
|
1059
|
-
const replyBody = reply.body
|
|
1305
|
+
const replyBody = reply.body
|
|
1306
|
+
? postBodyToMarkdown(reply.body, replySlug)
|
|
1307
|
+
: "";
|
|
1060
1308
|
files.push({
|
|
1061
1309
|
path: `content/${rootSlug}/${replySlug}/index.md`,
|
|
1062
1310
|
content: `${await formatFrontMatter(replyFrontMatter)}\n${replyBody}${replyBody.endsWith("\n") ? "" : "\n"}`,
|
|
@@ -1067,7 +1315,7 @@ async function buildThreadBundle(
|
|
|
1067
1315
|
media: replyMedia[i] as Media,
|
|
1068
1316
|
}))) {
|
|
1069
1317
|
if (emission.inlinePath) {
|
|
1070
|
-
const file =
|
|
1318
|
+
const file = toStoredMediaFile(
|
|
1071
1319
|
storage,
|
|
1072
1320
|
media.storageKey,
|
|
1073
1321
|
emission.inlinePath,
|
|
@@ -1075,7 +1323,7 @@ async function buildThreadBundle(
|
|
|
1075
1323
|
if (file) files.push(file);
|
|
1076
1324
|
}
|
|
1077
1325
|
if (emission.inlinePosterPath && media.posterKey) {
|
|
1078
|
-
const posterFile =
|
|
1326
|
+
const posterFile = toStoredMediaFile(
|
|
1079
1327
|
storage,
|
|
1080
1328
|
media.posterKey,
|
|
1081
1329
|
emission.inlinePosterPath,
|
|
@@ -1089,25 +1337,17 @@ async function buildThreadBundle(
|
|
|
1089
1337
|
}
|
|
1090
1338
|
|
|
1091
1339
|
/**
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
* and the CLI's pull-media step (or a later sync) can fill it in.
|
|
1340
|
+
* Name a media object for the archive to bundle as `static/media/…`. Its
|
|
1341
|
+
* bytes are read when the archive is written. Null when the export has no
|
|
1342
|
+
* storage, in which case the front matter entry still points at the file and
|
|
1343
|
+
* the CLI's pull-media step can fill it in.
|
|
1097
1344
|
*/
|
|
1098
|
-
|
|
1345
|
+
function toStoredMediaFile(
|
|
1099
1346
|
storage: StorageDriver | null,
|
|
1100
1347
|
storageKey: string,
|
|
1101
1348
|
bundlePath: string,
|
|
1102
|
-
):
|
|
1103
|
-
|
|
1104
|
-
try {
|
|
1105
|
-
const bytes = await readStorageObjectBytes(storage, storageKey);
|
|
1106
|
-
if (!bytes) return null;
|
|
1107
|
-
return { path: bundlePath, content: bytes };
|
|
1108
|
-
} catch {
|
|
1109
|
-
return null;
|
|
1110
|
-
}
|
|
1349
|
+
): ExportStoredFile | null {
|
|
1350
|
+
return storage ? { path: bundlePath, storageKey } : null;
|
|
1111
1351
|
}
|
|
1112
1352
|
|
|
1113
1353
|
// ---------------------------------------------------------------------------
|
|
@@ -1169,6 +1409,48 @@ async function buildCollectionSection(
|
|
|
1169
1409
|
return `${await formatFrontMatter(frontMatter)}\n`;
|
|
1170
1410
|
}
|
|
1171
1411
|
|
|
1412
|
+
/**
|
|
1413
|
+
* A smart collection's conditions as its section page carries them: the
|
|
1414
|
+
* stored selection, with the collection named by slug rather than ID so an
|
|
1415
|
+
* import into another site can resolve it. Null when the collection it names
|
|
1416
|
+
* is gone.
|
|
1417
|
+
*/
|
|
1418
|
+
function toExportedSelection(
|
|
1419
|
+
selection: SmartCollection["selection"],
|
|
1420
|
+
collectionSlugs: ReadonlyMap<string, string>,
|
|
1421
|
+
): HugoSmartCollectionSelection | null {
|
|
1422
|
+
const { collection, media, ...rest } = selection;
|
|
1423
|
+
const exported: HugoSmartCollectionSelection = { ...rest };
|
|
1424
|
+
if (collection !== undefined) {
|
|
1425
|
+
const slug = collection[0] ? collectionSlugs.get(collection[0]) : undefined;
|
|
1426
|
+
if (!slug) return null;
|
|
1427
|
+
exported.collection = slug;
|
|
1428
|
+
}
|
|
1429
|
+
if (media !== undefined) {
|
|
1430
|
+
exported.media = typeof media === "string" ? media : [...media];
|
|
1431
|
+
}
|
|
1432
|
+
return exported;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
async function buildSmartCollectionSection(
|
|
1436
|
+
smartCollection: SmartCollection,
|
|
1437
|
+
selection: HugoSmartCollectionSelection,
|
|
1438
|
+
rssFeedsEnabled: boolean,
|
|
1439
|
+
): Promise<string> {
|
|
1440
|
+
const frontMatter: HugoFrontMatter = {
|
|
1441
|
+
title: smartCollection.title,
|
|
1442
|
+
slug: smartCollection.slug,
|
|
1443
|
+
type: "smart_collection",
|
|
1444
|
+
summary_text: smartCollection.description ?? undefined,
|
|
1445
|
+
sort_order: smartCollection.sort,
|
|
1446
|
+
display_layout: smartCollection.layout ?? undefined,
|
|
1447
|
+
selection,
|
|
1448
|
+
// Opt into Atom output at /{slug}/index.xml.
|
|
1449
|
+
outputs: rssFeedsEnabled ? ["html", "rss"] : ["html"],
|
|
1450
|
+
};
|
|
1451
|
+
return `${await formatFrontMatter(frontMatter)}\n`;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1172
1454
|
// ---------------------------------------------------------------------------
|
|
1173
1455
|
// Summary extraction (kept from the previous exporter)
|
|
1174
1456
|
// ---------------------------------------------------------------------------
|
|
@@ -1333,6 +1615,7 @@ function buildExportedCollectionDirectoryItems(
|
|
|
1333
1615
|
sequence: sequenceLabels[index] ?? "",
|
|
1334
1616
|
label: item.label,
|
|
1335
1617
|
url: item.url,
|
|
1618
|
+
description: description || null,
|
|
1336
1619
|
descriptionHtml: description
|
|
1337
1620
|
? renderMarkdown(description, {
|
|
1338
1621
|
namespace: `collection-directory-link-${sequenceLabels[index] ?? index}`,
|
|
@@ -1342,6 +1625,31 @@ function buildExportedCollectionDirectoryItems(
|
|
|
1342
1625
|
return;
|
|
1343
1626
|
}
|
|
1344
1627
|
|
|
1628
|
+
if (item.type === "smart_collection") {
|
|
1629
|
+
const smartCollection = item.smartCollection;
|
|
1630
|
+
if (!smartCollection?.slug) return;
|
|
1631
|
+
const smartDescription = smartCollection.description?.trim();
|
|
1632
|
+
exportedItems.push({
|
|
1633
|
+
type: "smart_collection",
|
|
1634
|
+
sequence: sequenceLabels[index] ?? "",
|
|
1635
|
+
slug: smartCollection.slug,
|
|
1636
|
+
title: smartCollection.title || smartCollection.slug,
|
|
1637
|
+
descriptionHtml: smartDescription
|
|
1638
|
+
? renderMarkdown(smartDescription, {
|
|
1639
|
+
namespace: `smart-collection-${smartCollection.slug}`,
|
|
1640
|
+
})
|
|
1641
|
+
: null,
|
|
1642
|
+
entryCount: smartCollection.threadCount,
|
|
1643
|
+
recentActivityLabel: formatCollectionActivityLabel(
|
|
1644
|
+
smartCollection.recentActivityAt,
|
|
1645
|
+
),
|
|
1646
|
+
recentActivityIso: formatCollectionActivityIso(
|
|
1647
|
+
smartCollection.recentActivityAt,
|
|
1648
|
+
),
|
|
1649
|
+
});
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1345
1653
|
const collection = item.collection;
|
|
1346
1654
|
if (!collection?.id) {
|
|
1347
1655
|
return;
|
|
@@ -1503,7 +1811,12 @@ function buildHugoToml(config: SiteConfig): string {
|
|
|
1503
1811
|
`languageCode = "${escapeTomlString(language)}"`,
|
|
1504
1812
|
`defaultContentLanguage = "${escapeTomlString(language)}"`,
|
|
1505
1813
|
'theme = "jant"',
|
|
1506
|
-
`paginate
|
|
1814
|
+
// No site-level `paginate` / `[pagination] pagerSize`: every paginated
|
|
1815
|
+
// template calls `.Paginate` with an explicit page size taken from
|
|
1816
|
+
// `params.page_size` / `params.archive_page_size`, so a site-level value
|
|
1817
|
+
// would never be read. `paginate` was also deprecated in Hugo v0.128.0
|
|
1818
|
+
// and has since been removed, so emitting it fails the build outright on
|
|
1819
|
+
// any version that only knows `[pagination] pagerSize`.
|
|
1507
1820
|
"enableRobotsTXT = true",
|
|
1508
1821
|
// Disable Hugo's built-in taxonomies — jant has no tags or categories
|
|
1509
1822
|
// and the default empty /tags/ and /categories/ pages are noise. This
|
|
@@ -1580,17 +1893,49 @@ function buildHugoToml(config: SiteConfig): string {
|
|
|
1580
1893
|
return `${parts.join("\n")}\n`;
|
|
1581
1894
|
}
|
|
1582
1895
|
|
|
1896
|
+
/** What `data/jant.toml` needs to name nav targets and standalone URLs. */
|
|
1897
|
+
interface JantDataTargets {
|
|
1898
|
+
postSlugs: ReadonlyMap<string, string>;
|
|
1899
|
+
collectionSlugs: ReadonlyMap<string, string>;
|
|
1900
|
+
smartCollectionSlugs: ReadonlyMap<string, string>;
|
|
1901
|
+
standalonePaths: readonly PathRecord[];
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/** The key and slug `data/jant.toml` names a nav item's target by. */
|
|
1905
|
+
function resolveNavItemTarget(
|
|
1906
|
+
item: SiteConfig["navItems"][number],
|
|
1907
|
+
targets: JantDataTargets,
|
|
1908
|
+
): { key: string; slug: string } | null {
|
|
1909
|
+
const slug =
|
|
1910
|
+
item.type === "collection" && item.collectionId
|
|
1911
|
+
? targets.collectionSlugs.get(item.collectionId)
|
|
1912
|
+
: item.type === "smart_collection" && item.smartCollectionId
|
|
1913
|
+
? targets.smartCollectionSlugs.get(item.smartCollectionId)
|
|
1914
|
+
: item.type === "page" && item.postId
|
|
1915
|
+
? targets.postSlugs.get(item.postId)
|
|
1916
|
+
: undefined;
|
|
1917
|
+
if (!slug) return null;
|
|
1918
|
+
const key =
|
|
1919
|
+
item.type === "collection"
|
|
1920
|
+
? "collection_slug"
|
|
1921
|
+
: item.type === "smart_collection"
|
|
1922
|
+
? "smart_collection_slug"
|
|
1923
|
+
: "post_slug";
|
|
1924
|
+
return { key, slug };
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1583
1927
|
function buildJantDataToml(
|
|
1584
1928
|
config: SiteConfig,
|
|
1585
1929
|
iconAssets: SiteIconAssets,
|
|
1586
1930
|
directoryItems: readonly ExportedCollectionDirectoryItem[],
|
|
1931
|
+
targets: JantDataTargets,
|
|
1587
1932
|
): string {
|
|
1588
1933
|
const footerHtml = config.siteFooter
|
|
1589
1934
|
? renderMarkdown(config.siteFooter, { namespace: "site-footer" })
|
|
1590
1935
|
: "";
|
|
1591
1936
|
const parts: string[] = [
|
|
1592
1937
|
'format = "jant-site"',
|
|
1593
|
-
|
|
1938
|
+
`version = ${SITE_EXPORT_FORMAT_VERSION}`,
|
|
1594
1939
|
`generated_at = "${escapeTomlString(toISOString(Math.floor(Date.now() / 1000)))}"`,
|
|
1595
1940
|
`site_name = "${escapeTomlString(config.siteName)}"`,
|
|
1596
1941
|
`site_description = "${escapeTomlString(config.siteDescription)}"`,
|
|
@@ -1635,11 +1980,10 @@ function buildJantDataToml(
|
|
|
1635
1980
|
}
|
|
1636
1981
|
|
|
1637
1982
|
for (const item of config.navItems) {
|
|
1638
|
-
// `settings`
|
|
1639
|
-
//
|
|
1640
|
-
|
|
1641
|
-
//
|
|
1642
|
-
// export a link to something that was never written.
|
|
1983
|
+
// `settings` has no page in the static site; the theme skips it, and the
|
|
1984
|
+
// entry stays so an import back into Jant keeps it. Both feed entries
|
|
1985
|
+
// resolve to a feed file, so with feeds off both would export a link to
|
|
1986
|
+
// something that was never written.
|
|
1643
1987
|
if (
|
|
1644
1988
|
!config.rssFeedsEnabled &&
|
|
1645
1989
|
item.type === "system" &&
|
|
@@ -1656,13 +2000,22 @@ function buildJantDataToml(
|
|
|
1656
2000
|
);
|
|
1657
2001
|
parts.push(`system_key = "${escapeTomlString(item.systemKey ?? "")}"`);
|
|
1658
2002
|
parts.push(`placement = "${escapeTomlString(item.placement ?? "header")}"`);
|
|
2003
|
+
// `label` above is what the theme shows. The author's own wording, when
|
|
2004
|
+
// there is one, and the target by slug are what an import restores.
|
|
2005
|
+
if (item.label) {
|
|
2006
|
+
parts.push(`custom_label = "${escapeTomlString(item.label)}"`);
|
|
2007
|
+
}
|
|
2008
|
+
const target = resolveNavItemTarget(item, targets);
|
|
2009
|
+
if (target) {
|
|
2010
|
+
parts.push(`${target.key} = "${escapeTomlString(target.slug)}"`);
|
|
2011
|
+
}
|
|
1659
2012
|
}
|
|
1660
2013
|
|
|
1661
2014
|
for (const item of directoryItems) {
|
|
1662
2015
|
parts.push("");
|
|
1663
2016
|
parts.push("[[directory]]");
|
|
1664
2017
|
parts.push(`type = "${escapeTomlString(item.type)}"`);
|
|
1665
|
-
if (item.type === "collection") {
|
|
2018
|
+
if (item.type === "collection" || item.type === "smart_collection") {
|
|
1666
2019
|
parts.push(`sequence = "${escapeTomlString(item.sequence)}"`);
|
|
1667
2020
|
parts.push(`slug = "${escapeTomlString(item.slug)}"`);
|
|
1668
2021
|
parts.push(`title = "${escapeTomlString(item.title)}"`);
|
|
@@ -1692,6 +2045,9 @@ function buildJantDataToml(
|
|
|
1692
2045
|
parts.push(`sequence = "${escapeTomlString(item.sequence)}"`);
|
|
1693
2046
|
parts.push(`label = "${escapeTomlString(item.label)}"`);
|
|
1694
2047
|
parts.push(`url = "${escapeTomlString(item.url)}"`);
|
|
2048
|
+
if (item.description) {
|
|
2049
|
+
parts.push(`description = "${escapeTomlString(item.description)}"`);
|
|
2050
|
+
}
|
|
1695
2051
|
if (item.descriptionHtml) {
|
|
1696
2052
|
parts.push(
|
|
1697
2053
|
`description_html = "${escapeTomlString(item.descriptionHtml)}"`,
|
|
@@ -1700,13 +2056,168 @@ function buildJantDataToml(
|
|
|
1700
2056
|
}
|
|
1701
2057
|
}
|
|
1702
2058
|
|
|
2059
|
+
// Custom URLs that name no post or collection. Post aliases travel in each
|
|
2060
|
+
// root's `aliases:`; these would otherwise not travel at all.
|
|
2061
|
+
for (const record of targets.standalonePaths) {
|
|
2062
|
+
parts.push("");
|
|
2063
|
+
parts.push("[[custom_url]]");
|
|
2064
|
+
parts.push(`path = "${escapeTomlString(record.path)}"`);
|
|
2065
|
+
parts.push(`kind = "${escapeTomlString(record.kind)}"`);
|
|
2066
|
+
if (record.kind === "redirect" && record.redirectToPath) {
|
|
2067
|
+
parts.push(`to = "/${escapeTomlString(record.redirectToPath)}"`);
|
|
2068
|
+
parts.push(`status = ${record.redirectType ?? 301}`);
|
|
2069
|
+
}
|
|
2070
|
+
if (record.kind === "archive" && record.archiveQuery) {
|
|
2071
|
+
parts.push(`archive_query = "${escapeTomlString(record.archiveQuery)}"`);
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
|
|
1703
2075
|
return `${parts.join("\n")}\n`;
|
|
1704
2076
|
}
|
|
1705
2077
|
|
|
2078
|
+
/**
|
|
2079
|
+
* The author's redirects as `_redirects` rules, or null when there are none.
|
|
2080
|
+
*
|
|
2081
|
+
* @param standalonePaths - Custom URLs that name no post or collection
|
|
2082
|
+
* @returns The `_redirects` section
|
|
2083
|
+
* @example
|
|
2084
|
+
* buildCustomUrlRedirects([redirectFromAtomXml]); // "# Redirects...\n/atom.xml /feed 301\n"
|
|
2085
|
+
*/
|
|
2086
|
+
function buildCustomUrlRedirects(
|
|
2087
|
+
standalonePaths: readonly PathRecord[],
|
|
2088
|
+
): string | null {
|
|
2089
|
+
const rules = standalonePaths
|
|
2090
|
+
.filter((record) => record.kind === "redirect" && record.redirectToPath)
|
|
2091
|
+
.map(
|
|
2092
|
+
(record) =>
|
|
2093
|
+
[
|
|
2094
|
+
`/${record.path}`,
|
|
2095
|
+
`/${record.redirectToPath}`,
|
|
2096
|
+
record.redirectType ?? 301,
|
|
2097
|
+
] as const,
|
|
2098
|
+
);
|
|
2099
|
+
if (rules.length === 0) return null;
|
|
2100
|
+
|
|
2101
|
+
const width = Math.max(...rules.map(([from]) => from.length));
|
|
2102
|
+
return `# Redirects set up under Settings → Custom URLs on the live site.
|
|
2103
|
+
|
|
2104
|
+
${rules.map(([from, to, status]) => `${from.padEnd(width)} ${to} ${status}`).join("\n")}
|
|
2105
|
+
`;
|
|
2106
|
+
}
|
|
2107
|
+
|
|
1706
2108
|
// ---------------------------------------------------------------------------
|
|
1707
|
-
// README + .gitignore + _redirects
|
|
2109
|
+
// README + .gitignore + _redirects + wrangler.jsonc
|
|
1708
2110
|
// ---------------------------------------------------------------------------
|
|
1709
2111
|
|
|
2112
|
+
/** Repo-relative path of the Cloudflare Workers deploy config. */
|
|
2113
|
+
export const WRANGLER_CONFIG_PATH = "wrangler.jsonc";
|
|
2114
|
+
|
|
2115
|
+
/**
|
|
2116
|
+
* Normalize a string into a name Cloudflare accepts for a Worker: lowercase
|
|
2117
|
+
* letters, digits, and hyphens, at most 63 characters.
|
|
2118
|
+
*/
|
|
2119
|
+
function toWorkerName(raw: string): string {
|
|
2120
|
+
return (
|
|
2121
|
+
raw
|
|
2122
|
+
.toLowerCase()
|
|
2123
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
2124
|
+
// 63 characters is Cloudflare's limit; trimming hyphens comes after the
|
|
2125
|
+
// cut so a truncated name cannot end on one.
|
|
2126
|
+
.slice(0, 63)
|
|
2127
|
+
.replace(/^-+|-+$/g, "")
|
|
2128
|
+
);
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/**
|
|
2132
|
+
* Pick the Worker name for `wrangler.jsonc`.
|
|
2133
|
+
*
|
|
2134
|
+
* Cloudflare requires this name to match the Worker in the dashboard, and its
|
|
2135
|
+
* repository-import flow names a new Worker after the repository — so the
|
|
2136
|
+
* repository name is the one value that lines up without the user editing
|
|
2137
|
+
* anything. An export with no repository behind it (a ZIP, or
|
|
2138
|
+
* `site export` into a directory) uses the repository name the GitHub Sync
|
|
2139
|
+
* settings page prefills for this site, so pushing the export to a repository
|
|
2140
|
+
* created with that default still matches.
|
|
2141
|
+
*
|
|
2142
|
+
* @param repoName - The destination repository's name, without the owner.
|
|
2143
|
+
* @param siteUrl - The exported site's URL, used when there is no repository.
|
|
2144
|
+
* @returns A name Cloudflare accepts.
|
|
2145
|
+
* @example
|
|
2146
|
+
* deriveWorkerName("owenyoung-blog", "https://notes.example.com"); // "owenyoung-blog"
|
|
2147
|
+
* deriveWorkerName(null, "https://notes.example.com"); // "notes-jant-sync"
|
|
2148
|
+
*/
|
|
2149
|
+
export function deriveWorkerName(
|
|
2150
|
+
repoName: string | null | undefined,
|
|
2151
|
+
siteUrl: string,
|
|
2152
|
+
): string {
|
|
2153
|
+
return (
|
|
2154
|
+
toWorkerName(repoName ?? "") || toWorkerName(suggestSyncRepoName(siteUrl))
|
|
2155
|
+
);
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
/**
|
|
2159
|
+
* Build the Cloudflare Workers deploy config for the exported site.
|
|
2160
|
+
*
|
|
2161
|
+
* Workers Builds has no "build output directory" field — that one belongs to
|
|
2162
|
+
* Pages — so `public/` can only be declared here. Without this file the
|
|
2163
|
+
* dashboard's default deploy command (`npx wrangler deploy`) fails on a repo
|
|
2164
|
+
* that has no Worker name to deploy under.
|
|
2165
|
+
*
|
|
2166
|
+
* `build.command` is here because nothing else runs Hugo. Workers Builds
|
|
2167
|
+
* detects frameworks from a `package.json`, which a Hugo site does not have,
|
|
2168
|
+
* so importing this repository leaves the build command empty and the deploy
|
|
2169
|
+
* fails on a `public/` that was never generated. Wrangler runs a custom build
|
|
2170
|
+
* before deploying, assets-only Workers included, which makes
|
|
2171
|
+
* `npx wrangler deploy` self-sufficient — on Cloudflare's image, on any CI,
|
|
2172
|
+
* and in a local checkout. Cloudflare's image ships Hugo extended, so the
|
|
2173
|
+
* command needs no install step; anyone who does fill in a dashboard build
|
|
2174
|
+
* command should leave it empty here to keep Hugo from running twice.
|
|
2175
|
+
*
|
|
2176
|
+
* Deliberately absent:
|
|
2177
|
+
* - `main`: a site with only static assets is a valid assets-only Worker.
|
|
2178
|
+
* - `not_found_handling`: the theme emits no `404.html` to point it at.
|
|
2179
|
+
*
|
|
2180
|
+
* @param config - The exported site's configuration.
|
|
2181
|
+
* @param repoName - The destination repository's name, when there is one.
|
|
2182
|
+
* @returns The contents of `wrangler.jsonc`.
|
|
2183
|
+
* @example
|
|
2184
|
+
* buildWranglerConfig(config, "my-blog"); // '{\n // Cloudflare Workers …'
|
|
2185
|
+
*/
|
|
2186
|
+
function buildWranglerConfig(
|
|
2187
|
+
config: SiteConfig,
|
|
2188
|
+
repoName: string | null | undefined,
|
|
2189
|
+
): string {
|
|
2190
|
+
const name = deriveWorkerName(repoName, config.siteUrl);
|
|
2191
|
+
// `compatibility_date` pins the Workers runtime behavior to what shipped on
|
|
2192
|
+
// the day this export was generated, which is what a new Worker wants.
|
|
2193
|
+
const compatibilityDate = new Date().toISOString().slice(0, 10);
|
|
2194
|
+
return `{
|
|
2195
|
+
// Cloudflare Workers deploy config for the built site.
|
|
2196
|
+
//
|
|
2197
|
+
// "name" must match the Worker's name in the Cloudflare dashboard: Workers
|
|
2198
|
+
// Builds fails the build when they differ, and a deploy run by hand under
|
|
2199
|
+
// another name goes to another Worker. A Worker imported from a repository
|
|
2200
|
+
// is named after the repository, so Jant uses the repository name when it
|
|
2201
|
+
// knows it, and otherwise the name GitHub Sync suggests for this site's
|
|
2202
|
+
// repository.
|
|
2203
|
+
//
|
|
2204
|
+
// Jant writes this file once and never overwrites it, so your edits stay.
|
|
2205
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
2206
|
+
"name": ${JSON.stringify(name)},
|
|
2207
|
+
"compatibility_date": ${JSON.stringify(compatibilityDate)},
|
|
2208
|
+
// Wrangler runs this before it uploads, so "npx wrangler deploy" builds the
|
|
2209
|
+
// site first. Leave the build command in the Cloudflare dashboard empty, or
|
|
2210
|
+
// Hugo runs twice.
|
|
2211
|
+
"build": {
|
|
2212
|
+
"command": "hugo --gc --minify"
|
|
2213
|
+
},
|
|
2214
|
+
"assets": {
|
|
2215
|
+
"directory": "./public"
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
`;
|
|
2219
|
+
}
|
|
2220
|
+
|
|
1710
2221
|
/**
|
|
1711
2222
|
* Build the `static/_redirects` file that keeps existing feed subscribers
|
|
1712
2223
|
* working after the site moves to this export.
|
|
@@ -1822,6 +2333,29 @@ Thumbs.db
|
|
|
1822
2333
|
* @example
|
|
1823
2334
|
* renderMarkdownTable(["Jant", "This export"], [["/feed", "/index.xml"]]);
|
|
1824
2335
|
*/
|
|
2336
|
+
/**
|
|
2337
|
+
* Convert a stored post body to the export's Markdown, naming the post when
|
|
2338
|
+
* it can't be converted. An export that dropped the body would read as a
|
|
2339
|
+
* complete archive and restore as an empty post.
|
|
2340
|
+
*
|
|
2341
|
+
* @param body - Stored TipTap JSON
|
|
2342
|
+
* @param slug - The post's slug, for the error
|
|
2343
|
+
* @returns The body as Markdown
|
|
2344
|
+
* @throws {Error} When the stored body isn't a TipTap document
|
|
2345
|
+
* @example
|
|
2346
|
+
* postBodyToMarkdown('{"type":"doc","content":[]}', "hello"); // ""
|
|
2347
|
+
*/
|
|
2348
|
+
function postBodyToMarkdown(body: string, slug: string): string {
|
|
2349
|
+
try {
|
|
2350
|
+
return tiptapJsonToMarkdown(body);
|
|
2351
|
+
} catch (error) {
|
|
2352
|
+
throw new Error(
|
|
2353
|
+
`Couldn't convert the body of /${slug} to Markdown: ${error instanceof Error ? error.message : String(error)}`,
|
|
2354
|
+
{ cause: error },
|
|
2355
|
+
);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
|
|
1825
2359
|
function renderMarkdownTable(
|
|
1826
2360
|
headers: [string, string],
|
|
1827
2361
|
rows: [string, string][],
|
|
@@ -1869,6 +2403,10 @@ function buildReadme(config: SiteConfig, hasFeaturedSection: boolean): string {
|
|
|
1869
2403
|
const feedNote = config.rssFeedsEnabled
|
|
1870
2404
|
? "\n- Feed addresses are the exception: they move to `index.xml` and stay reachable only through `static/_redirects`. See [Feeds](#feeds)."
|
|
1871
2405
|
: "";
|
|
2406
|
+
// Same reason: without feeds there is no `static/_redirects` to explain.
|
|
2407
|
+
const redirectsNote = config.rssFeedsEnabled
|
|
2408
|
+
? "`static/_redirects` needs no configuration here. Hugo copies it to `public/_redirects` and Workers applies the rules as published.\n\n"
|
|
2409
|
+
: "";
|
|
1872
2410
|
// Nothing to say about feeds on a site that publishes none, and no
|
|
1873
2411
|
// `_redirects` file was written for it either.
|
|
1874
2412
|
const feedRows: [string, string][] = [
|
|
@@ -1890,6 +2428,8 @@ A reader who is already subscribed holds one of the old addresses, and a feed re
|
|
|
1890
2428
|
|
|
1891
2429
|
Hugo's \`aliases:\` cannot cover this. An alias page redirects with a meta refresh and a script, and feed readers fetch XML without running either — only an HTTP redirect reaches them.
|
|
1892
2430
|
|
|
2431
|
+
Feed entries keep the IDs Jant gave them, so feed readers don't show old posts again. Each root post stores its ID in \`feed_id\`: the post's address on Jant, which is not its page URL here. Don't change \`feed_id\`, or feed readers show that post again. A post you add here without one uses its page URL.
|
|
2432
|
+
|
|
1893
2433
|
The **Subscribe** entry in the site navigation points at \`${mainFeed}\`. The exported site has no \`/subscribe\` page; that page belongs to the Jant runtime.
|
|
1894
2434
|
|
|
1895
2435
|
`
|
|
@@ -1900,7 +2440,7 @@ This is a static site exported from [Jant](https://github.com/jant-me/jant), rea
|
|
|
1900
2440
|
|
|
1901
2441
|
## Install Hugo
|
|
1902
2442
|
|
|
1903
|
-
This export targets Hugo **extended 0.
|
|
2443
|
+
This export targets Hugo **extended 0.147.7+**.
|
|
1904
2444
|
|
|
1905
2445
|
**macOS (Homebrew):**
|
|
1906
2446
|
|
|
@@ -1938,10 +2478,27 @@ hugo --minify
|
|
|
1938
2478
|
|
|
1939
2479
|
The output goes to the \`public/\` directory. Upload it to any static host (Netlify, Vercel, Cloudflare Pages, GitHub Pages, etc.).
|
|
1940
2480
|
|
|
1941
|
-
|
|
2481
|
+
## Deploy to Cloudflare Workers
|
|
2482
|
+
|
|
2483
|
+
\`wrangler.jsonc\` at the root is the deploy config: it names the Worker, runs \`hugo --gc --minify\`, and points the upload at \`public/\`. Connect this repository to Cloudflare Workers Builds and leave the commands Cloudflare offers as they are:
|
|
2484
|
+
|
|
2485
|
+
| Field | Value |
|
|
2486
|
+
| --------------- | ------------------------------ |
|
|
2487
|
+
| Build command | leave empty |
|
|
2488
|
+
| Deploy command | \`npx wrangler deploy\` |
|
|
2489
|
+
| Version command | \`npx wrangler versions upload\` |
|
|
2490
|
+
|
|
2491
|
+
The build belongs to \`wrangler.jsonc\` rather than to that field: Workers Builds reads a \`package.json\` to detect a framework, a Hugo site has none, and an empty build command deploys a \`public/\` that was never built. Filling the field in as well makes Hugo run twice.
|
|
2492
|
+
|
|
2493
|
+
Check one thing before the first deploy: \`name\` in \`wrangler.jsonc\` has to match the Worker's name in the Cloudflare dashboard. Workers Builds fails the build when they differ, and a deploy run by hand under another name goes to another Worker. A Worker imported from a repository is named after the repository, so an export pushed by GitHub Sync uses the repository name. A downloaded export has no repository and uses the name GitHub Sync suggests when it creates one for this site. If the Worker is named something else, change \`name\` to match — Cloudflare names each build token \`<worker-name> build token\`, so the token list is one place to read it.
|
|
2494
|
+
|
|
2495
|
+
Jant writes \`wrangler.jsonc\` once and never overwrites it, so a corrected name survives later syncs.
|
|
2496
|
+
|
|
2497
|
+
${redirectsNote}${feedsSection}## Project structure
|
|
1942
2498
|
|
|
1943
2499
|
\`\`\`
|
|
1944
2500
|
hugo.toml — Site configuration (baseURL, title, theme, params)
|
|
2501
|
+
wrangler.jsonc — Cloudflare Workers deploy config (see Deploy above)
|
|
1945
2502
|
content/
|
|
1946
2503
|
_index.md — Home section
|
|
1947
2504
|
archive/_index.md — Archive section
|
|
@@ -1963,7 +2520,7 @@ static/ — Copy files here to add them to the published site$
|
|
|
1963
2520
|
- **Jant metadata** — \`data/jant.toml\` drives nav and the collections directory, and is preserved across round-trip import.
|
|
1964
2521
|
- **Styles** — edit \`themes/jant/static/main.css\`, or drop a \`static/main.css\` at the site root to override.
|
|
1965
2522
|
- **Templates** — add files under \`layouts/\` at the site root to override the bundled theme.
|
|
1966
|
-
- **Debugging** — from a Jant site project, run \`npx jant site export --
|
|
2523
|
+
- **Debugging** — from a Jant site project, run \`npx jant site export --url <site-url> --output ./my-site\`, then \`cd my-site && hugo serve\`.
|
|
1967
2524
|
|
|
1968
2525
|
## Fetching media locally
|
|
1969
2526
|
|