forked from notionnext-org/NotionNext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeiAnGongAn.js
More file actions
27 lines (24 loc) · 841 Bytes
/
Copy pathBeiAnGongAn.js
File metadata and controls
27 lines (24 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { siteConfig } from '@/lib/config'
import LazyImage from './LazyImage'
/**
* 公安备案号组件
* @returns
*/
export const BeiAnGongAn = props => {
const BEI_AN_GONGAN = siteConfig('BEI_AN_GONGAN')
// 从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={`${props.className}`}>
<LazyImage src='/images/gongan.png' width={15} height={15} />
<a href={href} target='_blank' rel='noopener noreferrer' className='ml-1'>
{BEI_AN_GONGAN}
</a>
</div>
)
}