From 2a7a5928987cc881b62ddd24276f66f98e4fd86a Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Wed, 20 May 2026 01:38:41 -0400 Subject: [PATCH] de-duplicate things --- .../[did]/[publication]/PublicationNav.tsx | 8 +- .../[rkey]/DocumentPageRenderer.tsx | 150 ++---------------- .../[rkey]/PublicationPageRenderer.tsx | 113 ++----------- .../[rkey]/collectAndFetchBlockResources.ts | 91 +++++++++++ .../[rkey]/extractBlocksByType.ts | 55 +++++++ app/lish/[did]/[publication]/[rkey]/page.tsx | 27 +--- .../edit/[[...route]]/PublicationPagesNav.tsx | 8 +- app/lish/[did]/[publication]/page.tsx | 29 +--- .../[publication]/sortPublicationPages.ts | 10 ++ .../tryRenderPublicationPage.tsx | 48 ++++++ components/Blocks/EmbedBlock.tsx | 14 +- components/Blocks/PostsListBlock.tsx | 22 +-- components/Blocks/SettingsTriggerButton.tsx | 18 +++ .../Blocks/StandardSitePostBlock/index.tsx | 23 +-- src/utils/addLinkBlock.ts | 32 ++-- 15 files changed, 294 insertions(+), 354 deletions(-) create mode 100644 app/lish/[did]/[publication]/[rkey]/collectAndFetchBlockResources.ts create mode 100644 app/lish/[did]/[publication]/[rkey]/extractBlocksByType.ts create mode 100644 app/lish/[did]/[publication]/sortPublicationPages.ts create mode 100644 app/lish/[did]/[publication]/tryRenderPublicationPage.tsx create mode 100644 components/Blocks/SettingsTriggerButton.tsx diff --git a/app/lish/[did]/[publication]/PublicationNav.tsx b/app/lish/[did]/[publication]/PublicationNav.tsx index ca05d139..1f5a8c1f 100644 --- a/app/lish/[did]/[publication]/PublicationNav.tsx +++ b/app/lish/[did]/[publication]/PublicationNav.tsx @@ -1,4 +1,5 @@ import { SpeedyLink } from "components/SpeedyLink"; +import { sortPublicationPages } from "./sortPublicationPages"; export type PublicationNavPage = { id: number; @@ -13,12 +14,7 @@ export function PublicationNav(props: { }) { if (props.pages.length === 0) return null; - let sortedPages = [...props.pages].sort((a, b) => { - let aHome = a.path === "/" ? 0 : 1; - let bHome = b.path === "/" ? 0 : 1; - if (aHome !== bHome) return aHome - bHome; - return (a.path ?? "").localeCompare(b.path ?? ""); - }); + let sortedPages = sortPublicationPages(props.pages); return (