@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
package/src/lib/feed-policy.ts
CHANGED
|
@@ -258,7 +258,7 @@ export function latestFeedSelection(input: {
|
|
|
258
258
|
status: "published",
|
|
259
259
|
excludeReplies: true,
|
|
260
260
|
excludeLatestHidden: true,
|
|
261
|
-
|
|
261
|
+
listedForReader: true,
|
|
262
262
|
lang: input.lang,
|
|
263
263
|
publishedBefore: input.publishedBefore,
|
|
264
264
|
} satisfies PostFilters;
|
|
@@ -284,7 +284,7 @@ export function featuredFeedSelection(input: {
|
|
|
284
284
|
}) {
|
|
285
285
|
return {
|
|
286
286
|
status: "published",
|
|
287
|
-
|
|
287
|
+
listedForReader: true,
|
|
288
288
|
lang: input.lang,
|
|
289
289
|
publishedBefore: input.publishedBefore,
|
|
290
290
|
} satisfies ThreadRootPageOptions;
|
|
@@ -883,6 +883,7 @@ const VISIBILITY_URL_SPELLING = {
|
|
|
883
883
|
public: "public",
|
|
884
884
|
featured: "featured",
|
|
885
885
|
latest_hidden: "hidden",
|
|
886
|
+
unlisted: "unlisted",
|
|
886
887
|
private: "private",
|
|
887
888
|
} as const satisfies Record<ArchiveVisibility, string>;
|
|
888
889
|
|
|
@@ -923,6 +924,11 @@ const VISIBILITY_LABELS: Record<ArchiveVisibility, MessageDescriptor> = {
|
|
|
923
924
|
message: "Hidden from Latest",
|
|
924
925
|
comment: "@context: Archive visibility filter for posts hidden from Latest",
|
|
925
926
|
}),
|
|
927
|
+
unlisted: msg({
|
|
928
|
+
message: "Unlisted",
|
|
929
|
+
comment:
|
|
930
|
+
"@context: Archive visibility filter - posts that open for anyone with the link but are listed nowhere",
|
|
931
|
+
}),
|
|
926
932
|
private: msg({
|
|
927
933
|
message: "Private",
|
|
928
934
|
comment: "@context: Archive visibility filter - private posts",
|
|
@@ -964,9 +970,10 @@ const VISIBILITY_DIMENSION: Dimension<"visibility"> = {
|
|
|
964
970
|
storage: {
|
|
965
971
|
column: "visibility",
|
|
966
972
|
// Narrower than the URL vocabulary on purpose: a smart collection is a
|
|
967
|
-
// published page, so it can never name
|
|
968
|
-
// `private`
|
|
969
|
-
// the "turn this link into a smart collection" flow
|
|
973
|
+
// published page, so it can never name a set only its author can list.
|
|
974
|
+
// `unlisted` and `private` parse here and fail validation, which is
|
|
975
|
+
// exactly what lets the "turn this link into a smart collection" flow
|
|
976
|
+
// refuse them by name.
|
|
970
977
|
isStorable(value): value is ArchiveVisibility {
|
|
971
978
|
return (
|
|
972
979
|
typeof value === "string" &&
|
|
@@ -991,7 +998,7 @@ const VISIBILITY_DIMENSION: Dimension<"visibility"> = {
|
|
|
991
998
|
},
|
|
992
999
|
toPostFilter(value) {
|
|
993
1000
|
// `featured` is a virtual visibility — a separate flag rather than a stored
|
|
994
|
-
// value — so it lands in a different field than the
|
|
1001
|
+
// value — so it lands in a different field than the stored ones.
|
|
995
1002
|
return value === "featured" ? { featured: true } : { visibility: value };
|
|
996
1003
|
},
|
|
997
1004
|
describe(value, i18n) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Signed state for the GitHub App install flow.
|
|
3
3
|
*
|
|
4
4
|
* When Jant Core runs behind a hosted control plane (multi-host / multi-site),
|
|
5
|
-
* the GitHub App's
|
|
5
|
+
* the GitHub App's Setup URL and redirect URI must point at one fixed URL — typically the
|
|
6
6
|
* control plane, which then dispatches the browser back to the correct site.
|
|
7
7
|
*
|
|
8
8
|
* The `state` query parameter that rides through that round-trip must tell
|
package/src/lib/github-app.ts
CHANGED
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
* way a PAT is — the downstream client is auth-agnostic.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import type { GitHubAppEnvConfig } from "./env.js";
|
|
16
|
+
import type { GitHubAppEnvConfig, GitHubAppOAuthConfig } from "./env.js";
|
|
17
17
|
|
|
18
18
|
const GITHUB_API = "https://api.github.com";
|
|
19
|
+
const GITHUB_OAUTH = "https://github.com/login/oauth";
|
|
19
20
|
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
21
22
|
// Installation token cache
|
|
@@ -485,3 +486,184 @@ export async function searchInstallationRepos(
|
|
|
485
486
|
totalCount: data.total_count,
|
|
486
487
|
};
|
|
487
488
|
}
|
|
489
|
+
|
|
490
|
+
// ---------------------------------------------------------------------------
|
|
491
|
+
// Who owns an installation (OAuth web flow)
|
|
492
|
+
// ---------------------------------------------------------------------------
|
|
493
|
+
//
|
|
494
|
+
// An installation id is not a secret and proves nothing: GitHub's Setup URL
|
|
495
|
+
// hands it over as a query parameter, so anyone can type another account's
|
|
496
|
+
// id into that URL. The only thing that ties an installation to the person
|
|
497
|
+
// in the browser is GitHub's answer to "which installations can this user
|
|
498
|
+
// reach", which takes a user access token — hence the web flow below.
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Create a PKCE verifier and its S256 challenge for one authorization.
|
|
502
|
+
*
|
|
503
|
+
* @returns The verifier to keep until the callback, and the challenge to
|
|
504
|
+
* send to GitHub.
|
|
505
|
+
* @example
|
|
506
|
+
* const { verifier, challenge } = await createPkcePair();
|
|
507
|
+
*/
|
|
508
|
+
export async function createPkcePair(): Promise<{
|
|
509
|
+
verifier: string;
|
|
510
|
+
challenge: string;
|
|
511
|
+
}> {
|
|
512
|
+
const bytes = new Uint8Array(32);
|
|
513
|
+
crypto.getRandomValues(bytes);
|
|
514
|
+
const verifier = base64UrlEncode(bytes);
|
|
515
|
+
const digest = await crypto.subtle.digest(
|
|
516
|
+
"SHA-256",
|
|
517
|
+
new TextEncoder().encode(verifier),
|
|
518
|
+
);
|
|
519
|
+
return { verifier, challenge: base64UrlEncode(digest) };
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Build the URL that asks GitHub to sign the author in for this App.
|
|
524
|
+
*
|
|
525
|
+
* No `redirect_uri`: GitHub then uses the first redirect URI in the App's
|
|
526
|
+
* settings, which on a hosted deployment is the control plane's dispatcher
|
|
527
|
+
* — the one URL that can route the browser back to any site.
|
|
528
|
+
*
|
|
529
|
+
* @param clientId - The App's OAuth client ID (not its App ID).
|
|
530
|
+
* @param state - CSRF token, also kept in a cookie for the callback.
|
|
531
|
+
* @param codeChallenge - PKCE challenge from `createPkcePair`.
|
|
532
|
+
* @returns The authorize URL.
|
|
533
|
+
* @example
|
|
534
|
+
* buildAuthorizeUrl("Iv1.abc", state, challenge);
|
|
535
|
+
* // "https://github.com/login/oauth/authorize?client_id=Iv1.abc&state=…"
|
|
536
|
+
*/
|
|
537
|
+
export function buildAuthorizeUrl(
|
|
538
|
+
clientId: string,
|
|
539
|
+
state: string,
|
|
540
|
+
codeChallenge: string,
|
|
541
|
+
): string {
|
|
542
|
+
const params = new URLSearchParams({
|
|
543
|
+
client_id: clientId,
|
|
544
|
+
state,
|
|
545
|
+
code_challenge: codeChallenge,
|
|
546
|
+
code_challenge_method: "S256",
|
|
547
|
+
});
|
|
548
|
+
return `${GITHUB_OAUTH}/authorize?${params.toString()}`;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/** An installation of this App that the signed-in GitHub user owns. */
|
|
552
|
+
export interface OwnedInstallation {
|
|
553
|
+
installationId: string;
|
|
554
|
+
account: InstallationAccount;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Exchange the code from GitHub's callback for a user access token, and list
|
|
559
|
+
* the installations of this App that user owns.
|
|
560
|
+
*
|
|
561
|
+
* "Owns" is narrower than what `GET /user/installations` returns. GitHub
|
|
562
|
+
* lists a personal account's installation for every collaborator on one of
|
|
563
|
+
* its repositories, and binding it would hand that collaborator every
|
|
564
|
+
* repository the installation covers — so a personal installation counts
|
|
565
|
+
* only for the account itself. An organization's installation counts for
|
|
566
|
+
* the members GitHub lists it for, which is the access GitHub itself gives
|
|
567
|
+
* them. Enterprise installations carry no login and are left out.
|
|
568
|
+
*
|
|
569
|
+
* The token is used for these two reads and then dropped; nothing stores it.
|
|
570
|
+
*
|
|
571
|
+
* @param oauth - The App's client credentials.
|
|
572
|
+
* @param code - The `code` query parameter from the callback.
|
|
573
|
+
* @param codeVerifier - The PKCE verifier kept since the authorize redirect.
|
|
574
|
+
* @returns The owned installations, possibly none.
|
|
575
|
+
* @example
|
|
576
|
+
* const owned = await listOwnedInstallations(app.oauth, code, verifier);
|
|
577
|
+
*/
|
|
578
|
+
export async function listOwnedInstallations(
|
|
579
|
+
oauth: GitHubAppOAuthConfig,
|
|
580
|
+
code: string,
|
|
581
|
+
codeVerifier: string,
|
|
582
|
+
): Promise<OwnedInstallation[]> {
|
|
583
|
+
const token = await exchangeUserCode(oauth, code, codeVerifier);
|
|
584
|
+
const user = (await fetchUserJson(token, "/user")) as { id: number };
|
|
585
|
+
|
|
586
|
+
const owned: OwnedInstallation[] = [];
|
|
587
|
+
for (let page = 1; ; page++) {
|
|
588
|
+
const data = (await fetchUserJson(
|
|
589
|
+
token,
|
|
590
|
+
`/user/installations?per_page=100&page=${page}`,
|
|
591
|
+
)) as {
|
|
592
|
+
installations: Array<{
|
|
593
|
+
id: number;
|
|
594
|
+
account: {
|
|
595
|
+
id?: number;
|
|
596
|
+
login?: string;
|
|
597
|
+
type?: string;
|
|
598
|
+
avatar_url?: string;
|
|
599
|
+
} | null;
|
|
600
|
+
}>;
|
|
601
|
+
};
|
|
602
|
+
for (const installation of data.installations) {
|
|
603
|
+
const account = installation.account;
|
|
604
|
+
if (!account?.login) continue;
|
|
605
|
+
const isOwner =
|
|
606
|
+
account.type === "Organization" ||
|
|
607
|
+
(account.type === "User" && account.id === user.id);
|
|
608
|
+
if (!isOwner) continue;
|
|
609
|
+
owned.push({
|
|
610
|
+
installationId: String(installation.id),
|
|
611
|
+
account: {
|
|
612
|
+
login: account.login,
|
|
613
|
+
type: account.type === "Organization" ? "Organization" : "User",
|
|
614
|
+
avatarUrl: account.avatar_url ?? "",
|
|
615
|
+
},
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
if (data.installations.length < 100) break;
|
|
619
|
+
}
|
|
620
|
+
return owned;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
async function exchangeUserCode(
|
|
624
|
+
oauth: GitHubAppOAuthConfig,
|
|
625
|
+
code: string,
|
|
626
|
+
codeVerifier: string,
|
|
627
|
+
): Promise<string> {
|
|
628
|
+
const res = await fetch(`${GITHUB_OAUTH}/access_token`, {
|
|
629
|
+
method: "POST",
|
|
630
|
+
headers: {
|
|
631
|
+
Accept: "application/json",
|
|
632
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
633
|
+
"User-Agent": "jant-github-sync",
|
|
634
|
+
},
|
|
635
|
+
body: new URLSearchParams({
|
|
636
|
+
client_id: oauth.clientId,
|
|
637
|
+
client_secret: oauth.clientSecret,
|
|
638
|
+
code,
|
|
639
|
+
code_verifier: codeVerifier,
|
|
640
|
+
}).toString(),
|
|
641
|
+
});
|
|
642
|
+
// GitHub answers a bad or expired code with 200 and an `error` field.
|
|
643
|
+
const data = (await res.json().catch(() => ({}))) as {
|
|
644
|
+
access_token?: string;
|
|
645
|
+
error?: string;
|
|
646
|
+
};
|
|
647
|
+
if (!res.ok || !data.access_token) {
|
|
648
|
+
throw new Error(
|
|
649
|
+
`GitHub OAuth code exchange failed (${res.status}): ${data.error ?? "no access token"}`,
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
return data.access_token;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
async function fetchUserJson(token: string, path: string): Promise<unknown> {
|
|
656
|
+
const res = await fetch(`${GITHUB_API}${path}`, {
|
|
657
|
+
headers: {
|
|
658
|
+
Accept: "application/vnd.github+json",
|
|
659
|
+
Authorization: `Bearer ${token}`,
|
|
660
|
+
"User-Agent": "jant-github-sync",
|
|
661
|
+
"X-GitHub-Api-Version": "2022-11-28",
|
|
662
|
+
},
|
|
663
|
+
});
|
|
664
|
+
if (!res.ok) {
|
|
665
|
+
const body = await res.text();
|
|
666
|
+
throw new Error(`GitHub ${path} failed (${res.status}): ${body}`);
|
|
667
|
+
}
|
|
668
|
+
return res.json();
|
|
669
|
+
}
|
package/src/lib/hugo-markdown.ts
CHANGED
|
@@ -128,6 +128,12 @@ export interface HugoFrontMatter {
|
|
|
128
128
|
*/
|
|
129
129
|
feed_id?: string;
|
|
130
130
|
build?: HugoBuildOptions;
|
|
131
|
+
/**
|
|
132
|
+
* Unlisted roots only: keep the page out of Hugo's sitemap. `build.list:
|
|
133
|
+
* never` already keeps it out of every page collection; this says so to the
|
|
134
|
+
* sitemap template by name.
|
|
135
|
+
*/
|
|
136
|
+
sitemap?: { disable?: boolean };
|
|
131
137
|
/**
|
|
132
138
|
* Reply bundles only: 1-based position in the Thread. Jant orders a Thread
|
|
133
139
|
* by creation time, then ID; replies written in the same second tie on
|
|
@@ -259,6 +265,7 @@ const FRONT_MATTER_KEY_ORDER: readonly string[] = [
|
|
|
259
265
|
"aliases",
|
|
260
266
|
"feed_id",
|
|
261
267
|
"build",
|
|
268
|
+
"sitemap",
|
|
262
269
|
|
|
263
270
|
// Post payload
|
|
264
271
|
"format",
|
package/src/lib/icons.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
History as HistoryIcon,
|
|
26
26
|
Image as ImageIcon,
|
|
27
27
|
LayoutGrid,
|
|
28
|
+
Link as LinkIcon,
|
|
28
29
|
List,
|
|
29
30
|
ListTree,
|
|
30
31
|
Lock as LockIcon,
|
|
@@ -62,6 +63,7 @@ const LUCIDE_ICONS = {
|
|
|
62
63
|
history: HistoryIcon,
|
|
63
64
|
image: ImageIcon,
|
|
64
65
|
"layout-grid": LayoutGrid,
|
|
66
|
+
link: LinkIcon,
|
|
65
67
|
list: List,
|
|
66
68
|
"list-tree": ListTree,
|
|
67
69
|
lock: LockIcon,
|