Render policy markdown and normalize filing links
This commit is contained in:
@@ -11,10 +11,35 @@ const footerLinks = [
|
||||
{ href: '/help', label: '帮助中心' },
|
||||
];
|
||||
|
||||
function normalizeExternalHref(value: string): string {
|
||||
const href = value.trim();
|
||||
if (!href) return '';
|
||||
if (/^https?:\/\//i.test(href)) return href;
|
||||
return `https://${href}`;
|
||||
}
|
||||
|
||||
function resolveFilingHref(filingInfo: string, configuredUrl: string): string {
|
||||
if (!filingInfo.trim()) return '';
|
||||
return normalizeExternalHref(configuredUrl) || 'https://beian.miit.gov.cn/';
|
||||
}
|
||||
|
||||
function resolvePublicSecurityFilingHref(filingInfo: string, configuredUrl: string): string {
|
||||
if (!filingInfo.trim()) return '';
|
||||
const normalized = normalizeExternalHref(configuredUrl);
|
||||
if (normalized) return normalized;
|
||||
const code = filingInfo.match(/\d{13,}/)?.[0];
|
||||
return code
|
||||
? `https://beian.mps.gov.cn/#/query/webSearch?code=${code}`
|
||||
: 'https://beian.mps.gov.cn/#/query/webSearch';
|
||||
}
|
||||
|
||||
export function SiteFooter() {
|
||||
const { config } = useSiteConfig();
|
||||
const filingHref = config.filingUrl.trim();
|
||||
const publicSecurityFilingHref = config.publicSecurityFilingUrl.trim();
|
||||
const filingHref = resolveFilingHref(config.filingInfo, config.filingUrl);
|
||||
const publicSecurityFilingHref = resolvePublicSecurityFilingHref(
|
||||
config.publicSecurityFilingInfo,
|
||||
config.publicSecurityFilingUrl,
|
||||
);
|
||||
|
||||
return (
|
||||
<footer className="border-t border-border/50 py-12">
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SiteLogo, SiteName } from '@/components/site-brand';
|
||||
import { useSiteConfig } from '@/lib/site-config';
|
||||
@@ -34,8 +36,10 @@ export function SitePolicyPage({ kind }: { kind: PolicyPageKind }) {
|
||||
|
||||
<article className="flex-1">
|
||||
<h1 className="font-serif text-3xl font-bold tracking-tight sm:text-4xl">{meta.title}</h1>
|
||||
<div className="mt-8 whitespace-pre-wrap break-words rounded-lg border border-border bg-card p-5 text-sm leading-8 text-muted-foreground sm:p-7">
|
||||
{content}
|
||||
<div className="announcement-markdown mt-8 break-words rounded-lg border border-border bg-card p-5 text-sm leading-8 text-muted-foreground sm:p-7">
|
||||
<ReactMarkdown remarkPlugins={[remarkGfm]}>
|
||||
{content}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user