mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 23:16:49 +00:00
29 lines
779 B
JavaScript
29 lines
779 B
JavaScript
import BLOG from '@/blog.config'
|
|
import { loadExternalResource } from '@/lib/utils'
|
|
import React from 'react'
|
|
|
|
/**
|
|
* 自定义引入外部JS 和 CSS
|
|
* @returns
|
|
*/
|
|
const ExternalScript = () => {
|
|
React.useEffect(() => {
|
|
if (BLOG.CUSTOM_EXTERNAL_JS && BLOG.CUSTOM_EXTERNAL_JS.length > 0) {
|
|
for (const url of BLOG.CUSTOM_EXTERNAL_JS) {
|
|
loadExternalResource(url, 'js')
|
|
}
|
|
}
|
|
if (BLOG.CUSTOM_EXTERNAL_CSS && BLOG.CUSTOM_EXTERNAL_CSS.length > 0) {
|
|
for (const url of BLOG.CUSTOM_EXTERNAL_CSS) {
|
|
loadExternalResource(url, 'css')
|
|
}
|
|
}
|
|
// 静态导入本地自定义样式
|
|
loadExternalResource('/css/custom.css', 'css')
|
|
loadExternalResource('/js/custom.js', 'js')
|
|
}, [])
|
|
return null
|
|
}
|
|
|
|
export default ExternalScript
|