@jant/core 1.1.0 → 1.2.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 (116) hide show
  1. package/bin/lib/site-snapshot.js +10 -0
  2. package/dist/{app-CKQ9PqAr.js → app-CbOZ2Irh.js} +7988 -5166
  3. package/dist/client/.vite/manifest.json +47 -47
  4. package/dist/client/_assets/chunks/{create-editor-BQkrw8Ax.js → create-editor-hWapNE40.js} +25 -25
  5. package/dist/client/_assets/chunks/footnote-rail-9zwl6jtV.js +2 -0
  6. package/dist/client/_assets/chunks/{settings-paths-B0bNUaih.js → settings-paths-BBVT8zKj.js} +1 -1
  7. package/dist/client/_assets/chunks/{slug-format-CYmQE5ln.js → slug-format-BuCPjSrB.js} +1 -1
  8. package/dist/client/_assets/chunks/sortable-list-DJXwkaOv.js +2 -0
  9. package/dist/client/_assets/chunks/types-DrYFqJH2.js +1 -0
  10. package/dist/client/_assets/chunks/unsafe-svg-CUrgo4Xg.js +1 -0
  11. package/dist/client/_assets/{client-Dp46QSht.js → client-BO8GOFfT.js} +12 -12
  12. package/dist/client/_assets/client-D8Rrsd73.css +2 -0
  13. package/dist/client/_assets/{client-auth-CG55rWb5.js → client-auth-CsUGM718.js} +1 -1
  14. package/dist/client/_assets/client-author-QPm1whbO.css +2 -0
  15. package/dist/client/_assets/client-compose-BB4U7Wz0.js +2004 -0
  16. package/dist/client/_assets/{client-manage-DnYdQAhf.js → client-manage-CI9-eh-8.js} +1 -1
  17. package/dist/client/_assets/{client-settings-CHgsIqXJ.js → client-settings-BnGPuqwc.js} +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/node.js +3 -2
  20. package/package.json +1 -1
  21. package/src/app.tsx +9 -0
  22. package/src/client/components/compose-types.ts +1 -0
  23. package/src/client/components/jant-compose-dialog.ts +1 -0
  24. package/src/client/components/jant-compose-editor.ts +30 -0
  25. package/src/client/components/jant-compose-fullscreen.ts +1 -0
  26. package/src/client/compose-bridge.ts +61 -1
  27. package/src/client/feed-video-player.ts +6 -0
  28. package/src/client/tiptap/bubble-menu.ts +25 -2
  29. package/src/client/tiptap/create-editor.ts +2 -0
  30. package/src/client/tiptap/extensions.ts +4 -0
  31. package/src/client/video-processor.ts +106 -52
  32. package/src/client/view-confirm.ts +108 -0
  33. package/src/client.ts +1 -0
  34. package/src/db/migrations/0035_brainy_next_avengers.sql +9 -0
  35. package/src/db/migrations/0036_gorgeous_smasher.sql +7 -0
  36. package/src/db/migrations/meta/0035_snapshot.json +2877 -0
  37. package/src/db/migrations/meta/0036_snapshot.json +2924 -0
  38. package/src/db/migrations/meta/_journal.json +14 -0
  39. package/src/db/migrations/pg/0033_cute_magdalene.sql +10 -0
  40. package/src/db/migrations/pg/0034_material_agent_brand.sql +8 -0
  41. package/src/db/migrations/pg/meta/0033_snapshot.json +3719 -0
  42. package/src/db/migrations/pg/meta/0034_snapshot.json +3766 -0
  43. package/src/db/migrations/pg/meta/_journal.json +14 -0
  44. package/src/db/pg/schema.ts +40 -0
  45. package/src/db/schema.ts +61 -0
  46. package/src/i18n/locales/public/en.po +5 -0
  47. package/src/i18n/locales/public/en.ts +1 -1
  48. package/src/i18n/locales/public/zh-Hans.po +5 -0
  49. package/src/i18n/locales/public/zh-Hans.ts +1 -1
  50. package/src/i18n/locales/public/zh-Hant.po +5 -0
  51. package/src/i18n/locales/public/zh-Hant.ts +1 -1
  52. package/src/i18n/locales/settings/en.po +149 -0
  53. package/src/i18n/locales/settings/en.ts +1 -1
  54. package/src/i18n/locales/settings/zh-Hans.po +149 -0
  55. package/src/i18n/locales/settings/zh-Hans.ts +1 -1
  56. package/src/i18n/locales/settings/zh-Hant.po +149 -0
  57. package/src/i18n/locales/settings/zh-Hant.ts +1 -1
  58. package/src/lib/env.ts +20 -0
  59. package/src/lib/github-app-state.ts +1 -1
  60. package/src/lib/github-app.ts +183 -1
  61. package/src/lib/markdown-manager.ts +129 -1
  62. package/src/lib/post-meta.ts +13 -3
  63. package/src/lib/referrer-aliases.ts +311 -0
  64. package/src/lib/render.tsx +10 -0
  65. package/src/lib/resolve-config.ts +14 -0
  66. package/src/lib/summary.ts +152 -54
  67. package/src/lib/tiptap-render.ts +1 -0
  68. package/src/lib/upload.ts +21 -1
  69. package/src/lib/video-playback.ts +55 -0
  70. package/src/lib/view-buffer.ts +201 -0
  71. package/src/lib/view-counting.ts +539 -0
  72. package/src/lib/view-token.ts +177 -0
  73. package/src/lib/view.ts +13 -1
  74. package/src/middleware/view-counter.ts +140 -0
  75. package/src/node/runtime.ts +4 -0
  76. package/src/preset.css +31 -14
  77. package/src/routes/api/media.ts +21 -3
  78. package/src/routes/dash/settings.tsx +433 -168
  79. package/src/routes/pages/archive.tsx +1 -0
  80. package/src/routes/pages/collection.tsx +6 -0
  81. package/src/routes/pages/collections.tsx +1 -0
  82. package/src/routes/pages/featured.tsx +1 -0
  83. package/src/routes/pages/home.tsx +1 -0
  84. package/src/routes/pages/page.tsx +3 -0
  85. package/src/routes/pages/smart-collection.tsx +2 -0
  86. package/src/routes/pages/subscribe.tsx +1 -0
  87. package/src/routes/view-confirm.ts +63 -0
  88. package/src/services/export-theme/assets/client-site.js +1 -1
  89. package/src/services/export-theme/styles/main.css +39 -21
  90. package/src/services/export.ts +2 -0
  91. package/src/services/index.ts +17 -0
  92. package/src/services/mcp.ts +31 -1
  93. package/src/services/media.ts +63 -0
  94. package/src/services/stats.ts +1130 -0
  95. package/src/styles/components-author.css +177 -0
  96. package/src/styles/components.css +11 -3
  97. package/src/styles/tokens.css +65 -30
  98. package/src/styles/ui.css +56 -13
  99. package/src/types/app-context.ts +9 -0
  100. package/src/types/bindings.ts +5 -0
  101. package/src/types/config.ts +54 -0
  102. package/src/types/views.ts +6 -0
  103. package/src/ui/compose/ComposeDialog.tsx +6 -0
  104. package/src/ui/dash/settings/SettingsRootContent.tsx +24 -6
  105. package/src/ui/dash/settings/StatsContent.tsx +855 -0
  106. package/src/ui/font-themes.ts +39 -6
  107. package/src/ui/layouts/BaseLayout.tsx +4 -2
  108. package/src/ui/layouts/SiteLayout.tsx +8 -3
  109. package/src/ui/shared/MediaGallery.tsx +19 -3
  110. package/dist/client/_assets/chunks/footnote-rail-B08scyhW.js +0 -2
  111. package/dist/client/_assets/chunks/sortable-list-t11Ma1Ek.js +0 -2
  112. package/dist/client/_assets/chunks/types-D5iF3H1a.js +0 -1
  113. package/dist/client/_assets/chunks/unsafe-svg-DZl-yjas.js +0 -1
  114. package/dist/client/_assets/client-B0-s9sqx.css +0 -2
  115. package/dist/client/_assets/client-author-CGVvrNZ8.css +0 -2
  116. package/dist/client/_assets/client-compose-DkUTuavR.js +0 -2004
