feat: support custom footer, close #136
This commit is contained in:
@@ -29,6 +29,7 @@ export default function SiteSettingsGeneralPage() {
|
||||
name: "",
|
||||
site_name: "",
|
||||
description: "",
|
||||
footer: "",
|
||||
ga: "",
|
||||
ua: "",
|
||||
uh: "",
|
||||
@@ -41,6 +42,7 @@ export default function SiteSettingsGeneralPage() {
|
||||
name: string
|
||||
site_name: string
|
||||
description: string
|
||||
footer: string
|
||||
ga: string
|
||||
ua: string
|
||||
uh: string
|
||||
@@ -55,6 +57,7 @@ export default function SiteSettingsGeneralPage() {
|
||||
name: values.name,
|
||||
site_name: values.site_name,
|
||||
description: values.description,
|
||||
footer: values.footer,
|
||||
ga: values.ga,
|
||||
ua: values.ua,
|
||||
uh: values.uh,
|
||||
@@ -94,6 +97,8 @@ export default function SiteSettingsGeneralPage() {
|
||||
form.setValue("site_name", site.data.metadata?.content?.site_name || "")
|
||||
!form.getValues("description") &&
|
||||
form.setValue("description", site.data.metadata?.content?.bio || "")
|
||||
!form.getValues("footer") &&
|
||||
form.setValue("footer", site.data.metadata?.content?.footer || "")
|
||||
!form.getValues("ga") &&
|
||||
form.setValue("ga", site.data.metadata?.content?.ga || "")
|
||||
!form.getValues("ua") &&
|
||||
@@ -191,6 +196,19 @@ export default function SiteSettingsGeneralPage() {
|
||||
{...form.register("description")}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-5">
|
||||
<label htmlFor="footer" className="form-label">
|
||||
{t("Footer")}
|
||||
</label>
|
||||
<Input
|
||||
multiline
|
||||
id="footer"
|
||||
className="input is-block"
|
||||
rows={2}
|
||||
{...form.register("footer")}
|
||||
help={t("Support Markdown")}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-5">
|
||||
<Input
|
||||
id="ga"
|
||||
|
||||
@@ -4,6 +4,7 @@ import Script from "next/script"
|
||||
import { Logo } from "~/components/common/Logo"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
import { renderPageContent } from "~/markdown"
|
||||
|
||||
import { DarkModeSwitch } from "../common/DarkModeSwitch"
|
||||
import { LanguageSwitch } from "../common/LanguageSwitch"
|
||||
@@ -32,24 +33,34 @@ export default async function SiteFooter({
|
||||
return (
|
||||
<>
|
||||
<footer className="text-zinc-500 border-t">
|
||||
<div className="max-w-screen-lg mx-auto px-5 py-10 text-xs sm:flex justify-between sm:space-x-5 sm:space-y-0 space-y-5 sm:items-center">
|
||||
<div className="font-medium text-base">
|
||||
<span>© </span>
|
||||
<UniLink href="/" className="hover:text-accent">
|
||||
<span>{site?.metadata?.content?.name}</span>
|
||||
</UniLink>
|
||||
<span> · </span>
|
||||
{t.rich("powered by", {
|
||||
name: () => <LogoWithLink />,
|
||||
span: (chunks) => <span>{chunks}</span>,
|
||||
})}
|
||||
</div>
|
||||
<ConnectedAccounts
|
||||
connectedAccounts={site?.metadata?.content?.connected_accounts}
|
||||
/>
|
||||
<div className="flex gap-x-2 items-center">
|
||||
<LanguageSwitch />
|
||||
<DarkModeSwitch />
|
||||
<div className="max-w-screen-lg mx-auto px-5 py-10">
|
||||
{site?.metadata?.content?.footer && (
|
||||
<div className="xlog-post-content prose text-sm">
|
||||
{
|
||||
renderPageContent(site.metadata.content.footer, false, true)
|
||||
?.element
|
||||
}
|
||||
</div>
|
||||
)}
|
||||
<div className="text-xs sm:flex justify-between sm:space-x-5 sm:space-y-0 space-y-5 sm:items-center">
|
||||
<div className="font-medium text-base">
|
||||
<span>© </span>
|
||||
<UniLink href="/" className="hover:text-accent">
|
||||
<span>{site?.metadata?.content?.name}</span>
|
||||
</UniLink>
|
||||
<span> · </span>
|
||||
{t.rich("powered by", {
|
||||
name: () => <LogoWithLink />,
|
||||
span: (chunks) => <span>{chunks}</span>,
|
||||
})}
|
||||
</div>
|
||||
<ConnectedAccounts
|
||||
connectedAccounts={site?.metadata?.content?.connected_accounts}
|
||||
/>
|
||||
<div className="flex gap-x-2 items-center">
|
||||
<LanguageSwitch />
|
||||
<DarkModeSwitch />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
+15
-24
@@ -262,30 +262,21 @@ export const expandCrossbellCharacter = async (site: CharacterEntity) => {
|
||||
(a: any) => a.trait_type === "xlog_navigation",
|
||||
)?.value as string) || "null",
|
||||
) || [{ id: nanoid(), label: "Archives", url: "/archives" }]
|
||||
expandedCharacter.metadata.content.css =
|
||||
expandedCharacter.metadata?.content?.attributes?.find(
|
||||
(a: any) => a.trait_type === "xlog_css",
|
||||
)?.value as string
|
||||
expandedCharacter.metadata.content.ga =
|
||||
(expandedCharacter.metadata?.content?.attributes?.find(
|
||||
(a: any) => a.trait_type === "xlog_ga",
|
||||
)?.value as string) || ""
|
||||
expandedCharacter.metadata.content.ua =
|
||||
(expandedCharacter.metadata?.content?.attributes?.find(
|
||||
(a: any) => a.trait_type === "xlog_ua",
|
||||
)?.value as string) || ""
|
||||
expandedCharacter.metadata.content.uh =
|
||||
(expandedCharacter.metadata?.content?.attributes?.find(
|
||||
(a: any) => a.trait_type === "xlog_uh",
|
||||
)?.value as string) || ""
|
||||
expandedCharacter.metadata.content.custom_domain =
|
||||
(expandedCharacter.metadata?.content?.attributes?.find(
|
||||
(a: any) => a.trait_type === "xlog_custom_domain",
|
||||
)?.value as string) || ""
|
||||
expandedCharacter.metadata.content.site_name =
|
||||
(expandedCharacter.metadata?.content?.attributes?.find(
|
||||
(a: any) => a.trait_type === "xlog_site_name",
|
||||
)?.value as string) || ""
|
||||
|
||||
const getArribute = (outputKey: string, typeKey: string) => {
|
||||
;(expandedCharacter.metadata.content as any)[outputKey] =
|
||||
expandedCharacter.metadata?.content?.attributes?.find(
|
||||
(a: any) => a.trait_type === `xlog_${typeKey}`,
|
||||
)?.value as string
|
||||
}
|
||||
getArribute("css", "css")
|
||||
getArribute("ga", "ga")
|
||||
getArribute("ua", "ua")
|
||||
getArribute("uh", "uh")
|
||||
getArribute("custom_domain", "custom_domain")
|
||||
getArribute("site_name", "site_name")
|
||||
getArribute("footer", "footer")
|
||||
|
||||
expandedCharacter.metadata.content.name =
|
||||
expandedCharacter.metadata.content.name || expandedCharacter.handle
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ export type ExpandedNote = NoteEntity & {
|
||||
export type ExpandedCharacter = CharacterEntity & {
|
||||
metadata: {
|
||||
content: {
|
||||
footer?: string
|
||||
navigation?: SiteNavigationItem[]
|
||||
css?: string
|
||||
ga?: string
|
||||
|
||||
@@ -429,5 +429,7 @@
|
||||
"en": "英语",
|
||||
"ja": "日语",
|
||||
"zh": "中文",
|
||||
"zh-TW": "繁体中文"
|
||||
"zh-TW": "繁体中文",
|
||||
"Footer": "页脚",
|
||||
"Support Markdown": "支持 Markdown"
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ export function useUpdateSite() {
|
||||
name?: string
|
||||
site_name?: string
|
||||
description?: string
|
||||
footer?: string
|
||||
icon?: string
|
||||
navigation?: SiteNavigationItem[]
|
||||
css?: string
|
||||
@@ -221,6 +222,7 @@ export function useUpdateSite() {
|
||||
setAttribute("uh", "uh")
|
||||
setAttribute("custom_domain", "custom_domain")
|
||||
setAttribute("site_name", "site_name")
|
||||
setAttribute("footer", "footer")
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user