@jant/core 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/bin/commands/site/import.js +2 -1
  2. package/bin/lib/site-snapshot.js +10 -0
  3. package/dist/{app-CKQ9PqAr.js → app-C8dETvgL.js} +9267 -5697
  4. package/dist/client/.vite/manifest.json +82 -93
  5. package/dist/client/_assets/chunks/{confirm-CMe01lne.js → confirm-BQebcuNB.js} +1 -1
  6. package/dist/client/_assets/chunks/{create-editor-BQkrw8Ax.js → create-editor-B8KuszlS.js} +38 -38
  7. package/dist/client/_assets/chunks/footnote-rail-DUrqz0Py.js +2 -0
  8. package/dist/client/_assets/chunks/{jant-locale-picker-2L4rkDaz.js → jant-locale-picker-CLq0iKDH.js} +1 -1
  9. package/dist/client/_assets/chunks/lit-BN4mrI3j.js +2 -0
  10. package/dist/client/_assets/chunks/{settings-paths-B0bNUaih.js → settings-paths-_fry4yWW.js} +1 -1
  11. package/dist/client/_assets/chunks/{slug-format-CYmQE5ln.js → slug-format-bcJ2ozr4.js} +1 -1
  12. package/dist/client/_assets/chunks/sortable-list-Bz2Na2E9.js +2 -0
  13. package/dist/client/_assets/chunks/types-DrYFqJH2.js +1 -0
  14. package/dist/client/_assets/chunks/{unsafe-html-CWos3v6N.js → unsafe-html-OJ9m154w.js} +1 -1
  15. package/dist/client/_assets/chunks/unsafe-svg-DVJ4NPcb.js +1 -0
  16. package/dist/client/_assets/client-CoNHvipV.css +2 -0
  17. package/dist/client/_assets/{client-auth-CG55rWb5.js → client-auth-CbnZkLJ6.js} +99 -129
  18. package/dist/client/_assets/{client-author-CGVvrNZ8.css → client-author-2WYBkgni.css} +1 -1
  19. package/dist/client/_assets/client-compose-DYtDlYm-.js +2008 -0
  20. package/dist/client/_assets/{client-manage-DnYdQAhf.js → client-manage-BODyYP5Z.js} +157 -157
  21. package/dist/client/_assets/client-pq6sVS7y.js +354 -0
  22. package/dist/client/_assets/{client-settings-CHgsIqXJ.js → client-settings-DDpe_tXJ.js} +166 -166
  23. package/dist/client/_assets/client-share-B9OsXx9p.js +149 -0
  24. package/dist/{constants-DEgyqWDl.js → constants-C2CdWAqt.js} +55 -5
  25. package/dist/index.js +1 -1
  26. package/dist/node.js +3 -2
  27. package/package.json +2 -1
  28. package/src/app.tsx +9 -0
  29. package/src/client/components/compose-types.ts +6 -1
  30. package/src/client/components/jant-compose-dialog.ts +26 -4
  31. package/src/client/components/jant-compose-editor.ts +30 -0
  32. package/src/client/components/jant-compose-fullscreen.ts +1 -0
  33. package/src/client/components/jant-media-lightbox.ts +18 -3
  34. package/src/client/components/jant-nav-manager.ts +2 -0
  35. package/src/client/components/jant-post-menu.ts +42 -89
  36. package/src/client/components/nav-manager-types.ts +2 -0
  37. package/src/client/components/settings-types.ts +1 -1
  38. package/src/client/compose-bridge.ts +61 -1
  39. package/src/client/feed-video-player.ts +6 -0
  40. package/src/client/list-views.ts +382 -0
  41. package/src/client/media-lightbox-events.ts +12 -0
  42. package/src/client/runtime-paths.ts +12 -0
  43. package/src/client/share-capture.ts +63 -0
  44. package/src/client/share-launch.ts +36 -9
  45. package/src/client/tiptap/bubble-menu.ts +25 -2
  46. package/src/client/tiptap/create-editor.ts +6 -0
  47. package/src/client/tiptap/embed-node.ts +3 -1
  48. package/src/client/tiptap/extensions.ts +4 -0
  49. package/src/client/tiptap/html-block-node.ts +3 -1
  50. package/src/client/tiptap/image-node.ts +3 -1
  51. package/src/client/video-processor.ts +106 -52
  52. package/src/client/view-confirm.ts +136 -0
  53. package/src/client.ts +2 -0
  54. package/src/db/migrations/0035_brainy_next_avengers.sql +9 -0
  55. package/src/db/migrations/0036_gorgeous_smasher.sql +7 -0
  56. package/src/db/migrations/0037_round_post.sql +16 -0
  57. package/src/db/migrations/0038_flashy_changeling.sql +15 -0
  58. package/src/db/migrations/0039_mixed_sister_grimm.sql +1 -0
  59. package/src/db/migrations/meta/0035_snapshot.json +2877 -0
  60. package/src/db/migrations/meta/0036_snapshot.json +2924 -0
  61. package/src/db/migrations/meta/0037_snapshot.json +2932 -0
  62. package/src/db/migrations/meta/0038_snapshot.json +2924 -0
  63. package/src/db/migrations/meta/0039_snapshot.json +2931 -0
  64. package/src/db/migrations/meta/_journal.json +35 -0
  65. package/src/db/migrations/pg/0033_cute_magdalene.sql +10 -0
  66. package/src/db/migrations/pg/0034_material_agent_brand.sql +8 -0
  67. package/src/db/migrations/pg/0035_flimsy_outlaw_kid.sql +3 -0
  68. package/src/db/migrations/pg/0036_milky_wolverine.sql +5 -0
  69. package/src/db/migrations/pg/0037_fuzzy_hammerhead.sql +1 -0
  70. package/src/db/migrations/pg/meta/0033_snapshot.json +3719 -0
  71. package/src/db/migrations/pg/meta/0034_snapshot.json +3766 -0
  72. package/src/db/migrations/pg/meta/0035_snapshot.json +3773 -0
  73. package/src/db/migrations/pg/meta/0036_snapshot.json +3766 -0
  74. package/src/db/migrations/pg/meta/0037_snapshot.json +3772 -0
  75. package/src/db/migrations/pg/meta/_journal.json +35 -0
  76. package/src/db/pg/schema.ts +41 -0
  77. package/src/db/post-visibility.ts +37 -6
  78. package/src/db/schema.ts +64 -0
  79. package/src/i18n/locales/glossary.zh-Hans.yml +4 -0
  80. package/src/i18n/locales/glossary.zh-Hant.yml +4 -0
  81. package/src/i18n/locales/public/en.po +26 -7
  82. package/src/i18n/locales/public/en.ts +1 -1
  83. package/src/i18n/locales/public/zh-Hans.po +25 -6
  84. package/src/i18n/locales/public/zh-Hans.ts +1 -1
  85. package/src/i18n/locales/public/zh-Hant.po +25 -6
  86. package/src/i18n/locales/public/zh-Hant.ts +1 -1
  87. package/src/i18n/locales/settings/en.po +159 -0
  88. package/src/i18n/locales/settings/en.ts +1 -1
  89. package/src/i18n/locales/settings/zh-Hans.po +159 -0
  90. package/src/i18n/locales/settings/zh-Hans.ts +1 -1
  91. package/src/i18n/locales/settings/zh-Hant.po +159 -0
  92. package/src/i18n/locales/settings/zh-Hant.ts +1 -1
  93. package/src/lib/api-public-posts.ts +10 -0
  94. package/src/lib/env.ts +20 -0
  95. package/src/lib/feed-policy.ts +2 -2
  96. package/src/lib/filter-dimensions.ts +11 -4
  97. package/src/lib/github-app-state.ts +1 -1
  98. package/src/lib/github-app.ts +183 -1
  99. package/src/lib/hugo-markdown.ts +7 -0
  100. package/src/lib/icons.ts +2 -0
  101. package/src/lib/link-preview.ts +499 -0
  102. package/src/lib/list-views.ts +117 -0
  103. package/src/lib/markdown-manager.ts +169 -2
  104. package/src/lib/navigation.ts +1 -1
  105. package/src/lib/post-meta.ts +13 -3
  106. package/src/lib/referrer-aliases.ts +311 -0
  107. package/src/lib/render.tsx +10 -0
  108. package/src/lib/resolve-config.ts +14 -0
  109. package/src/lib/share-card.ts +4 -3
  110. package/src/lib/summary.ts +152 -54
  111. package/src/lib/thread-query.ts +6 -2
  112. package/src/lib/timeline.ts +12 -11
  113. package/src/lib/tiptap-render.ts +1 -0
  114. package/src/lib/upload.ts +21 -1
  115. package/src/lib/url-fetch.ts +291 -74
  116. package/src/lib/video-playback.ts +55 -0
  117. package/src/lib/view-buffer.ts +201 -0
  118. package/src/lib/view-counting.ts +540 -0
  119. package/src/lib/view-token.ts +199 -0
  120. package/src/lib/view.ts +30 -1
  121. package/src/middleware/view-counter.ts +145 -0
  122. package/src/node/runtime.ts +4 -0
  123. package/src/preset.css +36 -17
  124. package/src/routes/api/media.ts +21 -3
  125. package/src/routes/api/search.ts +1 -1
  126. package/src/routes/dash/settings.tsx +434 -169
  127. package/src/routes/feed/sitemap.ts +1 -1
  128. package/src/routes/pages/archive.tsx +26 -19
  129. package/src/routes/pages/collection.tsx +9 -3
  130. package/src/routes/pages/collections.tsx +1 -0
  131. package/src/routes/pages/featured.tsx +1 -0
  132. package/src/routes/pages/home.tsx +1 -0
  133. package/src/routes/pages/page.tsx +18 -3
  134. package/src/routes/pages/search.tsx +3 -3
  135. package/src/routes/pages/smart-collection.tsx +2 -0
  136. package/src/routes/pages/subscribe.tsx +1 -0
  137. package/src/routes/view-confirm.ts +71 -0
  138. package/src/services/collection.ts +1 -1
  139. package/src/services/export-theme/assets/client-site.js +19 -19
  140. package/src/services/export-theme/layouts/archive/list.html +4 -2
  141. package/src/services/export-theme/layouts/partials/collection-members.html +4 -3
  142. package/src/services/export-theme/layouts/partials/featured-members.html +3 -3
  143. package/src/services/export-theme/layouts/partials/head.html +2 -0
  144. package/src/services/export-theme/layouts/partials/latest-members.html +4 -4
  145. package/src/services/export-theme/layouts/partials/post-card.html +1 -9
  146. package/src/services/export-theme/layouts/partials/reply.html +1 -9
  147. package/src/services/export-theme/layouts/partials/smart-collection-members.html +4 -3
  148. package/src/services/export-theme/layouts/post/list.html +1 -9
  149. package/src/services/export-theme/styles/main.css +41 -47
  150. package/src/services/export.ts +12 -3
  151. package/src/services/index.ts +17 -0
  152. package/src/services/mcp.ts +36 -6
  153. package/src/services/media.ts +63 -0
  154. package/src/services/navigation.ts +9 -4
  155. package/src/services/post.ts +102 -112
  156. package/src/services/search.ts +22 -7
  157. package/src/services/smart-collection.ts +3 -3
  158. package/src/services/stats.ts +1137 -0
  159. package/src/services/thread.ts +6 -2
  160. package/src/styles/components-author.css +242 -3
  161. package/src/styles/components.css +11 -3
  162. package/src/styles/tokens.css +89 -55
  163. package/src/styles/ui-author.css +140 -353
  164. package/src/styles/ui.css +90 -45
  165. package/src/types/app-context.ts +9 -0
  166. package/src/types/bindings.ts +5 -0
  167. package/src/types/config.ts +54 -0
  168. package/src/types/constants.ts +68 -4
  169. package/src/types/entities.ts +1 -0
  170. package/src/types/views.ts +8 -0
  171. package/src/ui/compose/ComposeDialog.tsx +26 -1
  172. package/src/ui/dash/StatusBadge.tsx +11 -0
  173. package/src/ui/dash/appearance/FontThemeContent.tsx +1 -1
  174. package/src/ui/dash/appearance/NavigationContent.tsx +8 -0
  175. package/src/ui/dash/settings/SettingsRootContent.tsx +24 -6
  176. package/src/ui/dash/settings/StatsContent.tsx +855 -0
  177. package/src/ui/feed/LinkCard.tsx +19 -2
  178. package/src/ui/feed/PostStatusBadges.tsx +19 -3
  179. package/src/ui/feed/TimelineFeed.tsx +3 -0
  180. package/src/ui/font-themes.ts +56 -6
  181. package/src/ui/layouts/BaseLayout.tsx +4 -2
  182. package/src/ui/layouts/SiteLayout.tsx +8 -3
  183. package/src/ui/pages/ArchivePage.tsx +1 -0
  184. package/src/ui/shared/MediaGallery.tsx +19 -3
  185. package/src/ui/shared/PostFooter.tsx +1 -22
  186. package/src/ui/shared/custom-icons.ts +5 -5
  187. package/dist/client/_assets/chunks/footnote-rail-B08scyhW.js +0 -2
  188. package/dist/client/_assets/chunks/lit-Bw_voPoW.js +0 -2
  189. package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +0 -1
  190. package/dist/client/_assets/chunks/sortable-list-t11Ma1Ek.js +0 -2
  191. package/dist/client/_assets/chunks/types-D5iF3H1a.js +0 -1
  192. package/dist/client/_assets/chunks/unsafe-svg-DZl-yjas.js +0 -1
  193. package/dist/client/_assets/client-B0-s9sqx.css +0 -2
  194. package/dist/client/_assets/client-Dp46QSht.js +0 -354
  195. package/dist/client/_assets/client-compose-DkUTuavR.js +0 -2004
  196. package/dist/client/_assets/client-share-C59mOLJ1.js +0 -149
