支持公安备案号配置

This commit is contained in:
tangly1024.com
2024-10-29 14:49:17 +08:00
parent 0ac8b7afc4
commit 3f31a27823
15 changed files with 369 additions and 135 deletions

30
components/GongAnBeiAn.js Normal file
View File

@@ -0,0 +1,30 @@
import { siteConfig } from '@/lib/config'
import LazyImage from './LazyImage'
/**
* 公安备案号组件
* @returns
*/
export const GongAnBeiAn = () => {
const BEI_AN_GONGAN = siteConfig(
'BEI_AN_GONGAN',
'京公网安备 11010102000001号'
)
// 从BEI_AN_GONGAN 字段中利用正则匹配提取出纯数字部分
const codeMatch = BEI_AN_GONGAN.match(/\d+/) // 匹配纯数字
const code = codeMatch ? codeMatch[0] : null // 如果匹配成功则取出数字部分
const href = `https://beian.mps.gov.cn/#/query/webSearch?code=${code}` // 动态生成链接
if (!BEI_AN_GONGAN) {
return null
}
return (
<div className='flex flex-nowrap items-center gap-1'>
<LazyImage src='/images/gongan.png' width={15} height={15} />
<a href={href} target='_blank' rel='noopener noreferrer'>
{BEI_AN_GONGAN}
</a>
</div>
)
}