From 104ff96844d1c156088bd6f1e6d54d369a8285cf Mon Sep 17 00:00:00 2001 From: enpitsulin Date: Sat, 6 May 2023 06:53:16 +0800 Subject: [PATCH 1/3] fix: support solidity syntax highlight (#489) --- src/markdown/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/markdown/index.ts b/src/markdown/index.ts index 78365b1b..6239e634 100644 --- a/src/markdown/index.ts +++ b/src/markdown/index.ts @@ -6,6 +6,7 @@ import { toast } from "react-hot-toast" import { Element } from "react-scroll" import { refractor } from "refractor" import jsx from "refractor/lang/jsx" +import solidity from "refractor/lang/solidity" import tsx from "refractor/lang/tsx" import rehypeAutolinkHeadings from "rehype-autolink-headings" import rehypeInferDescriptionMeta from "rehype-infer-description-meta" @@ -73,6 +74,7 @@ export type Rendered = { refractor.alias("html", ["svelte", "vue"]) refractor.register(tsx) refractor.register(jsx) +refractor.register(solidity) const rehypePrism = rehypePrismGenerator(refractor) From 54b7ded4add9286050b26928aba05a3bcccc4127 Mon Sep 17 00:00:00 2001 From: birdgg Date: Sat, 6 May 2023 07:03:23 +0800 Subject: [PATCH 2/3] fix: CharacterCard fetch every open (#482) --- src/components/common/CharacterCard.tsx | 25 ++++++------------------ src/queries/site.ts | 26 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/components/common/CharacterCard.tsx b/src/components/common/CharacterCard.tsx index 773247e9..1d3f85bf 100644 --- a/src/components/common/CharacterCard.tsx +++ b/src/components/common/CharacterCard.tsx @@ -1,14 +1,12 @@ import { useTranslation } from "next-i18next" -import { useEffect, useState } from "react" import { FollowingButton } from "~/components/common/FollowingButton" import { FollowingCount } from "~/components/common/FollowingCount" import { Titles } from "~/components/common/Titles" import { Avatar } from "~/components/ui/Avatar" import { useDate } from "~/hooks/useDate" -import type { ExpandedCharacter } from "~/lib/types" import { cn } from "~/lib/utils" -import * as siteModel from "~/models/site.model" +import { useGetCharacterCard } from "~/queries/site" export const CharacterCard: React.FC<{ siteId?: string @@ -27,25 +25,14 @@ export const CharacterCard: React.FC<{ simple, style, }) => { - const [firstOpen, setFirstOpen] = useState("") - const [site, setSite] = useState() const date = useDate() const { t } = useTranslation("common") - useEffect(() => { - if (open && (firstOpen !== (siteId || address) || !site)) { - if (siteId || address) { - setFirstOpen(siteId || address || "") - if (siteId) { - siteModel.getSite(siteId).then((site) => setSite(site)) - } else if (address) { - siteModel.getSiteByAddress(address).then((site) => setSite(site)) - } - } else { - setSite(undefined) - } - } - }, [open, firstOpen, siteId, address, site]) + const { data: site } = useGetCharacterCard({ + siteId, + address, + enabled: open || false, + }) return ( { return siteModel.getGreenfieldId(cid) }) } + +export const useGetCharacterCard = ({ + siteId, + address, + enabled, +}: { + siteId?: string + address?: string + enabled: boolean +}) => { + return useQuery( + ["useGetCharacterCard", { siteId, address }], + async () => { + if (siteId) { + return siteModel.getSite(siteId) + } else if (address) { + return siteModel.getSiteByAddress(address) + } else { + return null + } + }, + { + enabled, + }, + ) +} From 7ec85a002ecc48cb1205f05e369f8b70defe6a3f Mon Sep 17 00:00:00 2001 From: Steve Yu Date: Sat, 6 May 2023 22:01:50 +0800 Subject: [PATCH 3/3] fix: sitemap slug undefined (#493) --- src/pages/_site/[site]/sitemap.xml.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/_site/[site]/sitemap.xml.tsx b/src/pages/_site/[site]/sitemap.xml.tsx index f8a31073..683be892 100644 --- a/src/pages/_site/[site]/sitemap.xml.tsx +++ b/src/pages/_site/[site]/sitemap.xml.tsx @@ -34,7 +34,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { ${pages.list?.map( (page: any) => ` - ${link}/${page.slug || page.id} + ${link}/${page.metadata.content.slug} ${dayjs(page.date_updated).format("YYYY-MM-DD")} `, ).join(`