mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Refactor vendors (#72)
* Compatibility with `@next-theme/plugins` * Update test cases
This commit is contained in:
parent
04da779212
commit
d248a3f9a6
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1,2 +1 @@
|
||||
source/lib/* linguist-vendored
|
||||
test/* linguist-vendored
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@ -8,8 +8,3 @@ node_modules/
|
||||
|
||||
# Ignore optional external libraries
|
||||
source/lib/*
|
||||
|
||||
# Track internal libraries & Ignore unused verdors files
|
||||
!source/lib/font-awesome/
|
||||
!source/lib/anime.min.js
|
||||
!source/lib/animate-css/
|
||||
|
||||
70
_config.yml
70
_config.yml
@ -853,126 +853,86 @@ canvas_ribbon:
|
||||
#! See: https://theme-next.js.org/docs/advanced-settings
|
||||
#! ==============================================================
|
||||
|
||||
# Script Vendors. Set a CDN address for the vendor you want to customize.
|
||||
# CDN URLs from UNPKG and CDNJS are provided in the comments for selection.
|
||||
# If left blank, jsDelivr will be used as the default CDN provider.
|
||||
# It's recommended to use the same version as internal ones to avoid potential problems.
|
||||
# Remember to use the https protocol of CDN files when you enable https on your site.
|
||||
# It's recommended to use the same version as in `_vendors.yml` to avoid potential problems.
|
||||
# Remember to use the https protocol of CDN links when you enable https on your site.
|
||||
vendors:
|
||||
# The CDN provider of NexT internal scripts.
|
||||
# Available values: local, jsdelivr, unpkg
|
||||
internal: local
|
||||
# The default CDN provider of third-party plugins.
|
||||
# Available values: local, jsdelivr, unpkg, cdnjs
|
||||
# Dependencies for `plugins: local`: https://github.com/next-theme/plugins
|
||||
plugins: jsdelivr
|
||||
|
||||
# Internal version: 3.1.0
|
||||
# anime: //cdn.jsdelivr.net/npm/animejs@3.2.0/lib/anime.min.js
|
||||
# anime: //unpkg.com/animejs@3.2.0/lib/anime.min.js
|
||||
# anime: //cdnjs.cloudflare.com/ajax/libs/animejs/3.2.0/anime.min.js
|
||||
# In the following settings, you can specify the CDN link for each plugin.
|
||||
# If left blank, the default CDN provider set by `plugins` option will be used.
|
||||
|
||||
# Anime.js
|
||||
anime:
|
||||
|
||||
# Internal version: 5.13.0
|
||||
# fontawesome: //cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5/css/all.min.css
|
||||
# fontawesome: //unpkg.com/@fortawesome/fontawesome-free@5/css/all.min.css
|
||||
# fontawesome: //cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css
|
||||
# Font Awesome
|
||||
fontawesome:
|
||||
|
||||
# Prism
|
||||
# prism: //unpkg.com/prismjs@1/components/prism-core.min.js
|
||||
# prism_autoloader: //unpkg.com/prismjs@1/plugins/autoloader/prism-autoloader.min.js
|
||||
# prism_line_numbers: //unpkg.com/prismjs@1/plugins/line-numbers/prism-line-numbers.min.js
|
||||
prism:
|
||||
prism_autoloader:
|
||||
prism_line_numbers:
|
||||
|
||||
# MathJax
|
||||
# mathjax: //unpkg.com/mathjax@3/es5/tex-mml-chtml.js
|
||||
# mathjax: //cdnjs.cloudflare.com/ajax/libs/mathjax/3.0.5/es5/tex-mml-chtml.js
|
||||
mathjax:
|
||||
|
||||
# KaTeX
|
||||
# katex: //unpkg.com/katex@0/dist/katex.min.css
|
||||
# katex: //cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css
|
||||
# copy_tex_js: //unpkg.com/katex@0/dist/contrib/copy-tex.min.js
|
||||
# copy_tex_css: //unpkg.com/katex@0/dist/contrib/copy-tex.min.css
|
||||
katex:
|
||||
copy_tex_js:
|
||||
copy_tex_css:
|
||||
|
||||
# Recommended version: 0.4.0
|
||||
# pjax: //cdn.jsdelivr.net/gh/next-theme/pjax@0/pjax.min.js
|
||||
# Pjax
|
||||
pjax:
|
||||
|
||||
# FancyBox
|
||||
# jquery: //unpkg.com/jquery@3/dist/jquery.min.js
|
||||
# fancybox: //unpkg.com/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js
|
||||
# fancybox_css: //unpkg.com/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css
|
||||
jquery:
|
||||
fancybox:
|
||||
fancybox_css:
|
||||
|
||||
# Medium-zoom
|
||||
# mediumzoom: //unpkg.com/medium-zoom@1/dist/medium-zoom.min.js
|
||||
# mediumzoom: //cdnjs.cloudflare.com/ajax/libs/medium-zoom/1.0.5/medium-zoom.min.js
|
||||
mediumzoom:
|
||||
|
||||
# Lazyload
|
||||
# lazyload: //unpkg.com/lozad@1/dist/lozad.min.js
|
||||
# lazyload: //cdnjs.cloudflare.com/ajax/libs/lozad.js/1.15.0/lozad.min.js
|
||||
lazyload:
|
||||
|
||||
# Pangu
|
||||
# pangu: //unpkg.com/pangu@4/dist/browser/pangu.min.js
|
||||
# pangu: //cdnjs.cloudflare.com/ajax/libs/pangu/4.0.7/pangu.min.js
|
||||
pangu:
|
||||
|
||||
# Quicklink
|
||||
# quicklink: //unpkg.com/quicklink@2/dist/quicklink.umd.js
|
||||
# quicklink: //cdnjs.cloudflare.com/ajax/libs/quicklink/2.0.0/quicklink.umd.js
|
||||
quicklink:
|
||||
|
||||
# DisqusJS
|
||||
# disqusjs_js: //unpkg.com/disqusjs@1/dist/disqus.js
|
||||
# disqusjs_css: //unpkg.com/disqusjs@1/dist/disqusjs.css
|
||||
disqusjs_js:
|
||||
disqusjs_css:
|
||||
|
||||
# Valine
|
||||
# valine: //unpkg.com/valine@1/dist/Valine.min.js
|
||||
# valine: //cdnjs.cloudflare.com/ajax/libs/valine/1.4.14/Valine.min.js
|
||||
valine:
|
||||
|
||||
# Gitalk
|
||||
# gitalk_js: //unpkg.com/gitalk@1/dist/gitalk.min.js
|
||||
# gitalk_css: //unpkg.com/gitalk@1/dist/gitalk.min.css
|
||||
gitalk_js:
|
||||
gitalk_css:
|
||||
|
||||
# Algolia Search
|
||||
# algolia_search: //unpkg.com/algoliasearch@4/dist/algoliasearch-lite.umd.js
|
||||
# instant_search: //unpkg.com/instantsearch.js@4/dist/instantsearch.production.min.js
|
||||
algolia_search:
|
||||
instant_search:
|
||||
|
||||
# Mermaid
|
||||
# mermaid: //unpkg.com/mermaid@8/dist/mermaid.min.js
|
||||
# mermaid: //cdnjs.cloudflare.com/ajax/libs/mermaid/8.6.3/mermaid.min.js
|
||||
mermaid:
|
||||
|
||||
# Internal version: 3.1.1
|
||||
# Animate.css
|
||||
# Warning: motion won't work with animate.css version 3.2.0 or later
|
||||
# animate_css: //cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css
|
||||
# animate_css: //unpkg.com/animate.css@3.1.1/animate.min.css
|
||||
# animate_css: //cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css
|
||||
animate_css:
|
||||
|
||||
# Internal version: 1.0.2
|
||||
# pace: //unpkg.com/pace-js@1/pace.min.js
|
||||
# pace: //cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js
|
||||
# pace_css: //unpkg.com/pace-js@1/themes/blue/pace-theme-minimal.css
|
||||
# pace_css: //cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/themes/blue/pace-theme-minimal.min.css
|
||||
# Pace.js
|
||||
pace:
|
||||
pace_css:
|
||||
|
||||
# Canvas ribbon
|
||||
# canvas_ribbon: //unpkg.com/ribbon.js@1/dist/ribbon.min.js
|
||||
canvas_ribbon:
|
||||
|
||||
# Assets
|
||||
|
||||
132
_vendors.yml
Normal file
132
_vendors.yml
Normal file
@ -0,0 +1,132 @@
|
||||
anime:
|
||||
name: animejs
|
||||
version: 3.2.0
|
||||
file: lib/anime.min.js
|
||||
fontawesome:
|
||||
name: '@fortawesome/fontawesome-free'
|
||||
version: 5.14.0
|
||||
file: css/all.min.css
|
||||
alias: font-awesome
|
||||
prism:
|
||||
name: prismjs
|
||||
version: 1.20.0
|
||||
file: components/prism-core.min.js
|
||||
alias: prism
|
||||
prism_autoloader:
|
||||
name: prismjs
|
||||
version: 1.20.0
|
||||
file: plugins/autoloader/prism-autoloader.min.js
|
||||
alias: prism
|
||||
prism_line_numbers:
|
||||
name: prismjs
|
||||
version: 1.20.0
|
||||
file: plugins/line-numbers/prism-line-numbers.min.js
|
||||
alias: prism
|
||||
mathjax:
|
||||
name: mathjax
|
||||
version: 3.0.5
|
||||
file: es5/tex-mml-chtml.js
|
||||
katex:
|
||||
name: katex
|
||||
version: 0.11.1
|
||||
file: dist/katex.min.css
|
||||
alias: KaTeX
|
||||
copy_tex_js:
|
||||
name: katex
|
||||
version: 0.11.1
|
||||
file: dist/contrib/copy-tex.min.js
|
||||
alias: KaTeX
|
||||
copy_tex_css:
|
||||
name: katex
|
||||
version: 0.11.1
|
||||
file: dist/contrib/copy-tex.min.css
|
||||
alias: KaTeX
|
||||
pjax:
|
||||
name: '@next-theme/pjax'
|
||||
version: 0.4.0
|
||||
file: pjax.min.js
|
||||
unavailable: [cdnjs]
|
||||
jquery:
|
||||
name: jquery
|
||||
version: 3.5.1
|
||||
file: dist/jquery.min.js
|
||||
fancybox:
|
||||
name: '@fancyapps/fancybox'
|
||||
version: 3.5.7
|
||||
file: dist/jquery.fancybox.min.js
|
||||
alias: fancybox
|
||||
fancybox_css:
|
||||
name: '@fancyapps/fancybox'
|
||||
version: 3.5.7
|
||||
file: dist/jquery.fancybox.min.css
|
||||
alias: fancybox
|
||||
mediumzoom:
|
||||
name: medium-zoom
|
||||
version: 1.0.6
|
||||
file: dist/medium-zoom.min.js
|
||||
lazyload:
|
||||
name: lozad
|
||||
version: 1.15.0
|
||||
file: dist/lozad.min.js
|
||||
alias: lozad.js
|
||||
pangu:
|
||||
name: pangu
|
||||
version: 4.0.7
|
||||
file: dist/browser/pangu.min.js
|
||||
quicklink:
|
||||
name: quicklink
|
||||
version: 2.0.0
|
||||
file: dist/quicklink.umd.js
|
||||
disqusjs_js:
|
||||
name: disqusjs
|
||||
version: 1.3.0
|
||||
file: dist/disqus.js
|
||||
unavailable: [cdnjs]
|
||||
disqusjs_css:
|
||||
name: disqusjs
|
||||
version: 1.3.0
|
||||
file: dist/disqusjs.css
|
||||
unavailable: [cdnjs]
|
||||
valine:
|
||||
name: valine
|
||||
version: 1.4.14
|
||||
file: dist/Valine.min.js
|
||||
gitalk_js:
|
||||
name: gitalk
|
||||
version: 1.6.2
|
||||
file: dist/gitalk.min.js
|
||||
gitalk_css:
|
||||
name: gitalk
|
||||
version: 1.6.2
|
||||
file: dist/gitalk.css
|
||||
algolia_search:
|
||||
name: algoliasearch
|
||||
version: 4.3.1
|
||||
file: dist/algoliasearch-lite.umd.js
|
||||
instant_search:
|
||||
name: instantsearch.js
|
||||
version: 4.7.0
|
||||
file: dist/instantsearch.production.min.js
|
||||
mermaid:
|
||||
name: mermaid
|
||||
version: 8.6.4
|
||||
file: dist/mermaid.min.js
|
||||
animate_css:
|
||||
name: animate.css
|
||||
version: 3.1.1
|
||||
file: animate.min.css
|
||||
pace:
|
||||
name: pace-js
|
||||
version: 1.0.2
|
||||
file: pace.min.js
|
||||
alias: pace
|
||||
pace_css:
|
||||
name: pace-js
|
||||
version: 1.0.2
|
||||
file: themes/blue/pace-theme-minimal.css
|
||||
alias: pace
|
||||
canvas_ribbon:
|
||||
name: ribbon.js
|
||||
version: 1.0.2
|
||||
file: dist/ribbon.min.js
|
||||
unavailable: [cdnjs]
|
||||
@ -43,24 +43,19 @@
|
||||
|
||||
{{ next_font() }}
|
||||
|
||||
{%- set font_awesome_uri = theme.vendors.fontawesome or 'lib/font-awesome/css/all.min.css' %}
|
||||
<link rel="stylesheet" href="{{ url_for(font_awesome_uri) }}">
|
||||
<link rel="stylesheet" href="{{ theme.vendors.fontawesome }}">
|
||||
|
||||
{%-if theme.motion.enable %}
|
||||
{% set animate_css_uri = theme.vendors.animate_css or 'lib/animate-css/animate.min.css' %}
|
||||
<link rel="stylesheet" href="{{ url_for(animate_css_uri) }}">
|
||||
<link rel="stylesheet" href="{{ theme.vendors.animate_css }}">
|
||||
{%- endif %}
|
||||
|
||||
{%- if theme.fancybox %}
|
||||
{%- set fancybox_css_uri = theme.vendors.fancybox_css or '//cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css' %}
|
||||
<link rel="stylesheet" href="{{ url_for(fancybox_css_uri) }}">
|
||||
<link rel="stylesheet" href="{{ theme.vendors.fancybox_css }}">
|
||||
{%- endif %}
|
||||
|
||||
{%- if theme.pace.enable %}
|
||||
{%- set pace_css_uri = theme.vendors.pace_css or '//cdn.jsdelivr.net/npm/pace-js@1/themes/blue/pace-theme-' + theme.pace.theme + '.min.css' %}
|
||||
{%- set pace_js_uri = theme.vendors.pace or '//cdn.jsdelivr.net/npm/pace-js@1/pace.min.js' %}
|
||||
<link rel="stylesheet" href="{{ url_for(pace_css_uri) }}">
|
||||
<script src="{{ url_for(pace_js_uri) }}"></script>
|
||||
<link rel="stylesheet" href="{{ theme.vendors.pace_css }}">
|
||||
<script src="{{ theme.vendors.pace }}"></script>
|
||||
{%- endif %}
|
||||
|
||||
{{ next_config() }}
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
{%- if theme.canvas_ribbon.enable %}
|
||||
{%- set canvas_ribbon_uri = theme.vendors.canvas_ribbon or '//cdn.jsdelivr.net/npm/ribbon.js@1/dist/ribbon.min.js' %}
|
||||
<script size="{{ theme.canvas_ribbon.size }}" alpha="{{ theme.canvas_ribbon.alpha }}" zIndex="{{ theme.canvas_ribbon.zIndex }}" src="{{ url_for(canvas_ribbon_uri) }}"></script>
|
||||
<script size="{{ theme.canvas_ribbon.size }}" alpha="{{ theme.canvas_ribbon.alpha }}" zIndex="{{ theme.canvas_ribbon.zIndex }}" src="{{ theme.vendors.canvas_ribbon }}"></script>
|
||||
{%- endif %}
|
||||
|
||||
{%- for name, internal in js_vendors() %}
|
||||
<script src="{{ url_for(theme.vendors[name] or internal) }}"></script>
|
||||
{%- for name in js_vendors() %}
|
||||
<script src="{{ url_for(theme.vendors[name]) }}"></script>
|
||||
{%- endfor %}
|
||||
|
||||
7
layout/_third-party/comments/disqusjs.njk
vendored
7
layout/_third-party/comments/disqusjs.njk
vendored
@ -1,12 +1,9 @@
|
||||
{%- if page.comments %}
|
||||
{%- set disqusjs_css_uri = theme.vendors.disqusjs_css or '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css' %}
|
||||
<link rel="stylesheet" href="{{ url_for(disqusjs_css_uri) }}">
|
||||
|
||||
{%- set disqusjs_js_uri = theme.vendors.disqusjs_js or '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js' %}
|
||||
<link rel="stylesheet" href="{{ theme.vendors.disqusjs_css }}">
|
||||
|
||||
<script>
|
||||
NexT.utils.loadComments('#disqus_thread', () => {
|
||||
NexT.utils.getScript('{{ url_for(disqusjs_js_uri) }}', () => {
|
||||
NexT.utils.getScript('{{ theme.vendors.disqusjs_js }}', () => {
|
||||
window.dsqjs = new DisqusJS({
|
||||
api : '{{ theme.disqusjs.api }}' || 'https://disqus.com/api/',
|
||||
apikey : '{{ theme.disqusjs.apikey }}',
|
||||
|
||||
7
layout/_third-party/comments/gitalk.njk
vendored
7
layout/_third-party/comments/gitalk.njk
vendored
@ -1,12 +1,9 @@
|
||||
{%- if page.comments %}
|
||||
{%- set gitalk_css_uri = theme.vendors.gitalk_css or '//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css' %}
|
||||
<link rel="stylesheet" href="{{ url_for(gitalk_css_uri) }}">
|
||||
|
||||
{%- set gitalk_js_uri = theme.vendors.gitalk_js or '//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js' %}
|
||||
<link rel="stylesheet" href="{{ theme.vendors.gitalk_css }}">
|
||||
|
||||
<script>
|
||||
NexT.utils.loadComments('#gitalk-container', () => {
|
||||
NexT.utils.getScript('{{ url_for(gitalk_js_uri) }}', () => {
|
||||
NexT.utils.getScript('{{ theme.vendors.gitalk_js }}', () => {
|
||||
var gitalk = new Gitalk({
|
||||
clientID : '{{ theme.gitalk.client_id }}',
|
||||
clientSecret: '{{ theme.gitalk.client_secret }}',
|
||||
|
||||
4
layout/_third-party/comments/valine.njk
vendored
4
layout/_third-party/comments/valine.njk
vendored
@ -1,8 +1,6 @@
|
||||
{%- set valine_uri = theme.vendors.valine or '//cdn.jsdelivr.net/npm/valine@1/dist/Valine.min.js' %}
|
||||
|
||||
<script>
|
||||
NexT.utils.loadComments('#valine-comments', () => {
|
||||
NexT.utils.getScript('{{ url_for(valine_uri) }}', () => {
|
||||
NexT.utils.getScript('{{ theme.vendors.valine }}', () => {
|
||||
new Valine(Object.assign({
|
||||
el : '#valine-comments',
|
||||
path: location.pathname,
|
||||
|
||||
9
layout/_third-party/math/katex.njk
vendored
9
layout/_third-party/math/katex.njk
vendored
@ -1,8 +1,5 @@
|
||||
{%- set katex_uri = theme.vendors.katex or '//cdn.jsdelivr.net/npm/katex@0/dist/katex.min.css' %}
|
||||
<link rel="stylesheet" href="{{ url_for(katex_uri) }}">
|
||||
<link rel="stylesheet" href="{{ theme.vendors.katex }}">
|
||||
{%- if theme.math.katex.copy_tex %}
|
||||
{%- set copy_tex_js_uri = theme.vendors.copy_tex_js or '//cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js' %}
|
||||
{%- set copy_tex_css_uri = theme.vendors.copy_tex_css or '//cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.css' %}
|
||||
<script src="{{ url_for(copy_tex_js_uri) }}"></script>
|
||||
<link rel="stylesheet" href="{{ url_for(copy_tex_css_uri) }}">
|
||||
<script src="{{ theme.vendors.copy_tex_js }}"></script>
|
||||
<link rel="stylesheet" href="{{ theme.vendors.copy_tex_css }}">
|
||||
{%- endif %}
|
||||
|
||||
4
layout/_third-party/math/mathjax.njk
vendored
4
layout/_third-party/math/mathjax.njk
vendored
@ -1,5 +1,3 @@
|
||||
{%- set mathjax_uri = theme.vendors.mathjax or '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js' %}
|
||||
|
||||
<script>
|
||||
if (typeof MathJax === 'undefined') {
|
||||
window.MathJax = {
|
||||
@ -39,7 +37,7 @@
|
||||
};
|
||||
(function () {
|
||||
const script = document.createElement('script');
|
||||
script.src = '{{ url_for(mathjax_uri) }}';
|
||||
script.src = '{{ theme.vendors.mathjax }}';
|
||||
script.defer = true;
|
||||
document.head.appendChild(script);
|
||||
})();
|
||||
|
||||
3
layout/_third-party/quicklink.njk
vendored
3
layout/_third-party/quicklink.njk
vendored
@ -1,6 +1,5 @@
|
||||
{%- if page.quicklink.enable %}
|
||||
{%- set quicklink_uri = theme.vendors.quicklink or '//cdn.jsdelivr.net/npm/quicklink@2/dist/quicklink.umd.js' %}
|
||||
<script src="{{ url_for(quicklink_uri) }}"></script>
|
||||
<script src="{{ theme.vendors.quicklink }}"></script>
|
||||
<script>
|
||||
{%- if page.quicklink.delay %}
|
||||
window.addEventListener('load', () => {
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
{%- set algolia_search_uri = theme.vendors.algolia_search or '//cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js' %}
|
||||
{%- set instant_search_uri = theme.vendors.instant_search or '//cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js' %}
|
||||
<script src="{{ url_for(algolia_search_uri) }}"></script>
|
||||
<script src="{{ url_for(instant_search_uri) }}"></script>
|
||||
<script src="{{ theme.vendors.algolia_search }}"></script>
|
||||
<script src="{{ theme.vendors.instant_search }}"></script>
|
||||
|
||||
{{- next_js('algolia-search.js') }}
|
||||
|
||||
3
layout/_third-party/tags/mermaid.njk
vendored
3
layout/_third-party/tags/mermaid.njk
vendored
@ -1,8 +1,7 @@
|
||||
{%- if theme.mermaid.enable %}
|
||||
{%- set mermaid_uri = theme.vendors.mermaid or '//cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js' %}
|
||||
<script{{ pjax }}>
|
||||
if (document.querySelectorAll('pre.mermaid').length) {
|
||||
NexT.utils.getScript('{{ url_for(mermaid_uri) }}', () => {
|
||||
NexT.utils.getScript('{{ theme.vendors.mermaid }}', () => {
|
||||
mermaid.init({
|
||||
theme : '{{ theme.mermaid.theme }}',
|
||||
logLevel : 3,
|
||||
|
||||
@ -3,8 +3,10 @@
|
||||
'use strict';
|
||||
|
||||
hexo.extend.filter.register('before_generate', () => {
|
||||
// Merge config.
|
||||
// Merge config
|
||||
require('./lib/config')(hexo);
|
||||
// Set vendors
|
||||
require('./lib/vendors')(hexo);
|
||||
// Add filter type `theme_inject`
|
||||
require('./lib/injects')(hexo);
|
||||
// Highlight
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const merge = require('hexo-util').deepMerge || require('lodash/merge');
|
||||
let plugins;
|
||||
try {
|
||||
plugins = require('@next-theme/plugins');
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
module.exports = hexo => {
|
||||
const data = hexo.locals.get('data');
|
||||
@ -28,13 +23,6 @@ module.exports = hexo => {
|
||||
hexo.log.warn('Since caching is turned on, the `relative_link` option in Hexo `_config.yml` is set to `false` to avoid potential hazards.');
|
||||
hexo.config.relative_link = false;
|
||||
}
|
||||
if (typeof plugins === 'function') {
|
||||
const { vendors, generator } = plugins();
|
||||
Object.keys(vendors).forEach(key => {
|
||||
hexo.theme.config.vendors[key] = hexo.theme.config.vendors[key] || vendors[key];
|
||||
});
|
||||
hexo.extend.generator.register('next_vendors', () => generator);
|
||||
}
|
||||
hexo.config.meta_generator = false;
|
||||
|
||||
// Custom languages support. Introduced in NexT v6.3.0.
|
||||
|
||||
37
scripts/events/lib/vendors.js
Normal file
37
scripts/events/lib/vendors.js
Normal file
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const yaml = require('js-yaml');
|
||||
const { url_for } = require('hexo-util');
|
||||
let internal;
|
||||
try {
|
||||
internal = require('@next-theme/plugins');
|
||||
} catch (error) {
|
||||
}
|
||||
const vendorsFile = fs.readFileSync(path.join(__dirname, '../../../_vendors.yml'));
|
||||
const dependencies = yaml.safeLoad(vendorsFile);
|
||||
|
||||
module.exports = hexo => {
|
||||
const { vendors } = hexo.theme.config;
|
||||
if (typeof internal === 'function') {
|
||||
internal(hexo, dependencies);
|
||||
}
|
||||
for (const [key, value] of Object.entries(dependencies)) {
|
||||
if (vendors[key]) {
|
||||
vendors[key] = url_for.call(hexo, vendors[key]);
|
||||
continue;
|
||||
}
|
||||
const { name, version, file, alias, unavailable } = value;
|
||||
const links = {
|
||||
local : url_for.call(hexo, `lib/${name}/${file}`),
|
||||
jsdelivr: `//cdn.jsdelivr.net/npm/${name}@${version}/${file}`,
|
||||
unpkg : `//unpkg.com/${name}@${version}/${file}`,
|
||||
cdnjs : `//cdnjs.cloudflare.com/ajax/libs/${alias || name}/${version}/${file.replace(/^(dist|lib|)\/(browser\/|)/, '')}`
|
||||
};
|
||||
let { plugins = 'jsdelivr' } = vendors;
|
||||
if (plugins === 'cdnjs' && unavailable && unavailable.includes('cdnjs')) plugins = 'jsdelivr';
|
||||
if (plugins === 'local' && typeof internal === 'undefined') plugins = 'jsdelivr';
|
||||
vendors[key] = links[plugins];
|
||||
}
|
||||
};
|
||||
@ -12,20 +12,6 @@ hexo.extend.filter.register('after_generate', () => {
|
||||
|
||||
if (!theme.motion.enable) {
|
||||
hexo.route.remove('js/motion.js');
|
||||
hexo.route.remove('lib/animate-css/animate.min.css');
|
||||
} else if (theme.vendors.animate_css) {
|
||||
hexo.route.remove('lib/animate-css/animate.min.css');
|
||||
}
|
||||
|
||||
if (theme.vendors.fontawesome) {
|
||||
const lists = hexo.route.list();
|
||||
lists.forEach(path => {
|
||||
if (path.startsWith('lib/font-awesome')) hexo.route.remove(path);
|
||||
});
|
||||
}
|
||||
|
||||
if (theme.vendors.anime) {
|
||||
hexo.route.remove('lib/anime.min.js');
|
||||
}
|
||||
|
||||
if (!theme.algolia_search.enable) {
|
||||
|
||||
@ -4,31 +4,27 @@
|
||||
|
||||
hexo.extend.helper.register('js_vendors', function() {
|
||||
const { config, theme } = this;
|
||||
const vendors = {
|
||||
anime: 'lib/anime.min.js'
|
||||
};
|
||||
const vendors = ['anime'];
|
||||
if (config.prismjs.enable && !config.prismjs.preprocess) {
|
||||
vendors.prism = '//cdn.jsdelivr.net/npm/prismjs@1/components/prism-core.min.js';
|
||||
vendors.prism_autoloader = '//cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js';
|
||||
vendors.push('prism', 'prism_autoloader');
|
||||
if (config.prismjs.line_number) {
|
||||
vendors.prism_line_numbers = '//cdn.jsdelivr.net/npm/prismjs@1/plugins/line-numbers/prism-line-numbers.min.js';
|
||||
vendors.push('prism_line_numbers');
|
||||
}
|
||||
}
|
||||
if (theme.pjax) {
|
||||
vendors.pjax = '//cdn.jsdelivr.net/gh/next-theme/pjax@0/pjax.min.js';
|
||||
vendors.push('pjax');
|
||||
}
|
||||
if (theme.fancybox) {
|
||||
vendors.jquery = '//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js';
|
||||
vendors.fancybox = '//cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js';
|
||||
vendors.push('jquery', 'fancybox');
|
||||
}
|
||||
if (theme.mediumzoom) {
|
||||
vendors.mediumzoom = '//cdn.jsdelivr.net/npm/medium-zoom@1/dist/medium-zoom.min.js';
|
||||
vendors.push('mediumzoom');
|
||||
}
|
||||
if (theme.lazyload) {
|
||||
vendors.lazyload = '//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js';
|
||||
vendors.push('lazyload');
|
||||
}
|
||||
if (theme.pangu) {
|
||||
vendors.pangu = '//cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js';
|
||||
vendors.push('pangu');
|
||||
}
|
||||
return vendors;
|
||||
});
|
||||
|
||||
12
source/lib/animate-css/animate.min.css
vendored
12
source/lib/animate-css/animate.min.css
vendored
File diff suppressed because one or more lines are too long
8
source/lib/anime.min.js
vendored
8
source/lib/anime.min.js
vendored
File diff suppressed because one or more lines are too long
5
source/lib/font-awesome/css/all.min.css
vendored
5
source/lib/font-awesome/css/all.min.css
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,6 +13,13 @@ describe('Validate', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('vendors', () => {
|
||||
const vendorsFile = fs.readFileSync(path.join(__dirname, '../../_vendors.yml'));
|
||||
should.not.throw(() => {
|
||||
yaml.safeLoad(vendorsFile);
|
||||
});
|
||||
});
|
||||
|
||||
it('language', () => {
|
||||
const languagesPath = path.join(__dirname, '../../languages');
|
||||
should.not.throw(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user