package/src/styles/ui.css CHANGED
@@ -56,6 +56,10 @@
56
56
  .site-page > main,
57
57
  .site-page > footer,
58
58
  .site-page > .home-branding-credit {
59
+ /* The narrow frame's gutters. The start side keeps room for the thread
60
+ rail, which hangs into it. */
61
+ --site-frame-gutter-start: max(5%, 28px);
62
+ --site-frame-gutter-end: 5%;
59
63
  width: 100%;
60
64
  /* 12.5% left + 4% right = 16.5% padding → content = 83.5% */
61
65
  max-width: calc(var(--layout-body-max-width) / 0.835);
@@ -70,14 +74,42 @@
70
74
  .site-page > main,
71
75
  .site-page > footer,
72
76
  .site-page > .home-branding-credit {
73
- padding-left: max(5%, 28px);
74
- padding-right: 5%;
77
+ padding-left: var(--site-frame-gutter-start);
78
+ padding-right: var(--site-frame-gutter-end);
79
+ }
80
+ }
81
+
82
+ /*
83
+ * Once the sidenote gutter is gone (the single-column note in tokens.css),
84
+ * the asymmetric padding has nothing left to make room for, and a column
85
+ * held to its measure would sit against the left with every spare pixel on
86
+ * its right — 119px against 307px on a 951px screen. So the frame narrows
87
+ * to the column and its auto margins center it. That is the wide-screen
88
+ * rule too: the frame is centered and as wide as what it holds, which there
89
+ * is the column plus the gutter. Inside, everything stays flush left.
90
+ *
91
+ * Settings and the full-page composer size their own content, wider than
92
+ * the reading measure, and keep the frame they had (`.site-page-wide`).
93
+ */
94
+ @media (max-width: 1024px) {
95
+ .site-page:not(.site-page-wide) > header,
96
+ .site-page:not(.site-page-wide) > main,
97
+ .site-page:not(.site-page-wide) > footer,
98
+ .site-page:not(.site-page-wide) > .home-branding-credit {
99
+ max-width: calc(
100
+ var(--layout-reading-measure) + var(--site-frame-gutter-start) +
101
+ var(--site-frame-gutter-end)
102
+ );
103
+ padding-left: var(--site-frame-gutter-start);
104
+ padding-right: var(--site-frame-gutter-end);
75
105
  }
76
106
  }
