small fixes for wiki

This commit is contained in:
hzrd149 2024-04-18 18:37:14 -05:00
parent 03bec50ad7
commit 74feb01c45
3 changed files with 18 additions and 9 deletions

View File

@ -11,3 +11,8 @@ export function getPageTopic(page: NostrEvent) {
if (!d) throw new Error("Page missing d tag");
return d;
}
export function getPageSummary(page: NostrEvent) {
const summary = page.tags.find((t) => t[0] === "summary")?.[1];
return summary || page.content.split("\n")[0];
}

View File

@ -4,7 +4,7 @@ import { Link as RouterLink } from "react-router-dom";
import HoverLinkOverlay from "../../../components/hover-link-overlay";
import { getSharableEventAddress } from "../../../helpers/nip19";
import { getPageTitle } from "../../../helpers/nostr/wiki";
import { getPageSummary, getPageTitle } from "../../../helpers/nostr/wiki";
import UserLink from "../../../components/user/user-link";
import Timestamp from "../../../components/timestamp";
@ -17,10 +17,10 @@ export default function WikiPageResult({ page }: { page: NostrEvent }) {
</HoverLinkOverlay>
</Heading>
<Text>
by <UserLink pubkey={page.pubkey} /> - <Timestamp timestamp={page.created_at} />
by <UserLink pubkey={page.pubkey} fontWeight="bold " /> - <Timestamp timestamp={page.created_at} />
</Text>
<Text color="GrayText" noOfLines={2}>
{page.content.split("\n")[0]}
{getPageSummary(page)}
</Text>
</LinkBox>
);

View File

@ -42,12 +42,16 @@ function WikiPagePage({ page }: { page: NostrEvent }) {
<MarkdownContent event={page} />
</Box>
<Heading size="lg" mt="4">
Other Versions:
</Heading>
{sorted.slice(0, 6).map((page) => (
<WikiPageResult key={page.id} page={page} />
))}
{sorted.length > 0 && (
<>
<Heading size="lg" mt="4">
Other Versions:
</Heading>
{sorted.slice(0, 6).map((page) => (
<WikiPageResult key={page.id} page={page} />
))}
</>
)}
</VerticalPageLayout>
);
}