Update enhanceApp.js

This commit is contained in:
reco_luan 2020-07-07 00:15:36 +08:00 committed by GitHub
parent d480e0158b
commit 8fe0011f9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,17 +1,6 @@
import postMixin from '@theme/mixins/posts'
import localMixin from '@theme/mixins/locales'
function _registerCodeThemeCss (theme = 'tomorrow') {
const link = document.createElement('link')
link.rel = 'stylesheet'
if (theme === '') {
link.href = `http://prismjs.com/themes/prism.css`
} else {
link.href = `http://prismjs.com/themes/prism-${theme}.css`
}
document.head.append(link)
}
export default ({
Vue,
siteData,
@ -23,3 +12,13 @@ export default ({
_registerCodeThemeCss(siteData.themeConfig.codeTheme)
}
}
function _registerCodeThemeCss (theme = 'tomorrow') {
const themeArr = ['tomorrow', 'funky', 'okaidia', 'solarizedlight', 'default']
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = `//prismjs.com/themes/prism${themeArr.indexOf(theme) > -1 ? `-${theme}` : ''}.css`
document.head.append(link)
}