77
107
 
78
108
  /* --- Top header --------------------------------------------------------- */
79
109
 
80
110
  .site-header {
111
+ /* The nav collapses by this width (Header responsive, below). */
112
+ container: site-header / inline-size;
81
113
  padding-top: 24px;
82
114
  }
83
115
 
@@ -905,14 +937,21 @@
905
937
  }
906
938
 
907
939
  /*
908
- * Tiered nav collapse:
909
- * ≤960px — hide the 5th+ inline link, reveal it in More (tier-lg)
910
- * ≤780px — also hide the 4th inline link (tier-md)
911
- * ≤580px — also hide the 3rd inline link (tier-sm)
912
- * The first two links always stay inline until the hamburger takes over
913
- * at ≤480px (handled below).
940
+ * Tiered nav collapse, by the header's own width rather than the
941
+ * viewport's: below 1024px a reader page's header is held to the reading
942
+ * column while a settings page's is not, so one viewport gives two widths.
943
+ * < 802px — hide the 5th+ inline link, reveal it in More (tier-lg)
944
+ * < 652px — also hide the 4th inline link (tier-md)
945
+ * < 522px — also hide the 3rd inline link (tier-sm)
946
+ * Each is the header's width where the viewport tiers used to switch: past
947
+ * 960px and 780px on the wide frame, at 580px on a phone's (one pixel
948
+ * early, because WebKit drops the fraction when it measures the container).
949
+ * A page whose header did not narrow collapses where it always did; a
950
+ * reader page's 35rem header sits in the middle tier. The first two links always
951
+ * stay inline until the hamburger takes over at ≤480px (handled below).
952
+ * BaseLayout inlines the same rules as critical CSS.
914
953
  */
