Skip to content

Commit

Permalink
Updated theme cdn injection. (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Apr 8, 2021
1 parent 4059c41 commit 549e95b
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 53 deletions.
30 changes: 17 additions & 13 deletions data/cn.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
scripts:
- <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
- <script src="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/components/prism-core.min.js" data-manual></script>
- <script src="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/plugins/autoloader/prism-autoloader.js"></script>
- <script src="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/plugins/toolbar/prism-toolbar.js"></script>
- <script src="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
- <script src="https://cdn.bootcdn.net/ajax/libs/gitalk/1.7.0/gitalk.min.js"></script>
- <script src="https://cdn.bootcdn.net/ajax/libs/valine/1.4.14/Valine.min.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/av-min.js"></script>
- <script src="https://cdn.bootcdn.net/ajax/libs/blueimp-md5/2.18.0/js/md5.min.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>
- <script rel="prefetch" async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
- <script rel="preload" src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/components/prism-core.js" data-manual></script>
- <script rel="preload" src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/autoloader/prism-autoloader.js"></script>
- <script rel="preload" src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/toolbar/prism-toolbar.min.js"></script>
- <script rel="preload" src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
- <script rel="preload" src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.18.0/js/md5.min.js"></script>
- <script rel="preload" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>

css:
- <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/themes/prism.min.css"/>
- <link href="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/plugins/toolbar/prism-toolbar.css" rel="stylesheet"/>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism.min.css"/>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/toolbar/prism-toolbar.min.css"/>
- <link rel="stylesheet" href="https://fonts.loli.net/css?family=Rubik" />
- <link href="https://cdn.bootcdn.net/ajax/libs/gitalk/1.7.0/gitalk.min.css" rel="stylesheet"/>

plugins:
gitalk:
- <script rel="preload" src="https://cdnjs.cloudflare.com/ajax/libs/gitalk/1.7.2/gitalk.min.js"></script>
- <link href="https://cdnjs.cloudflare.com/ajax/libs/gitalk/1.7.2/gitalk.min.css" rel="stylesheet"/>
valine:
- <script rel="preload" src="https://cdnjs.cloudflare.com/ajax/libs/valine/1.4.14/Valine.min.js"></script>
- <script rel="preload" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/av-min.js"></script>
30 changes: 17 additions & 13 deletions data/en.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
scripts:
- <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-core.min.js" data-manual></script>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/autoloader/prism-autoloader.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/toolbar/prism-toolbar.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/gitalk/1.7.0/gitalk.min.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/valine/1.4.14/Valine.min.js"></script>
- <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/av-min.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/blueimp-md5/2.18.0/js/md5.min.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/lodash.js/4.17.21/lodash.min.js"></script>
- <script src="//cdn.jsdelivr.net/npm/[email protected]/components/prism-core.min.js" data-manual></script>
- <script src="//cdn.jsdelivr.net/npm/[email protected]/plugins/autoloader/prism-autoloader.js"></script>
- <script src="//cdn.jsdelivr.net/npm/[email protected]/plugins/toolbar/prism-toolbar.js"></script>
- <script src="//cdn.jsdelivr.net/npm/[email protected]/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
- <script src="//cdn.jsdelivr.net/npm/blueimp-md5/2.18.0/js/md5.min.js"></script>
- <script src="//cdn.jsdelivr.net/npm/lodash.js/4.17.21/lodash.min.js"></script>

css:
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism.min.css"/>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/plugins/toolbar/prism-toolbar.css"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rubik"/>
<link href="https://cdn.jsdelivr.net/npm/gitalk/1.7.0/gitalk.min.css" rel="stylesheet"/>
- <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/themes/prism.min.css"/>
- <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/plugins/toolbar/prism-toolbar.css"/>
- <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Rubik"/>

plugins:
gitalk:
- <script src="//cdn.jsdelivr.net/npm/gitalk/1.7.0/gitalk.min.js"></script>
- <link href="//cdn.jsdelivr.net/npm/gitalk/1.7.0/gitalk.min.css" rel="stylesheet"/>
valine:
- <script src="//cdn.jsdelivr.net/npm/valine/1.4.14/Valine.min.js"></script>
- <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/av-min.js"></script>
57 changes: 32 additions & 25 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,53 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<!-- Busuanzi site statistic generator -->
<script
rel="prefetch"
async
src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"
src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"
></script>
<!-- Prismjs -->
<script
src="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/components/prism-core.min.js"
rel="preload"
src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/components/prism-core.js"
data-manual
></script>
<script src="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/plugins/autoloader/prism-autoloader.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/plugins/toolbar/prism-toolbar.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism.min.css"
/>
<script
rel="preload"
src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/autoloader/prism-autoloader.js"
></script>
<script
rel="preload"
src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/toolbar/prism-toolbar.min.js"
></script>
<script
rel="preload"
src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"
></script>
<script
rel="preload"
src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.18.0/js/md5.min.js"
></script>
<script
rel="preload"
src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"
></script>
<link
href="https://cdn.bootcdn.net/ajax/libs/prism/1.23.0/plugins/toolbar/prism-toolbar.css"
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism.min.css"
/>
<!-- Google rubik fonts -->
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Rubik"
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/toolbar/prism-toolbar.min.css"
/>
<!-- Gitalk -->
<link rel="stylesheet" href="https://fonts.loli.net/css?family=Rubik" />
<script
rel="preload"
src="https://cdnjs.cloudflare.com/ajax/libs/gitalk/1.7.2/gitalk.min.js"
></script>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/gitalk/1.7.2/gitalk.min.css"
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css"
/>
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<!-- Valine -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/Valine.min.js"></script>
<!-- Lean Cloud Storage -->
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/av-min.js"></script>
<!-- MD5 -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/src/md5.min.js"></script>
<!-- Lodash -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>
</head>
<body id="body-container">
<noscript>
Expand Down
16 changes: 14 additions & 2 deletions scripts/lib/injector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,25 @@ module.exports = function (hexo) {
)
const locales = yaml.load(rawLocales)

for (script of locales.scripts) {
for (let script of locales.scripts) {
hexo.extend.injector.register('head_end', script)
}

for (cs of locales.css) {
for (let cs of locales.css) {
hexo.extend.injector.register('head_end', cs)
}

if (themeConfig.gitalk.enable) {
for (let cdn of locales.plugins.gitalk) {
hexo.extend.injector.register('head_ned', cdn)
}
}

if (themeConfig.valine.enable) {
for (let cdn of locales.plugins.valine) {
hexo.extend.injector.register('head_ned', cdn)
}
}
}

if (themeConfig.injects) {
Expand Down

0 comments on commit 549e95b

Please sign in to comment.