@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.
- package/bin/commands/site/import.js +2 -1
- package/bin/lib/site-snapshot.js +10 -0
- package/dist/{app-CKQ9PqAr.js → app-C8dETvgL.js} +9267 -5697
- package/dist/client/.vite/manifest.json +82 -93
- package/dist/client/_assets/chunks/{confirm-CMe01lne.js → confirm-BQebcuNB.js} +1 -1
- package/dist/client/_assets/chunks/{create-editor-BQkrw8Ax.js → create-editor-B8KuszlS.js} +38 -38
- package/dist/client/_assets/chunks/footnote-rail-DUrqz0Py.js +2 -0
- package/dist/client/_assets/chunks/{jant-locale-picker-2L4rkDaz.js → jant-locale-picker-CLq0iKDH.js} +1 -1
- package/dist/client/_assets/chunks/lit-BN4mrI3j.js +2 -0
- package/dist/client/_assets/chunks/{settings-paths-B0bNUaih.js → settings-paths-_fry4yWW.js} +1 -1
- package/dist/client/_assets/chunks/{slug-format-CYmQE5ln.js → slug-format-bcJ2ozr4.js} +1 -1
- package/dist/client/_assets/chunks/sortable-list-Bz2Na2E9.js +2 -0
- package/dist/client/_assets/chunks/types-DrYFqJH2.js +1 -0
- package/dist/client/_assets/chunks/{unsafe-html-CWos3v6N.js → unsafe-html-OJ9m154w.js} +1 -1
- package/dist/client/_assets/chunks/unsafe-svg-DVJ4NPcb.js +1 -0
- package/dist/client/_assets/client-CoNHvipV.css +2 -0
- package/dist/client/_assets/{client-auth-CG55rWb5.js → client-auth-CbnZkLJ6.js} +99 -129
- package/dist/client/_assets/{client-author-CGVvrNZ8.css → client-author-2WYBkgni.css} +1 -1
- package/dist/client/_assets/client-compose-DYtDlYm-.js +2008 -0
- package/dist/client/_assets/{client-manage-DnYdQAhf.js → client-manage-BODyYP5Z.js} +157 -157
- package/dist/client/_assets/client-pq6sVS7y.js +354 -0
- package/dist/client/_assets/{client-settings-CHgsIqXJ.js → client-settings-DDpe_tXJ.js} +166 -166
- package/dist/client/_assets/client-share-B9OsXx9p.js +149 -0
- package/dist/{constants-DEgyqWDl.js → constants-C2CdWAqt.js} +55 -5
- package/dist/index.js +1 -1
- package/dist/node.js +3 -2
- package/package.json +2 -1
- package/src/app.tsx +9 -0
- package/src/client/components/compose-types.ts +6 -1
- package/src/client/components/jant-compose-dialog.ts +26 -4
- package/src/client/components/jant-compose-editor.ts +30 -0
- package/src/client/components/jant-compose-fullscreen.ts +1 -0
- package/src/client/components/jant-media-lightbox.ts +18 -3
- package/src/client/components/jant-nav-manager.ts +2 -0
- package/src/client/components/jant-post-menu.ts +42 -89
- package/src/client/components/nav-manager-types.ts +2 -0
- package/src/client/components/settings-types.ts +1 -1
- package/src/client/compose-bridge.ts +61 -1
- package/src/client/feed-video-player.ts +6 -0
- package/src/client/list-views.ts +382 -0
- package/src/client/media-lightbox-events.ts +12 -0
- package/src/client/runtime-paths.ts +12 -0
- package/src/client/share-capture.ts +63 -0
- package/src/client/share-launch.ts +36 -9
- package/src/client/tiptap/bubble-menu.ts +25 -2
- package/src/client/tiptap/create-editor.ts +6 -0
- package/src/client/tiptap/embed-node.ts +3 -1
- package/src/client/tiptap/extensions.ts +4 -0
- package/src/client/tiptap/html-block-node.ts +3 -1
- package/src/client/tiptap/image-node.ts +3 -1
- package/src/client/video-processor.ts +106 -52
- package/src/client/view-confirm.ts +136 -0
- package/src/client.ts +2 -0
- package/src/db/migrations/0035_brainy_next_avengers.sql +9 -0
- package/src/db/migrations/0036_gorgeous_smasher.sql +7 -0
- package/src/db/migrations/0037_round_post.sql +16 -0
- package/src/db/migrations/0038_flashy_changeling.sql +15 -0
- package/src/db/migrations/0039_mixed_sister_grimm.sql +1 -0
- package/src/db/migrations/meta/0035_snapshot.json +2877 -0
- package/src/db/migrations/meta/0036_snapshot.json +2924 -0
- package/src/db/migrations/meta/0037_snapshot.json +2932 -0
- package/src/db/migrations/meta/0038_snapshot.json +2924 -0
- package/src/db/migrations/meta/0039_snapshot.json +2931 -0
- package/src/db/migrations/meta/_journal.json +35 -0
- package/src/db/migrations/pg/0033_cute_magdalene.sql +10 -0
- package/src/db/migrations/pg/0034_material_agent_brand.sql +8 -0
- package/src/db/migrations/pg/0035_flimsy_outlaw_kid.sql +3 -0
- package/src/db/migrations/pg/0036_milky_wolverine.sql +5 -0
- package/src/db/migrations/pg/0037_fuzzy_hammerhead.sql +1 -0
- package/src/db/migrations/pg/meta/0033_snapshot.json +3719 -0
- package/src/db/migrations/pg/meta/0034_snapshot.json +3766 -0
- package/src/db/migrations/pg/meta/0035_snapshot.json +3773 -0
- package/src/db/migrations/pg/meta/0036_snapshot.json +3766 -0
- package/src/db/migrations/pg/meta/0037_snapshot.json +3772 -0
- package/src/db/migrations/pg/meta/_journal.json +35 -0
- package/src/db/pg/schema.ts +41 -0
- package/src/db/post-visibility.ts +37 -6
- package/src/db/schema.ts +64 -0
- package/src/i18n/locales/glossary.zh-Hans.yml +4 -0
- package/src/i18n/locales/glossary.zh-Hant.yml +4 -0
- package/src/i18n/locales/public/en.po +26 -7
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +25 -6
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +25 -6
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +159 -0
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +159 -0
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +159 -0
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/lib/api-public-posts.ts +10 -0
- package/src/lib/env.ts +20 -0
- package/src/lib/feed-policy.ts +2 -2
- package/src/lib/filter-dimensions.ts +11 -4
- package/src/lib/github-app-state.ts +1 -1
- package/src/lib/github-app.ts +183 -1
- package/src/lib/hugo-markdown.ts +7 -0
- package/src/lib/icons.ts +2 -0
- package/src/lib/link-preview.ts +499 -0
- package/src/lib/list-views.ts +117 -0
- package/src/lib/markdown-manager.ts +169 -2
- package/src/lib/navigation.ts +1 -1
- package/src/lib/post-meta.ts +13 -3
- package/src/lib/referrer-aliases.ts +311 -0
- package/src/lib/render.tsx +10 -0
- package/src/lib/resolve-config.ts +14 -0
- package/src/lib/share-card.ts +4 -3
- package/src/lib/summary.ts +152 -54
- package/src/lib/thread-query.ts +6 -2
- package/src/lib/timeline.ts +12 -11
- package/src/lib/tiptap-render.ts +1 -0
- package/src/lib/upload.ts +21 -1
- package/src/lib/url-fetch.ts +291 -74
- package/src/lib/video-playback.ts +55 -0
- package/src/lib/view-buffer.ts +201 -0
- package/src/lib/view-counting.ts +540 -0
- package/src/lib/view-token.ts +199 -0
- package/src/lib/view.ts +30 -1
- package/src/middleware/view-counter.ts +145 -0
- package/src/node/runtime.ts +4 -0
- package/src/preset.css +36 -17
- package/src/routes/api/media.ts +21 -3
- package/src/routes/api/search.ts +1 -1
- package/src/routes/dash/settings.tsx +434 -169
- package/src/routes/feed/sitemap.ts +1 -1
- package/src/routes/pages/archive.tsx +26 -19
- package/src/routes/pages/collection.tsx +9 -3
- package/src/routes/pages/collections.tsx +1 -0
- package/src/routes/pages/featured.tsx +1 -0
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/page.tsx +18 -3
- package/src/routes/pages/search.tsx +3 -3
- package/src/routes/pages/smart-collection.tsx +2 -0
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/view-confirm.ts +71 -0
- package/src/services/collection.ts +1 -1
- package/src/services/export-theme/assets/client-site.js +19 -19
- package/src/services/export-theme/layouts/archive/list.html +4 -2
- package/src/services/export-theme/layouts/partials/collection-members.html +4 -3
- package/src/services/export-theme/layouts/partials/featured-members.html +3 -3
- package/src/services/export-theme/layouts/partials/head.html +2 -0
- package/src/services/export-theme/layouts/partials/latest-members.html +4 -4
- package/src/services/export-theme/layouts/partials/post-card.html +1 -9
- package/src/services/export-theme/layouts/partials/reply.html +1 -9
- package/src/services/export-theme/layouts/partials/smart-collection-members.html +4 -3
- package/src/services/export-theme/layouts/post/list.html +1 -9
- package/src/services/export-theme/styles/main.css +41 -47
- package/src/services/export.ts +12 -3
- package/src/services/index.ts +17 -0
- package/src/services/mcp.ts +36 -6
- package/src/services/media.ts +63 -0
- package/src/services/navigation.ts +9 -4
- package/src/services/post.ts +102 -112
- package/src/services/search.ts +22 -7
- package/src/services/smart-collection.ts +3 -3
- package/src/services/stats.ts +1137 -0
- package/src/services/thread.ts +6 -2
- package/src/styles/components-author.css +242 -3
- package/src/styles/components.css +11 -3
- package/src/styles/tokens.css +89 -55
- package/src/styles/ui-author.css +140 -353
- package/src/styles/ui.css +90 -45
- package/src/types/app-context.ts +9 -0
- package/src/types/bindings.ts +5 -0
- package/src/types/config.ts +54 -0
- package/src/types/constants.ts +68 -4
- package/src/types/entities.ts +1 -0
- package/src/types/views.ts +8 -0
- package/src/ui/compose/ComposeDialog.tsx +26 -1
- package/src/ui/dash/StatusBadge.tsx +11 -0
- package/src/ui/dash/appearance/FontThemeContent.tsx +1 -1
- package/src/ui/dash/appearance/NavigationContent.tsx +8 -0
- package/src/ui/dash/settings/SettingsRootContent.tsx +24 -6
- package/src/ui/dash/settings/StatsContent.tsx +855 -0
- package/src/ui/feed/LinkCard.tsx +19 -2
- package/src/ui/feed/PostStatusBadges.tsx +19 -3
- package/src/ui/feed/TimelineFeed.tsx +3 -0
- package/src/ui/font-themes.ts +56 -6
- package/src/ui/layouts/BaseLayout.tsx +4 -2
- package/src/ui/layouts/SiteLayout.tsx +8 -3
- package/src/ui/pages/ArchivePage.tsx +1 -0
- package/src/ui/shared/MediaGallery.tsx +19 -3
- package/src/ui/shared/PostFooter.tsx +1 -22
- package/src/ui/shared/custom-icons.ts +5 -5
- package/dist/client/_assets/chunks/footnote-rail-B08scyhW.js +0 -2
- package/dist/client/_assets/chunks/lit-Bw_voPoW.js +0 -2
- package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +0 -1
- package/dist/client/_assets/chunks/sortable-list-t11Ma1Ek.js +0 -2
- package/dist/client/_assets/chunks/types-D5iF3H1a.js +0 -1
- package/dist/client/_assets/chunks/unsafe-svg-DZl-yjas.js +0 -1
- package/dist/client/_assets/client-B0-s9sqx.css +0 -2
- package/dist/client/_assets/client-Dp46QSht.js +0 -354
- package/dist/client/_assets/client-compose-DkUTuavR.js +0 -2004
- package/dist/client/_assets/client-share-C59mOLJ1.js +0 -149
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Extension,
|
|
3
|
+
Mark,
|
|
4
|
+
markInputRule,
|
|
5
|
+
markPasteRule,
|
|
6
|
+
mergeAttributes,
|
|
3
7
|
Node,
|
|
4
8
|
getSchema,
|
|
5
9
|
type AnyExtension,
|
|
@@ -12,6 +16,7 @@ import CodeBlock from "@tiptap/extension-code-block";
|
|
|
12
16
|
import { OrderedList } from "@tiptap/extension-list";
|
|
13
17
|
import HardBreak from "@tiptap/extension-hard-break";
|
|
14
18
|
import Paragraph from "@tiptap/extension-paragraph";
|
|
19
|
+
import Heading from "@tiptap/extension-heading";
|
|
15
20
|
import Bold from "@tiptap/extension-bold";
|
|
16
21
|
import Italic from "@tiptap/extension-italic";
|
|
17
22
|
import Strike from "@tiptap/extension-strike";
|
|
@@ -455,6 +460,76 @@ const MarkdownStrike = Strike.extend({
|
|
|
455
460
|
},
|
|
456
461
|
});
|
|
457
462
|
|
|
463
|
+
/** Shared highlight mark for editing, Markdown interchange, and rich HTML paste. */
|
|
464
|
+
const MarkdownHighlight = Mark.create({
|
|
465
|
+
name: "highlight",
|
|
466
|
+
|
|
467
|
+
parseHTML() {
|
|
468
|
+
return [{ tag: "mark" }];
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
renderHTML() {
|
|
472
|
+
return ["mark", 0];
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
addKeyboardShortcuts() {
|
|
476
|
+
return {
|
|
477
|
+
"Mod-Shift-h": () => this.editor.commands.toggleMark(this.name),
|
|
478
|
+
};
|
|
479
|
+
},
|
|
480
|
+
|
|
481
|
+
// The character before `==` is checked with a lookbehind, never matched.
|
|
482
|
+
// `markInputRule` and `markPasteRule` delete everything matched ahead of
|
|
483
|
+
// the content, so a matched `是` in `这是==重点==` was deleted with the
|
|
484
|
+
// delimiters, and a matched line break failed Tiptap's check that the
|
|
485
|
+
// match is the text in the document, leaving `==text==` as typed.
|
|
486
|
+
addInputRules() {
|
|
487
|
+
return [
|
|
488
|
+
markInputRule({
|
|
489
|
+
find: /(?<!=)==([^=\s](?:(?:=(?!=)|[^=\n])*?[^=\s])?)==$/,
|
|
490
|
+
type: this.type,
|
|
491
|
+
}),
|
|
492
|
+
];
|
|
493
|
+
},
|
|
494
|
+
|
|
495
|
+
addPasteRules() {
|
|
496
|
+
return [
|
|
497
|
+
markPasteRule({
|
|
498
|
+
find: /(?<!=)==([^=\s](?:(?:=(?!=)|[^=\n])*?[^=\s])?)==(?!=)/g,
|
|
499
|
+
type: this.type,
|
|
500
|
+
}),
|
|
501
|
+
];
|
|
502
|
+
},
|
|
503
|
+
|
|
504
|
+
markdownTokenName: "highlight",
|
|
505
|
+
|
|
506
|
+
parseMarkdown(token, helpers) {
|
|
507
|
+
return helpers.applyMark(
|
|
508
|
+
"highlight",
|
|
509
|
+
helpers.parseInline(token.tokens ?? []),
|
|
510
|
+
);
|
|
511
|
+
},
|
|
512
|
+
|
|
513
|
+
renderMarkdown(node, helpers) {
|
|
514
|
+
return `==${helpers.renderChildren(node)}==`;
|
|
515
|
+
},
|
|
516
|
+
|
|
517
|
+
markdownTokenizer: {
|
|
518
|
+
name: "highlight",
|
|
519
|
+
level: "inline",
|
|
520
|
+
start(src: string) {
|
|
521
|
+
return src.indexOf("==");
|
|
522
|
+
},
|
|
523
|
+
tokenize(src: string, _tokens, helpers) {
|
|
524
|
+
const match = /^==((?:\\[^\n]|=(?!=)|[^=\\\n])+?)==(?![=])/.exec(src);
|
|
525
|
+
if (!match) return undefined;
|
|
526
|
+
const [raw, text = ""] = match;
|
|
527
|
+
if (text.trim() !== text) return undefined;
|
|
528
|
+
return { type: "highlight", raw, tokens: helpers.inlineTokens(text) };
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
});
|
|
532
|
+
|
|
458
533
|
/** Marked token for each HTML emphasis tag the parser accepts. */
|
|
459
534
|
const HTML_EMPHASIS_TOKEN_TYPES: Record<string, "strong" | "em" | "del"> = {
|
|
460
535
|
strong: "strong",
|
|
@@ -520,6 +595,42 @@ const MarkdownParagraph = Paragraph.extend({
|
|
|
520
595
|
},
|
|
521
596
|
});
|
|
522
597
|
|
|
598
|
+
/** Every level a Markdown or HTML heading can have. */
|
|
599
|
+
const ALL_HEADING_LEVELS = [1, 2, 3, 4, 5, 6] as const;
|
|
600
|
+
|
|
601
|
+
function clampHeadingLevel(level: unknown): number {
|
|
602
|
+
const value = typeof level === "number" ? Math.trunc(level) : 1;
|
|
603
|
+
return Math.min(Math.max(value, 1), 6);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Headings at every level the published post renders, created at three.
|
|
608
|
+
*
|
|
609
|
+
* `levels` limits what the author can make — the `#` to `###` input rules,
|
|
610
|
+
* the shortcuts and the heading commands. A post can still hold `####` and
|
|
611
|
+
* below: written through the API or MCP, imported, or pasted as Markdown.
|
|
612
|
+
* Tiptap draws a level outside `levels` as the first one and drops it on an
|
|
613
|
+
* HTML paste, so an `h4` opened in the editor looked like an `h1`, and one
|
|
614
|
+
* copied in from a web page became a paragraph. Here every level parses and
|
|
615
|
+
* renders as itself, the way `tiptap-render.ts` publishes it.
|
|
616
|
+
*/
|
|
617
|
+
const MarkdownHeading = Heading.extend({
|
|
618
|
+
parseHTML() {
|
|
619
|
+
return ALL_HEADING_LEVELS.map((level) => ({
|
|
620
|
+
tag: `h${level}`,
|
|
621
|
+
attrs: { level },
|
|
622
|
+
}));
|
|
623
|
+
},
|
|
624
|
+
|
|
625
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
626
|
+
return [
|
|
627
|
+
`h${clampHeadingLevel(node.attrs.level)}`,
|
|
628
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
629
|
+
0,
|
|
630
|
+
];
|
|
631
|
+
},
|
|
632
|
+
}).configure({ levels: [1, 2, 3] });
|
|
633
|
+
|
|
523
634
|
/**
|
|
524
635
|
* Ordered lists with CommonMark markers: digits only.
|
|
525
636
|
*
|
|
@@ -1156,7 +1267,7 @@ export function createMarkdownContentExtensions(
|
|
|
1156
1267
|
): Extensions {
|
|
1157
1268
|
return [
|
|
1158
1269
|
StarterKit.configure({
|
|
1159
|
-
heading:
|
|
1270
|
+
heading: false,
|
|
1160
1271
|
link: false,
|
|
1161
1272
|
codeBlock: false,
|
|
1162
1273
|
orderedList: false,
|
|
@@ -1168,10 +1279,12 @@ export function createMarkdownContentExtensions(
|
|
|
1168
1279
|
trailingNode: { notAfter: ["footnoteDefinition"] },
|
|
1169
1280
|
}),
|
|
1170
1281
|
MarkdownParagraph,
|
|
1282
|
+
MarkdownHeading,
|
|
1171
1283
|
MarkdownHardBreak,
|
|
1172
1284
|
MarkdownBold,
|
|
1173
1285
|
MarkdownItalic,
|
|
1174
1286
|
MarkdownStrike,
|
|
1287
|
+
MarkdownHighlight,
|
|
1175
1288
|
MarkdownHtmlEmphasis,
|
|
1176
1289
|
CommonMarkOrderedList,
|
|
1177
1290
|
SemanticLink.configure({
|
|
@@ -1382,10 +1495,64 @@ function expandCodeBlockFences(markdown: string): string {
|
|
|
1382
1495
|
return markdown;
|
|
1383
1496
|
}
|
|
1384
1497
|
|
|
1498
|
+
/**
|
|
1499
|
+
* Swap each `=` in a text node that could take part in a `==` delimiter for
|
|
1500
|
+
* a sentinel, which the serializer later writes as `\=`.
|
|
1501
|
+
*
|
|
1502
|
+
* Only two kinds of `=` can: one in a run of two or more, and one at either
|
|
1503
|
+
* end of the text (leading and trailing whitespace aside, since the
|
|
1504
|
+
* serializer moves it outside a mark), where a highlight's own `==` lands
|
|
1505
|
+
* right beside it. `a = b` and `E=mc²` stay as they are.
|
|
1506
|
+
*
|
|
1507
|
+
* @param text - A text node's text, outside code
|
|
1508
|
+
* @param sentinel - A string the document doesn't contain
|
|
1509
|
+
* @returns The text with those `=` replaced by the sentinel
|
|
1510
|
+
* @example
|
|
1511
|
+
* protectHighlightDelimiters("a==b and c = d=", "S"); // "aSSb and c = dS"
|
|
1512
|
+
*/
|
|
1513
|
+
function protectHighlightDelimiters(text: string, sentinel: string): string {
|
|
1514
|
+
return text
|
|
1515
|
+
.replace(/={2,}/g, (run) => sentinel.repeat(run.length))
|
|
1516
|
+
.replace(/^(\s*)=/, (_match, space: string) => `${space}${sentinel}`)
|
|
1517
|
+
.replace(/=(\s*)$/, (_match, space: string) => `${sentinel}${space}`);
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
/**
|
|
1521
|
+
* The upstream serializer escapes CommonMark delimiters but not `==`, so
|
|
1522
|
+
* literal text such as `a==b and c==d` came back as a highlight. Its escaping
|
|
1523
|
+
* hook is private: the `=` that need it go through a sentinel instead.
|
|
1524
|
+
*/
|
|
1525
|
+
class JantMarkdownManager extends MarkdownManager {
|
|
1526
|
+
override serialize(doc: JSONContent): string {
|
|
1527
|
+
const source = JSON.stringify(doc);
|
|
1528
|
+
let sentinel = "JANTLITERALEQUALS";
|
|
1529
|
+
while (source.includes(sentinel)) sentinel += "X";
|
|
1530
|
+
|
|
1531
|
+
// Builds a copy: the stored JSON is never changed, and code keeps its `=`.
|
|
1532
|
+
const protect = (node: JSONContent, insideCode = false): JSONContent => {
|
|
1533
|
+
const code =
|
|
1534
|
+
insideCode ||
|
|
1535
|
+
node.type === "codeBlock" ||
|
|
1536
|
+
node.marks?.some((mark) => mark.type === "code");
|
|
1537
|
+
return {
|
|
1538
|
+
...node,
|
|
1539
|
+
...(node.text && !code
|
|
1540
|
+
? { text: protectHighlightDelimiters(node.text, sentinel) }
|
|
1541
|
+
: {}),
|
|
1542
|
+
...(node.content
|
|
1543
|
+
? { content: node.content.map((child) => protect(child, code)) }
|
|
1544
|
+
: {}),
|
|
1545
|
+
};
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
return super.serialize(protect(doc)).split(sentinel).join("\\=");
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1385
1552
|
export function createMarkdownManager(
|
|
1386
1553
|
extensions: Extensions = createMarkdownContentExtensions(),
|
|
1387
1554
|
): MarkdownManager {
|
|
1388
|
-
return new
|
|
1555
|
+
return new JantMarkdownManager({
|
|
1389
1556
|
extensions,
|
|
1390
1557
|
markedOptions: MARKDOWN_MARKED_OPTIONS,
|
|
1391
1558
|
});
|
package/src/lib/navigation.ts
CHANGED
|
@@ -169,7 +169,7 @@ export async function getNavigationData(
|
|
|
169
169
|
collectionNavIds.length > 0
|
|
170
170
|
? await c.var.services.navItems.getCollectionFreshness(collectionNavIds, {
|
|
171
171
|
status: "published",
|
|
172
|
-
|
|
172
|
+
listedForReader: !isAuthenticated,
|
|
173
173
|
})
|
|
174
174
|
: undefined;
|
|
175
175
|
|
package/src/lib/post-meta.ts
CHANGED
|
@@ -5,6 +5,16 @@ import { extractBodyText } from "./summary.js";
|
|
|
5
5
|
const TITLE_MAX_CHARS = 72;
|
|
6
6
|
const DESCRIPTION_MAX_CHARS = 160;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* The columns a Post's name is derived from. A caller that has only these,
|
|
10
|
+
* such as a list joined from another table, can name a Post without loading
|
|
11
|
+
* the rest of it.
|
|
12
|
+
*/
|
|
13
|
+
export type PostNameSource = Pick<
|
|
14
|
+
Post,
|
|
15
|
+
"format" | "title" | "url" | "body" | "bodyText" | "quoteText" | "summary"
|
|
16
|
+
>;
|
|
17
|
+
|
|
8
18
|
/**
|
|
9
19
|
* Derive a clean plain-text projection of the body for human-facing meta.
|
|
10
20
|
*
|
|
@@ -13,7 +23,7 @@ const DESCRIPTION_MAX_CHARS = 160;
|
|
|
13
23
|
* pollutes the stored text with trailing URLs. Re-derive from the source
|
|
14
24
|
* TipTap JSON (`post.body`) without that option.
|
|
15
25
|
*/
|
|
16
|
-
function getCleanBodyText(post:
|
|
26
|
+
function getCleanBodyText(post: PostNameSource): string {
|
|
17
27
|
// Prefer re-derivation from `post.body` (TipTap JSON). Fall back to
|
|
18
28
|
// `post.bodyText` only when `body` is absent (legacy rows / fixtures);
|
|
19
29
|
// without link marks in the source, there is no URL pollution to worry
|
|
@@ -48,7 +58,7 @@ function clipText(text: string, maxChars: number): string {
|
|
|
48
58
|
return `${clipped.trimEnd()}...`;
|
|
49
59
|
}
|
|
50
60
|
|
|
51
|
-
function getTitleCandidate(post:
|
|
61
|
+
function getTitleCandidate(post: PostNameSource): string {
|
|
52
62
|
if (post.format === "quote") {
|
|
53
63
|
const quoteSnippet = getFirstParagraph(post.quoteText);
|
|
54
64
|
const attribution = normalizeText(
|
|
@@ -112,7 +122,7 @@ function getDescriptionCandidate(post: Post): string {
|
|
|
112
122
|
* @example
|
|
113
123
|
* getPostDisplayTitle(untitledNote); // "An untitled note about espresso."
|
|
114
124
|
*/
|
|
115
|
-
export function getPostDisplayTitle(post:
|
|
125
|
+
export function getPostDisplayTitle(post: PostNameSource): string {
|
|
116
126
|
return getTitleCandidate(post);
|
|
117
127
|
}
|
|
118
128
|
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The address a source is listed under, whatever address a reader came from.
|
|
3
|
+
*
|
|
4
|
+
* A reader from Reddit arrives from `reddit.com`, `old.reddit.com`,
|
|
5
|
+
* `out.reddit.com`, `redd.it` or the Android app, and a referrer list that
|
|
6
|
+
* keeps hostnames gives each its own line. This table folds the addresses a
|
|
7
|
+
* well-known site goes by into the one it is known by, so the list reads as
|
|
8
|
+
* sources. What is kept is still a domain, not a display name: a source the
|
|
9
|
+
* table does not know is a domain already, and one kind of value stays
|
|
10
|
+
* sortable, copyable and, later, filterable.
|
|
11
|
+
*
|
|
12
|
+
* A source has up to three kinds of entry. A family is a domain whose every
|
|
13
|
+
* subdomain is this source (`m.facebook.com`, `l.facebook.com`,
|
|
14
|
+
* `business.facebook.com`); a host folds to the nearest family above it. An
|
|
15
|
+
* alias is one host or word that names the source under another name: a
|
|
16
|
+
* short link (`t.co`), an old domain (`chat.openai.com`), the package id an
|
|
17
|
+
* Android app reports when it opens a link, or a word authors and platforms
|
|
18
|
+
* put in `utm_source` (`twitter`, `ig`). A pattern matches a whole host for a
|
|
19
|
+
* site with a domain per country (`google.co.uk`, `pinterest.de`). Lookup
|
|
20
|
+
* order is alias, pattern, family. Google has no family on purpose:
|
|
21
|
+
* `mail.google.com`, `docs.google.com` and `gemini.google.com` are sources of
|
|
22
|
+
* their own. A site that only ever appears under one address needs no entry.
|
|
23
|
+
*
|
|
24
|
+
* Which sites are worth an entry follows Plausible's source list and the
|
|
25
|
+
* Snowplow referer-parser database, plus the Chinese platforms they lack.
|
|
26
|
+
* Folding to a host rather than a name is this module's own choice.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
interface Source {
|
|
30
|
+
/** The address the source is listed under. */
|
|
31
|
+
readonly host: string;
|
|
32
|
+
/** Domains whose every subdomain is this source. */
|
|
33
|
+
readonly families?: readonly string[];
|
|
34
|
+
/** Hosts, Android package ids and `utm_source` words that name this source. */
|
|
35
|
+
readonly aliases?: readonly string[];
|
|
36
|
+
/** Whole hosts, for a site with a domain per country. */
|
|
37
|
+
readonly patterns?: readonly RegExp[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const SOURCES: readonly Source[] = [
|
|
41
|
+
// Social
|
|
42
|
+
{
|
|
43
|
+
host: "reddit.com",
|
|
44
|
+
families: ["reddit.com"],
|
|
45
|
+
aliases: [
|
|
46
|
+
"redd.it",
|
|
47
|
+
"com.reddit.frontpage",
|
|
48
|
+
"com.laurencedawson.reddit_sync",
|
|
49
|
+
"reddit",
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
host: "facebook.com",
|
|
54
|
+
families: ["facebook.com"],
|
|
55
|
+
aliases: [
|
|
56
|
+
"fb.me",
|
|
57
|
+
"fb.com",
|
|
58
|
+
"com.facebook.katana",
|
|
59
|
+
"com.facebook.orca",
|
|
60
|
+
"facebook",
|
|
61
|
+
"fb",
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
host: "instagram.com",
|
|
66
|
+
families: ["instagram.com"],
|
|
67
|
+
aliases: ["instagr.am", "com.instagram.android", "instagram", "ig"],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
host: "threads.com",
|
|
71
|
+
families: ["threads.com", "threads.net"],
|
|
72
|
+
aliases: ["com.instagram.barcelona", "threads"],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
host: "x.com",
|
|
76
|
+
families: ["x.com", "twitter.com"],
|
|
77
|
+
aliases: ["t.co", "com.twitter.android", "twitter", "x"],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
host: "youtube.com",
|
|
81
|
+
families: ["youtube.com"],
|
|
82
|
+
aliases: ["youtu.be", "com.google.android.youtube", "youtube", "yt"],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
host: "linkedin.com",
|
|
86
|
+
families: ["linkedin.com"],
|
|
87
|
+
aliases: ["lnkd.in", "com.linkedin.android", "linkedin"],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
host: "pinterest.com",
|
|
91
|
+
families: ["pinterest.com"],
|
|
92
|
+
aliases: ["pin.it", "com.pinterest", "pinterest"],
|
|
93
|
+
patterns: [/^pinterest\.(?:co\.|com\.)?[a-z]{2}$/],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
host: "tiktok.com",
|
|
97
|
+
families: ["tiktok.com"],
|
|
98
|
+
aliases: ["com.zhiliaoapp.musically", "tiktok"],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
host: "bsky.app",
|
|
102
|
+
families: ["bsky.app"],
|
|
103
|
+
aliases: ["xyz.blueskyweb.app", "bluesky", "bsky"],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
host: "tumblr.com",
|
|
107
|
+
families: ["tumblr.com"],
|
|
108
|
+
aliases: ["t.umblr.com", "tumblr"],
|
|
109
|
+
},
|
|
110
|
+
{ host: "vk.com", families: ["vk.com"], aliases: ["vkontakte.ru"] },
|
|
111
|
+
{ host: "medium.com", families: ["medium.com"] },
|
|
112
|
+
{
|
|
113
|
+
host: "wikipedia.org",
|
|
114
|
+
families: ["wikipedia.org"],
|
|
115
|
+
aliases: ["org.wikipedia", "wikipedia"],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
host: "news.ycombinator.com",
|
|
119
|
+
aliases: [
|
|
120
|
+
"hn.algolia.com",
|
|
121
|
+
"io.github.hidroh.materialistic",
|
|
122
|
+
"hackernews",
|
|
123
|
+
"hn",
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
{ host: "github.com", families: ["github.com"], aliases: ["github"] },
|
|
127
|
+
{ host: "disqus.com", families: ["disqus.com"], aliases: ["disq.us"] },
|
|
128
|
+
{ host: "quora.com", families: ["quora.com"] },
|
|
129
|
+
|
|
130
|
+
// Messaging
|
|
131
|
+
{
|
|
132
|
+
host: "t.me",
|
|
133
|
+
families: ["t.me", "telegram.org"],
|
|
134
|
+
aliases: [
|
|
135
|
+
"telegram.me",
|
|
136
|
+
"org.telegram.messenger",
|
|
137
|
+
"org.telegram.messenger.web",
|
|
138
|
+
"org.telegram.plus",
|
|
139
|
+
"telegram",
|
|
140
|
+
"tg",
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
host: "whatsapp.com",
|
|
145
|
+
families: ["whatsapp.com"],
|
|
146
|
+
aliases: ["wa.me", "com.whatsapp", "whatsapp"],
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
host: "discord.com",
|
|
150
|
+
families: ["discord.com", "discordapp.com"],
|
|
151
|
+
aliases: ["com.discord", "discord"],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
host: "slack.com",
|
|
155
|
+
families: ["slack.com"],
|
|
156
|
+
aliases: ["com.slack", "slack"],
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
host: "teams.microsoft.com",
|
|
160
|
+
aliases: ["statics.teams.cdn.office.net", "com.microsoft.teams", "teams"],
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
// Search
|
|
164
|
+
{
|
|
165
|
+
host: "google.com",
|
|
166
|
+
aliases: ["com.google.android.googlequicksearchbox", "google"],
|
|
167
|
+
patterns: [/^google\.(?:com|[a-z]{2,3}|co\.[a-z]{2}|com\.[a-z]{2})$/],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
host: "bing.com",
|
|
171
|
+
families: ["bing.com"],
|
|
172
|
+
aliases: ["ntp.msn.com", "cc.bingj.com", "bing"],
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
host: "yahoo.com",
|
|
176
|
+
aliases: ["yahoo"],
|
|
177
|
+
patterns: [/^(?:[a-z]{2}\.)?search\.yahoo\.com$/],
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
host: "duckduckgo.com",
|
|
181
|
+
families: ["duckduckgo.com"],
|
|
182
|
+
aliases: ["com.duckduckgo.mobile.android", "duckduckgo", "ddg"],
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
host: "yandex.ru",
|
|
186
|
+
aliases: ["ya.ru", "yandex"],
|
|
187
|
+
patterns: [/^(?:clck\.)?yandex\.(?:ru|com|ua|by|kz|uz|tm|fr|eu|com\.tr)$/],
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
host: "baidu.com",
|
|
191
|
+
families: ["baidu.com"],
|
|
192
|
+
aliases: ["com.baidu.searchbox", "baidu"],
|
|
193
|
+
},
|
|
194
|
+
{ host: "sogou.com", families: ["sogou.com"], aliases: ["sogou"] },
|
|
195
|
+
{ host: "so.com", families: ["so.com"], aliases: ["so.360.cn"] },
|
|
196
|
+
{ host: "sm.cn", families: ["sm.cn"] },
|
|
197
|
+
{ host: "naver.com", families: ["naver.com"], aliases: ["naver"] },
|
|
198
|
+
|
|
199
|
+
// AI assistants
|
|
200
|
+
{
|
|
201
|
+
host: "chatgpt.com",
|
|
202
|
+
families: ["chatgpt.com"],
|
|
203
|
+
aliases: ["chat.openai.com", "com.openai.chatgpt", "chatgpt", "openai"],
|
|
204
|
+
},
|
|
205
|
+
{ host: "claude.ai", aliases: ["com.anthropic.claude", "claude"] },
|
|
206
|
+
{
|
|
207
|
+
host: "perplexity.ai",
|
|
208
|
+
families: ["perplexity.ai"],
|
|
209
|
+
aliases: ["pplx.ai", "ai.perplexity.app", "perplexity"],
|
|
210
|
+
},
|
|
211
|
+
{ host: "gemini.google.com", aliases: ["gemini"] },
|
|
212
|
+
{ host: "copilot.microsoft.com", aliases: ["copilot.com", "copilot"] },
|
|
213
|
+
{ host: "grok.com", aliases: ["x.ai", "grok"] },
|
|
214
|
+
{ host: "deepseek.com", aliases: ["deepseek"] },
|
|
215
|
+
|
|
216
|
+
// Chinese platforms
|
|
217
|
+
{
|
|
218
|
+
host: "weibo.com",
|
|
219
|
+
families: ["weibo.com", "weibo.cn"],
|
|
220
|
+
aliases: ["t.cn", "com.sina.weibo", "weibo"],
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
host: "weixin.qq.com",
|
|
224
|
+
families: ["weixin.qq.com"],
|
|
225
|
+
aliases: ["com.tencent.mm", "wechat", "weixin"],
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
host: "zhihu.com",
|
|
229
|
+
families: ["zhihu.com"],
|
|
230
|
+
aliases: ["com.zhihu.android", "zhihu"],
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
host: "bilibili.com",
|
|
234
|
+
families: ["bilibili.com"],
|
|
235
|
+
aliases: ["b23.tv", "tv.danmaku.bili", "bilibili"],
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
host: "douban.com",
|
|
239
|
+
families: ["douban.com"],
|
|
240
|
+
aliases: ["com.douban.frodo", "douban"],
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
host: "xiaohongshu.com",
|
|
244
|
+
families: ["xiaohongshu.com"],
|
|
245
|
+
aliases: ["xhslink.com", "com.xingin.xhs", "xiaohongshu", "xhs"],
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
host: "douyin.com",
|
|
249
|
+
families: ["douyin.com"],
|
|
250
|
+
aliases: ["com.ss.android.ugc.aweme", "douyin"],
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
// Mail and feed readers
|
|
254
|
+
{ host: "mail.google.com", aliases: ["com.google.android.gm", "gmail"] },
|
|
255
|
+
{
|
|
256
|
+
host: "outlook.com",
|
|
257
|
+
aliases: [
|
|
258
|
+
"mail.live.com",
|
|
259
|
+
"outlook.live.com",
|
|
260
|
+
"outlook.office.com",
|
|
261
|
+
"outlook.office365.com",
|
|
262
|
+
"com.microsoft.office.outlook",
|
|
263
|
+
"outlook",
|
|
264
|
+
],
|
|
265
|
+
},
|
|
266
|
+
{ host: "mail.yahoo.com", aliases: ["com.yahoo.mobile.client.android.mail"] },
|
|
267
|
+
{ host: "feedly.com", families: ["feedly.com"], aliases: ["feedly"] },
|
|
268
|
+
{ host: "inoreader.com", families: ["inoreader.com"] },
|
|
269
|
+
];
|
|
270
|
+
|
|
271
|
+
// Maps, not plain objects: a tag word like `constructor` must find nothing.
|
|
272
|
+
const ALIASES = new Map<string, string>();
|
|
273
|
+
const FAMILIES = new Map<string, string>();
|
|
274
|
+
const PATTERNS: Array<readonly [RegExp, string]> = [];
|
|
275
|
+
for (const source of SOURCES) {
|
|
276
|
+
for (const alias of source.aliases ?? []) ALIASES.set(alias, source.host);
|
|
277
|
+
for (const family of source.families ?? []) FAMILIES.set(family, source.host);
|
|
278
|
+
for (const pattern of source.patterns ?? [])
|
|
279
|
+
PATTERNS.push([pattern, source.host]);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The address a source is listed under.
|
|
284
|
+
*
|
|
285
|
+
* @param host - A host, Android package id or tag word, already lowercased
|
|
286
|
+
* and without a leading `www.`
|
|
287
|
+
* @returns The address the stats list it under, or `host` itself when the
|
|
288
|
+
* table has no entry for it
|
|
289
|
+
* @example
|
|
290
|
+
* ```ts
|
|
291
|
+
* canonicalSource("old.reddit.com"); // "reddit.com"
|
|
292
|
+
* canonicalSource("t.co"); // "x.com"
|
|
293
|
+
* canonicalSource("google.co.uk"); // "google.com"
|
|
294
|
+
* canonicalSource("mail.google.com"); // "mail.google.com"
|
|
295
|
+
* canonicalSource("example.org"); // "example.org"
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
export function canonicalSource(host: string): string {
|
|
299
|
+
const alias = ALIASES.get(host);
|
|
300
|
+
if (alias) return alias;
|
|
301
|
+
for (const [pattern, target] of PATTERNS) {
|
|
302
|
+
if (pattern.test(host)) return target;
|
|
303
|
+
}
|
|
304
|
+
for (let rest = host; ;) {
|
|
305
|
+
const family = FAMILIES.get(rest);
|
|
306
|
+
if (family) return family;
|
|
307
|
+
const dot = rest.indexOf(".");
|
|
308
|
+
if (dot === -1) return host;
|
|
309
|
+
rest = rest.slice(dot + 1);
|
|
310
|
+
}
|
|
311
|
+
}
|
package/src/lib/render.tsx
CHANGED
|
@@ -108,6 +108,15 @@ export interface RenderPublicPageOptions {
|
|
|
108
108
|
composeContextLanguage?: string | null;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Pages whose content sets its own width, wider than the reading column, and
|
|
113
|
+
* so keep the wide frame where reader pages narrow theirs below 1024px.
|
|
114
|
+
*/
|
|
115
|
+
const WIDE_FRAME_PAGES: ReadonlySet<PageName> = new Set([
|
|
116
|
+
"settings",
|
|
117
|
+
"compose",
|
|
118
|
+
]);
|
|
119
|
+
|
|
111
120
|
/**
|
|
112
121
|
* Render a public page with the standard layout stack.
|
|
113
122
|
*
|
|
@@ -178,6 +187,7 @@ export function renderPublicPage(c: Context, options: RenderPublicPageOptions) {
|
|
|
178
187
|
siteFooterHtml: navData.siteFooterHtml,
|
|
179
188
|
showHomeBranding,
|
|
180
189
|
sidebar,
|
|
190
|
+
wideFrame: WIDE_FRAME_PAGES.has(page),
|
|
181
191
|
uploadMaxFileSize: appConfig.uploadMaxFileSize,
|
|
182
192
|
showComposeDialog,
|
|
183
193
|
showHeader,
|
|
@@ -424,6 +424,20 @@ export function resolveConfig(
|
|
|
424
424
|
siteAvatarThumbUrl,
|
|
425
425
|
faviconVersion: allSettings["SITE_FAVICON_VERSION"] ?? "",
|
|
426
426
|
|
|
427
|
+
// View stats. The daily limit exists for one runtime: free-tier D1 allows
|
|
428
|
+
// 100,000 rows written per UTC day and refuses every query, reads too,
|
|
429
|
+
// once that is spent — so a well-read day must never be able to take the
|
|
430
|
+
// site down with it. SQLite and Postgres on Node have no such quota, and
|
|
431
|
+
// an unset variable there means no limit rather than the Cloudflare one.
|
|
432
|
+
stats: {
|
|
433
|
+
enabled: resolve("STATS_ENABLED", allSettings, env) === "true",
|
|
434
|
+
dailyLimit:
|
|
435
|
+
readEnvInteger(env, "STATS_DAILY_LIMIT") ??
|
|
436
|
+
(env.NODE_DATABASE || env.NODE_SQLITE
|
|
437
|
+
? 0
|
|
438
|
+
: Number(CONFIG_FIELDS.STATS_DAILY_LIMIT.defaultValue)),
|
|
439
|
+
},
|
|
440
|
+
|
|
427
441
|
// Rate limiting (ENV only). Defaults are conservative enough for a
|
|
428
442
|
// human typing in the search UI but reject bot floods.
|
|
429
443
|
rateLimit: {
|
package/src/lib/share-card.ts
CHANGED
|
@@ -21,6 +21,7 @@ import type { Context } from "hono";
|
|
|
21
21
|
import { renderSVG } from "uqr";
|
|
22
22
|
import type { Bindings, Media, Post, PostView } from "../types.js";
|
|
23
23
|
import type { AppVariables } from "../types/app-context.js";
|
|
24
|
+
import { isOpenableByReader } from "../types/constants.js";
|
|
24
25
|
import { buildMediaMap } from "./media-helpers.js";
|
|
25
26
|
import {
|
|
26
27
|
ARTICLE_SUMMARY_MAX_BLOCKS,
|
|
@@ -208,18 +209,18 @@ export interface ShareCardSite {
|
|
|
208
209
|
* the address its QR code points at.
|
|
209
210
|
*
|
|
210
211
|
* @param post - Post record
|
|
211
|
-
* @returns True for published posts
|
|
212
|
+
* @returns True for published posts a reader can open: everything but Private
|
|
212
213
|
*
|
|
213
214
|
* @example
|
|
214
215
|
* ```ts
|
|
215
|
-
* canShareAsImage({ status: "published", visibility: "
|
|
216
|
+
* canShareAsImage({ status: "published", visibility: "unlisted" }); // true
|
|
216
217
|
* canShareAsImage({ status: "draft", visibility: "public" }); // false
|
|
217
218
|
* ```
|
|
218
219
|
*/
|
|
219
220
|
export function canShareAsImage(
|
|
220
221
|
post: Pick<Post, "status" | "visibility">,
|
|
221
222
|
): boolean {
|
|
222
|
-
return post.status === "published" && post.visibility
|
|
223
|
+
return post.status === "published" && isOpenableByReader(post.visibility);
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
/**
|