915
- @media (max-width: 960px) {
954
+ @container site-header (width < 802px) {
916
955
  .site-header-link-collapse-lg {
917
956
  display: none;
918
957
  }
@@ -930,7 +969,7 @@
930
969
  }
931
970
  }
932
971
 
933
- @media (max-width: 780px) {
972
+ @container site-header (width < 652px) {
934
973
  .site-header-link-collapse-md {
935
974
  display: none;
936
975
  }
@@ -948,7 +987,7 @@
948
987
  }
949
988
  }
950
989
 
951
- @media (max-width: 580px) {
990
+ @container site-header (width < 522px) {
952
991
  .site-header-link-collapse-sm {
953
992
  display: none;
954
993
  }
@@ -2353,10 +2392,13 @@
2353
2392
  margin-top: 1.4rem;
2354
2393
  }
2355
2394
 
2395
+ /* Inline text rather than flex, so `vertical-align: middle` can set both
2396
+ icons on the middle of the domain's x-height, where a lowercase domain's
2397
+ letters sit; centering on the line box put them a pixel or two high.
2398
+ Nothing breaks between an icon and the domain, but a long domain still
2399
+ wraps (`overflow-wrap: anywhere` in preset.css). */
2356
2400
  .feed-link-domain {
2357
- display: inline-flex;
2358
- align-items: center;
2359
- gap: 0.25rem;
2401
+ display: inline-block;
2360
2402
  max-width: 100%;
2361
2403
  margin-bottom: 0.65rem;
2362
2404
  padding: 0;
@@ -2368,17 +2410,40 @@
2368
2410
  font-weight: var(--fw-regular);
2369
2411
  line-height: 1.3;
2370
2412
  text-decoration: none;
2413
+ white-space: nowrap;
2371
2414
  transition: color 0.18s ease;
2372
2415
  }
2373
2416
 
2417
+ .feed-link-domain > span {
2418
+ white-space: normal;
2419
+ }
2420
+
2374
2421
  .feed-link-domain:hover {
2375
2422
  color: var(--site-text-primary);
2376
2423
  }
2377
2424
 
2425
+ /* The external-link mark, after the domain. */
2378
2426
  .feed-link-domain-icon {
2427
+ display: inline-block;
2379
2428
  width: 0.72rem;
2380
2429
  height: 0.72rem;
2381
- flex-shrink: 0;
2430
+ margin-left: 0.35rem;
2431
+ vertical-align: middle;
2432
+ }
2433
+
2434
+ /* The linked site's own icon, before the domain: sized to the text rather
2435
+ than to the arrow's thin stroke, and set on a backdrop that only dark
2436
+ mode fills. */
2437
+ .feed-link-domain-favicon {
2438
+ display: inline-block;
2439
+ width: 1rem;
2440
+ height: 1rem;
2441
+ margin-right: 0.4rem;
2442
+ padding: 1px;
2443
+ border-radius: 3px;
2444
+ background: var(--site-link-icon-backdrop);
2445
+ object-fit: contain;
2446
+ vertical-align: middle;
2382
2447
  }
2383
2448
 
2384
2449
  /* The two post titles that do not carry their own heading font: the detail
@@ -2460,10 +2525,14 @@
2460
2525
  margin-bottom: 1.7rem;
2461
2526
  }
2462
2527
 
2528
+ /* Title, then the date a clear step below it, then air before the body:
2529
+ the three tiers every well-set article page keeps (Medium, Substack,
2530
+ Ghost). At 0.7rem the date sat on the title's descenders. */
2463
2531
  .post-header-block-detail {
2464
2532
  display: flex;
2465
2533
  flex-direction: column;
2466
- gap: 0.7rem;
2534
+ gap: 0.9rem;
2535
+ margin-bottom: 2.2rem;
2467
2536
  }
2468
2537
 
2469
2538
  .post-header-block .feed-link-title,
@@ -2497,7 +2566,7 @@
2497
2566
  .post-header-meta-link {
2498
2567
  color: var(--site-text-secondary);
2499
2568
  font-family: var(--font-ui);
2500
- font-size: var(--type-ui-hint);
2569
+ font-size: var(--type-ui-meta);
2501
2570
  text-decoration: none;
2502
2571
  white-space: nowrap;
2503
2572
  }
@@ -3402,6 +3471,7 @@
3402
3471
  article[data-post-pinned] .post-status-badges,
3403
3472
  article[data-post-pinned-in-collection] .post-status-badges,
3404
3473
  article[data-post-draft] .post-status-badges,
3474
+ article[data-post-visibility="unlisted"] .post-status-badges,
3405
3475
  article[data-post-visibility="private"] .post-status-badges {
3406
3476
  display: flex;
3407
3477
  }
@@ -3428,6 +3498,7 @@
3428
3498
  display: none;
3429
3499
  }