@@ -535,7 +535,10 @@
535
535
  opacity: 0.5;
536
536
  }
537
537
 
538
+ /* The current page's name is the one piece that can be long (a post's
539
+ derived title); it takes the rest of the line and is cut, never wrapped. */
538
540
  .dash-breadcrumb-current {
541
+ @apply flex-1 min-w-0 truncate;
539
542
  color: var(--color-foreground);
540
543
  font-weight: var(--fw-medium);
541
544
  }
@@ -1619,4 +1622,178 @@
1619
1622
  .skel-section-lg {
1620
1623
  min-height: 300px;
1621
1624
  }
1625
+
1626
+ /* ---------------------------------------------------------------------- */
1627
+ /* Stats page: a window switch, a bar chart, two lists, one switch */
1628
+ /* ---------------------------------------------------------------------- */
1629
+
1630
+ .settings-stats {
1631
+ @apply flex flex-col;
1632
+ gap: 2rem;
1633
+ max-width: var(--form-max-width);
1634
+ }
1635
+
1636
+ .settings-stats-header {
1637
+ @apply flex flex-wrap items-baseline justify-between;
1638
+ gap: 0.75rem 1.5rem;
1639
+ }
1640
+
1641
+ .settings-stats-title {
1642
+ @apply flex flex-wrap items-baseline;
1643
+ gap: 0.5rem;
1644
+ margin: 0;
1645
+ font-size: var(--type-title);
1646
+ font-weight: var(--fw-semibold);
1647
+ line-height: var(--type-heading-leading);
1648
+ }
1649
+
1650
+ /* A page's name on its own stats page: at most two lines, then cut. An
1651
+ untitled note is named by its opening words, which can run long. */
1652
+ .settings-stats-title-name {
1653
+ display: -webkit-box;
1654
+ -webkit-box-orient: vertical;
1655
+ -webkit-line-clamp: 2;
1656
+ overflow: hidden;
1657
+ overflow-wrap: anywhere;
1658
+ }
1659
+
1660
+ .settings-stats-windows {
1661
+ @apply flex;
1662
+ gap: 0.25rem;
1663
+ font-family: var(--font-ui);
1664
+ font-size: var(--type-sm);
1665
+ }
1666
+
1667
+ .settings-stats-window {
1668
+ padding: 0.25rem 0.6rem;
1669
+ border-radius: 999px;
1670
+ color: var(--site-text-secondary);
1671
+ text-decoration: none;
1672
+ transition:
1673
+ color 150ms ease,
1674
+ background-color 150ms ease;
1675
+ }
1676
+
1677
+ .settings-stats-window:hover {
1678
+ color: var(--foreground);
1679
+ }
1680
+
1681
+ .settings-stats-window[aria-current="page"] {
1682
+ color: var(--foreground);
1683
+ background: var(--muted);
1684
+ }
1685
+
1686
+ .settings-stats-total {
1687
+ margin: 0;
1688
+ font-family: var(--font-ui);
1689
+ font-size: var(--type-subtitle);
1690
+ font-weight: var(--fw-medium);
1691
+ }
1692
+
1693
+ .settings-stats-figure {
1694
+ margin: 0;
1695
+ color: var(--primary);
1696
+ }
1697
+
1698
+ .settings-stats-chart {
1699
+ display: block;
1700
+ width: 100%;
1701
+ height: 9rem;
1702
+ }
1703
+
1704
+ .settings-stats-bar {
1705
+ fill: currentColor;
1706
+ opacity: 0.8;
1707
+ transition: opacity 150ms ease;
1708
+ }
1709
+
1710
+ .settings-stats-bar:hover {
1711
+ opacity: 1;
1712
+ }
1713
+
1714
+ /* The baseline under the bars. It starts where the record does: the chart
1715
+ sets `--stats-start` to the share of the window that was never counted. */
1716
+ .settings-stats-axis {
1717
+ @apply flex justify-between;
1718
+ margin-left: var(--stats-start, 0%);
1719
+ padding-top: 0.35rem;
1720
+ border-top: 1px solid var(--border);
1721
+ font-family: var(--font-ui);
1722
+ font-size: var(--type-xs);
1723
+ color: var(--site-text-secondary);
1724
+ }
1725
+
1726
+ .settings-stats-axis > span {
1727
+ white-space: nowrap;
1728
+ }
1729
+
1730
+ /* Today's date alone, under the end of the baseline. */
1731
+ .settings-stats-axis-single {
1732
+ @apply justify-end;
1733
+ }
1734
+
1735
+ .settings-stats-section {
1736
+ @apply flex flex-col;
1737
+ gap: 0.5rem;
1738
+ }
1739
+
1740
+ .settings-stats-heading {
1741
+ margin: 0;
1742
+ font-family: var(--font-ui);
1743
+ font-size: var(--type-xs);
1744
+ font-weight: var(--fw-medium);
1745
+ letter-spacing: 0.02em;
1746
+ color: var(--site-text-secondary);
1747
+ }
1748
+
1749
+ .settings-stats-list {
1750
+ @apply flex flex-col;
1751
+ gap: 0.125rem;
1752
+ margin: 0;
1753
+ padding: 0;
1754
+ list-style: none;
1755
+ }
1756
+
1757
+ /* A ranked row. The bar behind it is its share of the window's total,
1758
+ set by the row as `--stats-share`; the text sits on top of it. */
1759
+ .settings-stats-row {
1760
+ @apply flex items-center;
1761
+ gap: 0.75rem;
1762
+ padding: 0.45rem 0.625rem;
1763
+ border-radius: var(--radius-sm, 0.375rem);
1764
+ background: linear-gradient(
1765
+ to right,
1766
+ var(--muted) var(--stats-share, 0%),
1767
+ transparent var(--stats-share, 0%)
1768
+ );
1769
+ }
1770
+
1771
+ .settings-stats-rank {
1772
+ flex: none;
1773
+ min-width: 1.25rem;
1774
+ font-family: var(--font-ui);
1775
+ font-size: var(--type-sm);
1776
+ font-variant-numeric: tabular-nums;
1777
+ text-align: right;
1778
+ color: var(--site-text-secondary);
1779
+ }
1780
+
1781
+ .settings-stats-label {
1782
+ @apply flex-1 min-w-0 truncate;
1783
+ }
1784
+
1785
+ .settings-stats-link {
1786
+ color: inherit;
1787
+ text-decoration: none;
1788
+ }
1789
+
1790
+ .settings-stats-link:hover {
1791
+ text-decoration: underline;
1792
+ }
1793
+
1794
+ .settings-stats-count {
1795
+ font-family: var(--font-ui);
1796
+ font-variant-numeric: tabular-nums;
1797
+ color: var(--site-text-secondary);
1798
+ }
1622
1799
  }
