Update next_js helper

This commit is contained in:
Mimi 2022-03-07 15:52:16 +08:00
parent 2ca7577f0a
commit bd69da6470
3 changed files with 7 additions and 4 deletions

View File

@ -14,7 +14,7 @@
{{ partial(inject_item.layout, inject_item.locals, inject_item.options) }}
</div>
{%- endfor %}
{{- next_js('comments-buttons.js', true) }}
{{- next_js('comments-buttons.js', { pjax: true }) }}
{%- elif theme.comments.style == 'tabs' %}
<div class="tabs tabs-comment">
<ul class="nav-tabs">

View File

@ -1,3 +1,3 @@
<div class="event-list">
</div>
{{- next_js('schedule.js', true) }}
{{- next_js('schedule.js', { pjax: true }) }}

View File

@ -17,7 +17,10 @@ hexo.extend.helper.register('next_inject', function(point) {
.join('');
});
hexo.extend.helper.register('next_js', function(file, pjax = false) {
hexo.extend.helper.register('next_js', function(file, {
pjax = false,
module = false
} = {}) {
const { next_version } = this;
const { internal, custom_cdn_url } = this.theme.vendors;
const links = getVendors({
@ -29,7 +32,7 @@ hexo.extend.helper.register('next_js', function(file, pjax = false) {
custom : custom_cdn_url
});
const src = links[internal] || links.local;
return `<script ${pjax ? 'data-pjax ' : ''}src="${src}"></script>`;
return `<script ${pjax ? 'data-pjax ' : ''}${module ? 'type="module" ' : ''}src="${src}"></script>`;
});
hexo.extend.helper.register('next_vendors', function(name) {