3430
3500
 
3501
+ article[data-post-visibility="unlisted"] .post-status-unlisted,
3431
3502
  article[data-post-visibility="private"] .post-status-private {
3432
3503
  display: inline-flex;
3433
3504
  }
@@ -3561,30 +3632,6 @@
3561
3632
  text-decoration: underline;
3562
3633
  }
3563
3634
 
3564
- .post-footer-external-link {
3565
- display: inline-flex;
3566
- align-items: center;
3567
- justify-content: center;
3568
- width: 2rem;
3569
- height: 2rem;
3570
- border-radius: 0.72rem;
3571
- color: var(--site-text-secondary);
3572
- text-decoration: none;
3573
- transition:
3574
- color 0.18s ease,
3575
- background-color 0.16s ease;
3576
- flex-shrink: 0;
3577
- }
3578
-
3579
- .post-footer-external-link:hover {
3580
- color: var(--site-text-primary);
3581
- }
3582
-
3583
- .post-footer-external-link svg {
3584
- width: 1.05rem;
3585
- height: 1.05rem;
3586
- }
3587
-
3588
3635
  .post-collection-tags {
3589
3636
  display: inline-flex;
3590
3637
  align-items: center;
@@ -4726,8 +4773,7 @@
4726
4773
  }
4727
4774
 
4728
4775
  .post-menu-trigger,