@@ -10,14 +10,22 @@
10
10
  * see the note in `style-author.css`.
11
11
  */
12
12
 
13
- /* Search result highlight */
13
+ /* Highlighted text in a post */
14
14
  mark {
15
- background-color: var(--site-search-mark-bg);
16
- color: var(--site-search-mark-color);
15
+ background-color: var(--site-highlight-bg);
16
+ color: var(--site-highlight-color);
17
17
  border-radius: 2px;
18
18
  padding: 0 2px;
19
19
  }
20
20
 
21
+ /* Search result highlight. The search page renders snippets, never post
22
+ HTML, so every mark on it is a match. */
23
+ .search-page mark,
24
+ .search-snippet mark {
25
+ background-color: var(--site-search-mark-bg);
26
+ color: var(--site-search-mark-color);
27
+ }
28
+
21
29
  /* Config Editor — a quiet utility list, not a stack of nested cards. */
22
30
  @layer components {
23
31
  jant-config-editor {
@@ -17,11 +17,12 @@
17
17
  * otherwise drop the text to the OS last-resort font.
18
18
  */
19
19
  --font-cjk-serif-fallback:
20
- "Songti SC", STSong, SimSun, "Noto Serif SC", "Noto Serif CJK SC",
21
- "Songti TC", PMingLiU, MingLiU, "Noto Serif TC", "Noto Serif CJK TC",
22
- "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", YuMincho,
23
- "Noto Serif JP", "Noto Serif CJK JP", "MS PMincho", "MS Mincho", Batang,
24
- "Noto Serif KR", "Noto Serif CJK KR", NanumMyeongjo;
20
+ "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC",
21
+ STSong, SimSun, "Songti TC", "Noto Serif TC", "Noto Serif CJK TC",
22
+ "Source Han Serif TC", PMingLiU, MingLiU, "Hiragino Mincho ProN",
23
+ "Hiragino Mincho Pro", "Yu Mincho", YuMincho, "Noto Serif JP",
24
+ "Noto Serif CJK JP", "MS PMincho", "MS Mincho", Batang, "Noto Serif KR",
25
+ "Noto Serif CJK KR", NanumMyeongjo;
25
26
  --font-cjk-sans-fallback:
26
27
  "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
27
28
  "Noto Sans CJK SC", "PingFang TC", "Hiragino Sans CNS",
@@ -97,8 +98,14 @@
97
98
  /* Content reading tokens — desktop maps to core scale,
98
99
  mobile overrides below cap sizes for small screens.
99
100
  --type-content-scale uniformly scales all content sizes
100
- without affecting UI controls. */
101
- --type-content-scale: 0.8;
101
+ without affecting UI controls.
102
+
103
+ 0.81 puts the body at 17px (21px × 0.81). Latin reading surfaces run
104
+ 17–21 (Ghost 17–19, Substack 20, Medium 21); Chinese ones settle on 17
105
+ (sspai, Apple), since a Han glyph fills its em where Latin lowercase
106
+ fills half, so the same px reads a size larger. 18 was tried and read
107
+ as big on a 13-inch laptop. Titles and headings keep their ratios. */
108
+ --type-content-scale: 0.81;
102
109
  --type-content-display: calc(var(--type-display) * var(--type-content-scale));
103
110
  --type-content-title: calc(var(--type-title) * var(--type-content-scale));
104
111
  --type-content-subtitle: calc(
@@ -126,12 +133,24 @@
126
133
  --type-thread-context-meta: var(--type-sm);
127
134
  --feed-note-title-size: calc(var(--type-content-body) * 1.36);
128
135
  --feed-note-title-leading: var(--type-heading-leading);
136
+ /*
137
+ * Reading rhythm. A page in Chinese, Japanese or Korean raises both
138
+ * leadings (`getCjkFontCssVariables` in ui/font-themes.ts): Han glyphs fill
139
+ * the em box, so the same line-height packs CJK lines tighter than Latin.
140
+ */
129
141
  --type-body-leading: 1.7;
130
142
  --type-display-leading: 1.15;
131
- --type-heading-leading: 1.15;
132
- --type-heading-weight: var(--fw-medium);
143
+ --type-heading-leading: 1.2;
144
+ /*
145
+ * Semibold, not medium: a heading has to outweigh bold body text, and the
146
+ * CJK serif faces have no 500 — Songti SC resolves 500 to Regular and 600
147
+ * to Bold, so medium headings came out lighter than the <strong> runs
148
+ * beneath them. Latin faces with a 500 (New York, Literata, Source Sans)
149
+ * step up half a weight. Tufte opts back out to Regular, its own look.
150
+ */
151
+ --type-heading-weight: var(--fw-semibold);
133
152
  --type-heading-tracking: 0;
134
- --type-display-weight: var(--fw-medium);
153
+ --type-display-weight: var(--fw-semibold);
135
154
  --type-display-tracking: 0;
136
155
  --type-label-weight: var(--fw-medium);
137
156
  --type-label-tracking: 0.08em;
@@ -152,15 +171,16 @@
152
171
  *
153
172
  * `--layout-reading-width` is the reading column a post's text actually
154
173
  * gets. It tracks the proportion while the gutter exists, then keeps a
155
- * measure of its own instead of going full-width. Anything that must line
156
- * up with body copy — the text blocks in preset.css, a lone image
157
- * (MediaGallery `getSingleVisualWidth`), a link preview, the feed divider
158
- * that centers over the column — reads this one. Before it existed those
159
- * consumers capped on the proportion and quietly outgrew the text between
160
- * 700px and 1024px.
174
+ * measure of its own, `--layout-reading-measure`, instead of going
175
+ * full-width. Anything that must line up with body copy — the text blocks
176
+ * in preset.css, a lone image (MediaGallery `getSingleVisualWidth`), a link
177
+ * preview, the feed divider that centers over the column — reads this one.
178
+ * Before it existed those consumers capped on the proportion and quietly
179
+ * outgrew the text between 700px and 1024px.
161
180
  */
162
181
  --layout-content-width: 55%;
163
182
  --layout-reading-width: var(--layout-content-width);
183
+ --layout-reading-measure: 35rem;
164
184
  --layout-sidenote-width: 50%;
165
185
  --layout-sidenote-gap: 10%;
166
186
  --layout-sidenote-margin: -60%;
@@ -460,6 +480,11 @@
460
480
  --site-search-mark-bg: oklch(0.92 0.14 90 / 0.55);
461
481
  --site-search-mark-color: oklch(0.35 0.09 70);
462
482
 
483
+ /* Highlighted text in posts (`==text==`). Follows each theme's search
484
+ colors until a theme sets it, and every theme sets those on :root. */
485
+ --site-highlight-bg: var(--site-search-mark-bg);
486
+ --site-highlight-color: var(--site-search-mark-color);
487
+
463
488
  /* Admin */
464
489
  --dash-bg: oklch(0.97 0.005 80);
465
490
  --dash-card-radius: 10px;
@@ -477,19 +502,22 @@
477
502
  * dialog.
478
503
  *
479
504
  * 480px Header hamburger; the composer's post-meta pill sheds its words.
480
- * 580px Nav collapse tier-sm (hides the 3rd inline link).
481
505
  * 640px Media grid and lightbox chrome.
482
506
  * 700px THE PHONE SWITCH. Below it the layout is a phone's: the composer
483
507
  * is a full-screen sheet, the compose FAB appears, page gutters and
484
508
  * the content type scale go narrow. Written `max-width: 699px` on
485
509
  * the phone side and `min-width: 700px` on the desktop side, so the
486
510
  * two never both match at 700px itself.
487
- * 780px Nav collapse tier-md (also hides the 4th inline link).
488
- * 960px Nav collapse tier-lg (hides the 5th+ inline link into More).
489
- * 1024px Tufte two-column → single-column (see the note below).
511
+ * 960px The full-screen composer tightens its padding and title sizes.
512
+ * 1024px Tufte two-column → single-column, and the page frame narrows to
513
+ * the reading column (see the note below).
490
514
  * 1079px Collections sidebar drops out.
491
515
  * 1200px Header search collapses to an icon.
492
516
  *
517
+ * The header's nav links are not on this list: they collapse into More by the
518
+ * header's own width (`@container site-header` in ui.css), because the same
519
+ * viewport gives a reader page a narrower header than a settings page.
520
+ *
493
521
  * Touch is NOT a width. Thumb-sized controls and always-visible affordances
494
522
  * belong to `(hover: none) and (pointer: coarse)`, which is what actually
495
523
  * catches a phone or a tablet; a narrow desktop window is still a mouse.
@@ -505,17 +533,19 @@
505
533
  /* Tufte two-column → single-column collapse.
506
534
  *
507
535
  * There is no room for a 45% sidenote gutter here, so page shells go
508
- * full-width — but the reading column does not follow them. It keeps a 35rem
509
- * measure, and everything sized to the text (preset.css blocks, single images,
510
- * link previews, the feed divider) tracks that through
511
- * `--layout-reading-width` rather than restating the number.
536
+ * full-width — but the reading column does not follow them. It keeps
537
+ * `--layout-reading-measure`, and everything sized to the text (preset.css
538
+ * blocks, single images, link previews, the feed divider) tracks that through
539
+ * `--layout-reading-width` rather than restating the number. The page frame
540
+ * narrows to the same measure and centers (ui.css), so the column has no
541
+ * leftover width piled up on its right.
512
542
  *
513
543
  * Keep this breakpoint in sync with the sidenote float→inline collapse
514
544
  * (ui.css). They are one layout switch; do not let them drift apart. */
515
545
  @media (max-width: 1024px) {
516
546
  :root {
517
547
  --layout-content-width: 100%;
518
- --layout-reading-width: min(100%, 35rem);
548
+ --layout-reading-width: min(100%, var(--layout-reading-measure));
519
549
  }
520
550
  }
521
551
 
@@ -628,14 +658,19 @@
628
658
  @media (max-width: 699px), (hover: none) and (pointer: coarse) {
629
659
  :root {
630
660
  /* Content layer — tighter scale for mobile reading.
661
+ Body keeps the desktop size; the headings sit closer to it than
662
+ desktop's 2.7 / 2.1 / 1.8 rem so a title fits a phone line.
631
663
  Ratio ≈ 1.88 : 1.42 : 1.15 : 1 (display:title:subtitle:body).
632
- At 15px root × 0.8 content-scale: 29.4 / 22.2 / 18 / 15.6px.
664
+ At 15px root × 0.81 content-scale: 32 / 24.2 / 19.6 / 17px.
633
665
  Body is floored to a 16px minimum below (max()) for readability;
634
666
  the floor still yields to calc() when the user zooms the root up. */
635
- --type-content-display: calc(2.45rem * var(--type-content-scale));
636
- --type-content-title: calc(1.85rem * var(--type-content-scale));
637
- --type-content-subtitle: calc(1.5rem * var(--type-content-scale));
638
- --type-content-body: max(16px, calc(1.3rem * var(--type-content-scale)));
667
+ --type-content-display: calc(2.63rem * var(--type-content-scale));
668
+ --type-content-title: calc(1.99rem * var(--type-content-scale));
669
+ --type-content-subtitle: calc(1.61rem * var(--type-content-scale));
670
+ --type-content-body: max(
671
+ 16px,
672
+ calc(var(--type-body) * var(--type-content-scale))
673
+ );
639
674
 
640
675
  /* UI layer — pixel floors for touch targets */
641
676
  --type-ui-title: max(16px, var(--type-secondary));
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
  }
@@ -2460,10 +2499,14 @@
2460
2499
  margin-bottom: 1.7rem;
2461
2500
  }
2462
2501
 
2502
+ /* Title, then the date a clear step below it, then air before the body:
2503
+ the three tiers every well-set article page keeps (Medium, Substack,
2504
+ Ghost). At 0.7rem the date sat on the title's descenders. */
2463
2505
  .post-header-block-detail {
2464
2506
  display: flex;
2465
2507
  flex-direction: column;
2466
- gap: 0.7rem;
2508
+ gap: 0.9rem;
2509
+ margin-bottom: 2.2rem;
2467
2510
  }
2468
2511
 
2469
2512
  .post-header-block .feed-link-title,
@@ -2497,7 +2540,7 @@
2497
2540
  .post-header-meta-link {
2498
2541
  color: var(--site-text-secondary);
2499
2542
  font-family: var(--font-ui);
2500
- font-size: var(--type-ui-hint);
2543
+ font-size: var(--type-ui-meta);
2501
2544
  text-decoration: none;
2502
2545
  white-space: nowrap;
2503
2546
  }
@@ -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. */
@@ -337,6 +337,12 @@ export interface SiteLayoutProps {
337
337
  siteFooterHtml?: string;
338
338
  showHomeBranding?: boolean;
339
339
  sidebar?: import("hono/jsx").Child;
340
+ /**
341
+ * Keep the wide page frame below 1024px, where reader pages narrow theirs
342
+ * to the reading column. For pages that size their own content: settings,
343
+ * the full-page composer.
344
+ */
345
+ wideFrame?: boolean;
340
346
  uploadMaxFileSize?: number;
341
347
  showComposeDialog?: boolean;
342
348
  showHeader?: boolean;
@@ -888,6 +888,12 @@ export const ComposeForm: FC<ComposeFormProps> = ({
888
888
  "@context: First-use hint shown over the compose editor to surface the slash command menu",
889
889
  }),
890
890
  ),
891
+ highlight: i18n._(
892
+ msg({
893
+ message: "Highlight",
894
+ comment: "@context: Selection toolbar button that highlights text",
895
+ }),
896
+ ),
891
897
  tableControls: {
892
898
  toolbarLabel: i18n._(
893
899
  msg({