element-plus/docs/.vitepress/config/head.ts

74 lines
1.6 KiB
TypeScript
Raw Normal View History

import fs from 'fs'
import path from 'path'
import { vpRoot } from '@element-plus/build'
import { languages } from '../utils/lang'
import { features } from './features'
import type { HeadConfig } from 'vitepress'
export const head: HeadConfig[] = [
[
'link',
{
rel: 'icon',
href: '/images/element-plus-logo-small.svg',
},
],
[
'link',
{
rel: 'stylesheet',
href: '//fonts.loli.net/css?family=Inter:300,400,500,600|Open+Sans:400,600;display=swap',
},
],
[
'link',
{
rel: 'stylesheet',
href: '//unpkg.com/nprogress@0.2.0/nprogress.css',
},
],
[
'script',
{},
`;(() => {
window.supportedLangs = ${JSON.stringify(languages)}
})()`,
],
['script', {}, fs.readFileSync(path.resolve(vpRoot, 'lang.js'), 'utf-8')],
[
'script',
{
async: 'true',
src: 'https://www.googletagmanager.com/gtag/js?id=UA-175337989-1',
},
],
[
'script',
{},
`window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-175337989-1');`,
],
2022-03-26 14:03:16 +08:00
[
'script',
{},
`(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:2894908,hjsv:6};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');`,
],
]
if (features.theme) {
head.push([
'script',
{},
fs.readFileSync(path.resolve(vpRoot, 'dark-mode.js'), 'utf-8'),
])
}