4729
- .reply-trigger,
4730
- .post-footer-external-link {
4776
+ .reply-trigger {
4731
4777
  width: 2.2rem;
4732
4778
  height: 2.2rem;
4733
4779
  border-radius: 0.88rem;
@@ -4743,8 +4789,7 @@
4743
4789
  }
4744
4790
 
4745
4791
  .post-menu-trigger svg,
4746
- .reply-trigger svg,
4747
- .post-footer-external-link svg {
4792
+ .reply-trigger svg {
4748
4793
  width: 1.18rem;
4749
4794
  height: 1.18rem;
4750
4795
  }
@@ -16,6 +16,7 @@ import type { RateLimiter } from "../lib/rate-limit.js";
16
16
  import type { StorageDriver } from "../lib/storage.js";
17
17
  import type { Bindings } from "./bindings.js";
18
18
  import type { Site, SiteDomain } from "./entities.js";
19
+ import type { ViewTarget } from "../lib/view-counting.js";
19
20
 
20
21
  /**
21
22
  * Session payload as returned by better-auth's `getSession`.
@@ -81,6 +82,14 @@ export interface AppVariables {
81
82
  * multilingual content is off.
82
83
  */
83
84
  viewLang?: string;
85
+ /**
86
+ * What the page just rendered counts as for the view counter: a post, by
87
+ * id, or any other public page, by its path. Set by the page routes worth
88
+ * counting and absent on everything else, so an API call, a feed or a
89
+ * partial never registers a view. Read by `middleware/view-counter.ts`
90
+ * after the response.
91
+ */
92
+ viewTarget?: ViewTarget;
84
93
  }
85
94
 
86
95
  /**
@@ -80,6 +80,8 @@ export interface Bindings {
80
80
  GITHUB_APP_PRIVATE_KEY?: EnvBindingValue;
81
81
  GITHUB_APP_SLUG?: EnvBindingValue;
82
82
  GITHUB_APP_WEBHOOK_SECRET?: EnvBindingValue;
83
+ GITHUB_APP_CLIENT_ID?: EnvBindingValue;
84
+ GITHUB_APP_CLIENT_SECRET?: EnvBindingValue;
83
85
  // Rate limits
84
86
  RATE_LIMIT_ENABLED?: EnvBindingValue;
85
87
  RATE_LIMIT_SEARCH_PER_MIN?: EnvBindingValue;
@@ -108,6 +110,9 @@ export interface Bindings {
108
110
  SUMMARY_MAX_CHARS?: EnvBindingValue;
109
111
  // Slug generation
110
112
  SLUG_ID_LENGTH?: EnvBindingValue;
113
+ // View stats
114
+ STATS_ENABLED?: EnvBindingValue;
115
+ STATS_DAILY_LIMIT?: EnvBindingValue;
111
116
  // RSS feed
112
117
  RSS_FEED_LIMIT?: EnvBindingValue;
113
118
  RSS_PUBLISH_DELAY_SECONDS?: EnvBindingValue;
@@ -308,6 +308,14 @@ export const CONFIG_FIELDS = {
308
308
  envOnly: true,
309
309
  envKeys: ["SLUG_ID_LENGTH"],
310
310
  },
311
+ // Views one instance records per day before counting pauses until the next
312
+ // UTC day. The registry default is the Cloudflare one; `resolveConfig`
313
+ // reads an unset variable as no limit on Node, where no write quota exists.
314
+ STATS_DAILY_LIMIT: {
315
+ defaultValue: "20000",
316
+ envOnly: true,
317
+ envKeys: ["STATS_DAILY_LIMIT"],
318
+ },
311
319
  RSS_FEED_LIMIT: {
312
320
  defaultValue: "50",
313
321
  envOnly: false,
@@ -467,6 +475,25 @@ export const CONFIG_FIELDS = {
467
475
  envKeys: ["RSS_FEEDS_ENABLED"],
468
476
  editor: { type: "boolean" },
469
477
  },
478
+ // Whether page views are counted. Edited on the Stats page, which deletes
479
+ // the counts on the way off, and deliberately kept out of Config Editor: a
480
+ // `false` saved there would stop the counting and leave ninety days of rows
481
+ // behind, which is not what "off" promises.
482
+ STATS_ENABLED: {
483
+ defaultValue: "true",
484
+ envOnly: false,
485
+ envKeys: ["STATS_ENABLED"],
486
+ },
487
+ // The day counting began, a `YYYY-MM-DD` key in the site's time zone.
488
+ // Written by the stats service alone: when the switch is turned on, or by
489
+ // the first flush that writes the site's counts when nobody ever touched
490
+ // the switch; deleted with the counts on the way off. The Stats page says
491
+ // where its record starts instead of drawing the days before as zero.
492
+ STATS_SINCE: {
493
+ defaultValue: "",
494
+ envOnly: false,
495
+ internal: true,
496
+ },
470
497
  // No default value, and deliberately no `editor`. "Never chosen" has to stay
471
498
  // tellable apart from an explicit choice — an unset site falls through to
472
499
  // `noindex` and then to the deployment default, an explicit one does not —
@@ -628,6 +655,21 @@ export const CONFIG_FIELDS = {
628
655
  envOnly: true,
629
656
  envKeys: ["GITHUB_APP_WEBHOOK_SECRET"],
630
657
  },
658
+ /**
659
+ * The App's OAuth client credentials. With them, connecting an account
660
+ * signs the author in with GitHub to learn which installations they own.
661
+ * Required on a host-based deployment; recommended on a single-site one.
662
+ */
663
+ GITHUB_APP_CLIENT_ID: {
664
+ defaultValue: "",
665
+ envOnly: true,
666
+ envKeys: ["GITHUB_APP_CLIENT_ID"],
667
+ },
668
+ GITHUB_APP_CLIENT_SECRET: {
669
+ defaultValue: "",
670
+ envOnly: true,
671
+ envKeys: ["GITHUB_APP_CLIENT_SECRET"],
672
+ },
631
673
 
632
674
  // Telegram bot pool (env-only). When TELEGRAM_BOT_TOKENS is set the bot
633
675
  // tokens are platform-managed (hosted, or a single-site operator who opts
@@ -840,6 +882,18 @@ export interface AppConfig {
840
882
  siteAvatarThumbUrl: string;
841
883
  faviconVersion: string;
842
884
 
885
+ // View stats
886
+ stats: {
887
+ /** When false, no view is counted and the Stats page offers to turn it on. */
888
+ enabled: boolean;
889
+ /**
890
+ * Views this instance records in one UTC day before counting pauses until
891
+ * the next. `0` is no limit. Guards the free-tier D1 write quota, which
892
+ * refuses every query once spent; see `services/stats.ts`.
893
+ */
894
+ dailyLimit: number;
895
+ };
896
+
843
897
  // Rate limiting (ENV only)
844
898
  rateLimit: {
845
899
  /** When false, every rate-limit check passes without counting. */
@@ -8,9 +8,71 @@ export type Format = (typeof FORMATS)[number];
8
8
  export const STATUSES = ["draft", "published"] as const;
9
9
  export type Status = (typeof STATUSES)[number];
10
10
 
11
- export const VISIBILITIES = ["public", "latest_hidden", "private"] as const;
11
+ export const VISIBILITIES = [
12
+ "public",
13
+ "latest_hidden",
14
+ "unlisted",
15
+ "private",
16
+ ] as const;
12
17
  export type Visibility = (typeof VISIBILITIES)[number];
13
18
 
19
+ /**
20
+ * Visibilities a signed-out reader can open at the post's address.
21
+ *
22
+ * Wider than {@link READER_LISTED_VISIBILITIES}: an Unlisted post opens for
23
+ * anyone who has its link, but no list a reader sees includes it.
24
+ */
25
+ export const READER_OPENABLE_VISIBILITIES = [
26
+ "public",
27
+ "latest_hidden",
28
+ "unlisted",
29
+ ] as const satisfies readonly Visibility[];
30
+
31
+ /**
32
+ * Visibilities a signed-out reader may find in a list: an archive, a search,
33
+ * a Collection, a feed, a sitemap, an API listing. Latest narrows this further
34
+ * by leaving out `latest_hidden`.
35
+ */
36
+ export const READER_LISTED_VISIBILITIES = [
37
+ "public",
38
+ "latest_hidden",
39
+ ] as const satisfies readonly Visibility[];
40
+
41
+ /**
42
+ * Whether a signed-out reader can open a post with this visibility.
43
+ *
44
+ * @param visibility - The post's effective visibility (its Thread root's)
45
+ * @returns False only for `private`
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * isOpenableByReader("unlisted"); // true
50
+ * isOpenableByReader("private"); // false
51
+ * ```
52
+ */
53
+ export function isOpenableByReader(visibility: string): boolean {
54
+ return (READER_OPENABLE_VISIBILITIES as readonly string[]).includes(
55
+ visibility,
56
+ );
57
+ }
58
+
59
+ /**
60
+ * Whether a list a signed-out reader sees may include a post with this
61
+ * visibility.
62
+ *
63
+ * @param visibility - The post's effective visibility (its Thread root's)
64
+ * @returns False for `unlisted` and `private`
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * isListedForReader("latest_hidden"); // true
69
+ * isListedForReader("unlisted"); // false
70
+ * ```
71
+ */
72
+ export function isListedForReader(visibility: string): boolean {
73
+ return (READER_LISTED_VISIBILITIES as readonly string[]).includes(visibility);
74
+ }
75
+
14
76
  export const FEED_KINDS = ["latest", "featured"] as const;
15
77
  export type FeedKind = (typeof FEED_KINDS)[number];
16
78
 
@@ -43,9 +105,10 @@ export type ArchiveSort = (typeof ARCHIVE_SORTS)[number];
43
105
  * visibility, and it lives here because the filter bar presents the two as one
44
106
  * dimension.
45
107
  *
46
- * `private` is deliberately absent. It names a set only the author can see, so
47
- * a reader who asks for it has to be told so — handing back a different set
48
- * under the same name is the one answer that is never right.
108
+ * `unlisted` and `private` are deliberately absent. Each names a set only the
109
+ * author can list, so a reader who asks for it has to be told so — handing
110
+ * back a different set under the same name is the one answer that is never
111
+ * right.
49
112
  */
50
113
  export const PUBLIC_ARCHIVE_VISIBILITIES = [
51
114
  "public",
@@ -56,6 +119,7 @@ export const PUBLIC_ARCHIVE_VISIBILITIES = [
56
119
  /** Every visibility the author can select, in filter-bar order. */
57
120
  export const ARCHIVE_VISIBILITIES = [
58
121
  ...PUBLIC_ARCHIVE_VISIBILITIES,
122
+ "unlisted",
59
123
  "private",
60
124
  ] as const;
61
125
 
@@ -71,6 +71,7 @@ export interface Post {
71
71
  previewImageKey: string | null;
72
72
  previewKind: string | null;
73
73
  previewProvider: string | null;
74
+ previewIconKey: string | null;
74
75
  replyToId: string | null;
75
76
  threadId: string;
76
77
  /**
@@ -81,6 +81,8 @@ export interface PostView {
81
81
  previewProvider?: string;
82
82
  /** Pre-computed preview image URL */
83
83
  previewImageUrl?: string;
84
+ /** The linked site's icon, shown before a Link post's domain */
85
+ previewIconUrl?: string;
84
86
 
85
87
  // Time -- pre-formatted
86
88
  /** ISO 8601 string */
@@ -337,6 +339,12 @@ export interface SiteLayoutProps {
337
339
  siteFooterHtml?: string;
338
340
  showHomeBranding?: boolean;
339
341
  sidebar?: import("hono/jsx").Child;
342
+ /**
343
+ * Keep the wide page frame below 1024px, where reader pages narrow theirs
344
+ * to the reading column. For pages that size their own content: settings,
345
+ * the full-page composer.
346
+ */
347
+ wideFrame?: boolean;
340
348
  uploadMaxFileSize?: number;
341
349
  showComposeDialog?: boolean;
342
350
  showHeader?: boolean;
@@ -659,11 +659,24 @@ export const ComposeForm: FC<ComposeFormProps> = ({
659
659
  publishVisibilityHiddenFromLatestHint: i18n._(
660
660
  msg({
661
661
  message:
662
- "Doesn't appear in Latest. Still appears in collections you add it to.",
662
+ "Doesn't appear in Latest. Still appears in the archive, search, and collections.",
663
663
  comment:
664
664
  "@context: Compose publish settings help text for posts hidden from Latest",
665
665
  }),
666
666
  ),
667
+ publishVisibilityUnlisted: i18n._(
668
+ msg({
669
+ message: "Unlisted",
670
+ comment: "@context: Compose publish settings visibility option",
671
+ }),
672
+ ),
673
+ publishVisibilityUnlistedHint: i18n._(
674
+ msg({
675
+ message: "Not listed anywhere. Only people with the link can see it.",
676
+ comment:
677
+ "@context: Compose publish settings help text for unlisted visibility",
678
+ }),
679
+ ),
667
680
  publishVisibilityPrivate: i18n._(
668
681
  msg({
669
682
  message: "Private",
@@ -823,6 +836,12 @@ export const ComposeForm: FC<ComposeFormProps> = ({
823
836
  "@context: Compose publish button for posts hidden from Latest",
824
837
  }),
825
838
  ),
839
+ postUnlisted: i18n._(
840
+ msg({
841
+ message: "Post unlisted",
842
+ comment: "@context: Compose publish button for unlisted visibility",
843
+ }),
844
+ ),
826
845
  postPrivately: i18n._(
827
846
  msg({
828
847
  message: "Post privately",
@@ -888,6 +907,12 @@ export const ComposeForm: FC<ComposeFormProps> = ({
888
907
  "@context: First-use hint shown over the compose editor to surface the slash command menu",
889
908
  }),
890
909
  ),
910
+ highlight: i18n._(
911
+ msg({
912
+ message: "Highlight",
913
+ comment: "@context: Selection toolbar button that highlights text",
914
+ }),
915
+ ),
891
916
  tableControls: {
892
917
  toolbarLabel: i18n._(
893
918
  msg({
@@ -67,6 +67,17 @@ export const StatusBadge: FC<StatusBadgeProps> = ({
67
67
  )}
68
68
  </span>
69
69
  )}
70
+ {visibility === "unlisted" && (
71
+ <span class="badge-outline">
72
+ {i18n._(
73
+ msg({
74
+ message: "Unlisted",
75
+ comment:
76
+ "@context: Post badge for posts that open for anyone with the link but are listed nowhere",
77
+ }),
78
+ )}
79
+ </span>
80
+ )}
70
81
  {pinned && (
71
82
  <span class="badge-outline">
72
83
  {i18n._(
@@ -115,6 +115,7 @@ export function FontThemeContent({
115
115
  style="font-family:var(--font-body);font-size:var(--type-body-size);line-height:var(--type-body-leading);letter-spacing:var(--type-body-tracking)"
116
116
  >
117
117
  <div class="feed-link-domain">
118
+ <span>{FONT_THEME_PREVIEW.linkMeta}</span>
118
119
  <svg
119
120
  class="feed-link-domain-icon"
120
121
  xmlns="http://www.w3.org/2000/svg"
@@ -126,7 +127,6 @@ export function FontThemeContent({
126
127
  >
127
128
  <path d="M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" />
128
129
  </svg>
129
- <span>{FONT_THEME_PREVIEW.linkMeta}</span>
130
130
  </div>
131
131
  <div class="feed-link-title mt-1">
132
132
  <span class="feed-link-title-link">
@@ -543,6 +543,14 @@ export function NavigationContent({
543
543
  comment: "@context: Shown when a pasted address resolves to a draft",
544
544
  }),
545
545
  ),
546
+ addressUnlisted: i18n._(
547
+ msg({
548
+ message:
549
+ "That page is unlisted. Make it Public or Hidden from Latest to add it to the menu.",
550
+ comment:
551
+ "@context: Shown when a pasted address resolves to an unlisted page, which a menu entry would list",
552
+ }),
553
+ ),
546
554
  addressPrivate: i18n._(
547
555
  msg({
548
556
  message: "That page is private, so nobody could open it from a menu.",
@@ -30,6 +30,7 @@ const ICONS = {
30
30
  send: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"/><path d="m21.854 2.147-10.94 10.939"/></svg>`,
31
31
  cloud: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z"/></svg>`,
32
32
  sliders: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" x2="4" y1="21" y2="14"/><line x1="4" x2="4" y1="10" y2="3"/><line x1="12" x2="12" y1="21" y2="12"/><line x1="12" x2="12" y1="8" y2="3"/><line x1="20" x2="20" y1="21" y2="16"/><line x1="20" x2="20" y1="12" y2="3"/><line x1="1" x2="7" y1="14" y2="14"/><line x1="9" x2="15" y1="8" y2="8"/><line x1="17" x2="23" y1="16" y2="16"/></svg>`,
33
+ barChart: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3v18h18"/><path d="M18 17V9"/><path d="M13 17V5"/><path d="M8 17v-3"/></svg>`,
33
34
  };
34
35
 
35
36
  export function SettingsRootContent({
@@ -138,19 +139,19 @@ export function SettingsRootContent({
138
139
  )}
139
140
  />
140
141
  <SettingsDirectoryLink
141
- href={toPublicPath("/settings/custom-urls", sitePathPrefix)}
142
- icon={ICONS.arrowRightLeft}
142
+ href={toPublicPath("/settings/stats", sitePathPrefix)}
143
+ icon={ICONS.barChart}
143
144
  tone="subtle"
144
145
  name={i18n._(
145
146
  msg({
146
- message: "Custom URLs",
147
- comment: "@context: Settings item — custom URL settings",
147
+ message: "Stats",
148
+ comment: "@context: Settings item — view stats",
148
149
  }),
149
150
  )}
150
151
  description={i18n._(
151
152
  msg({
152
- message: "Redirects, vanity paths, and URL control",
153
- comment: "@context: Settings item description for custom URLs",
153
+ message: "Views by day, most-read pages, and referrers",
154
+ comment: "@context: Settings item description for stats",
154
155
  }),
155
156
  )}
156
157
  />
@@ -303,6 +304,23 @@ export function SettingsRootContent({
303
304
  }),
304
305
  )}
305
306
  >
307
+ <SettingsDirectoryLink
308
+ href={toPublicPath("/settings/custom-urls", sitePathPrefix)}
309
+ icon={ICONS.arrowRightLeft}
310
+ tone="subtle"
311
+ name={i18n._(
312
+ msg({
313
+ message: "Custom URLs",
314
+ comment: "@context: Settings item — custom URL settings",
315
+ }),
316
+ )}
317
+ description={i18n._(
318
+ msg({
319
+ message: "Redirects, vanity paths, and URL control",
320
+ comment: "@context: Settings item description for custom URLs",
321
+ }),
322
+ )}
323
+ />
306
324
  <SettingsDirectoryLink
307
325
  href={toPublicPath("/settings/code-injection", sitePathPrefix)}
308
326
  icon={ICONS.terminal}