mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Code style update
This commit is contained in:
parent
b02c93dc3a
commit
da9c1dda7c
@ -47,7 +47,7 @@
|
||||
<link rel="stylesheet" href="{{ font_awesome_uri }}">
|
||||
|
||||
{%- if theme.fancybox %}
|
||||
{%- set fancybox_css_uri = theme.vendors.fancybox_css or next_vendors('//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css') %}
|
||||
{%- set fancybox_css_uri = theme.vendors.fancybox_css or '//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css' %}
|
||||
<link rel="stylesheet" href="{{ fancybox_css_uri }}">
|
||||
{%- endif %}
|
||||
|
||||
|
||||
2
layout/_third-party/quicklink.njk
vendored
2
layout/_third-party/quicklink.njk
vendored
@ -1,5 +1,5 @@
|
||||
{%- if page.quicklink.enable %}
|
||||
{%- set quicklink_uri = theme.vendors.quicklink or next_vendors('//cdn.jsdelivr.net/npm/quicklink@1/dist/quicklink.umd.js') %}
|
||||
{%- set quicklink_uri = theme.vendors.quicklink or '//cdn.jsdelivr.net/npm/quicklink@1/dist/quicklink.umd.js' %}
|
||||
<script src="{{ quicklink_uri }}"></script>
|
||||
<script>
|
||||
{%- if page.quicklink.delay %}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{%- set algolia_search_uri = theme.vendors.algolia_search or next_vendors('//cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js') %}
|
||||
{%- set instant_search_uri = theme.vendors.instant_search or next_vendors('//cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js') %}
|
||||
{%- 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="{{ algolia_search_uri }}"></script>
|
||||
<script src="{{ instant_search_uri }}"></script>
|
||||
|
||||
|
||||
@ -1,37 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
function isObject(item) {
|
||||
return item && typeof item === 'object' && !Array.isArray(item);
|
||||
}
|
||||
|
||||
function merge(target, source) {
|
||||
for (const key in source) {
|
||||
if (isObject(target[key]) && isObject(source[key])) {
|
||||
merge(target[key], source[key]);
|
||||
} else {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
const merge = require('hexo-util').deepMerge || require('lodash/merge');
|
||||
|
||||
module.exports = hexo => {
|
||||
let data = hexo.locals.get('data');
|
||||
|
||||
/**
|
||||
* Merge configs from _data/next.yml into hexo.theme.config.
|
||||
* If `override`, configs in next.yml will rewrite configs in hexo.theme.config.
|
||||
* If next.yml not exists, merge all `theme_config.*` into hexo.theme.config.
|
||||
*/
|
||||
if (data.next) {
|
||||
if (data.next.override) {
|
||||
hexo.theme.config = data.next;
|
||||
} else {
|
||||
merge(hexo.config, data.next);
|
||||
merge(hexo.theme.config, data.next);
|
||||
}
|
||||
} else {
|
||||
merge(hexo.theme.config, hexo.config.theme_config);
|
||||
hexo.config = merge(hexo.config, data.next);
|
||||
hexo.theme.config = merge(hexo.theme.config, data.next);
|
||||
} else if (hexo.config.theme_config) {
|
||||
hexo.theme.config = merge(hexo.theme.config, hexo.config.theme_config);
|
||||
}
|
||||
|
||||
if (hexo.theme.config.cache && hexo.theme.config.cache.enable && hexo.config.relative_link) {
|
||||
|
||||
@ -5,24 +5,24 @@
|
||||
const crypto = require('crypto');
|
||||
|
||||
hexo.extend.helper.register('next_inject', function(point) {
|
||||
return hexo.theme.config.injects[point]
|
||||
return this.theme.injects[point]
|
||||
.map(item => this.partial(item.layout, item.locals, item.options))
|
||||
.join('');
|
||||
});
|
||||
|
||||
hexo.extend.helper.register('next_js', function(...urls) {
|
||||
const { js } = hexo.theme.config;
|
||||
const { js } = this.theme;
|
||||
return urls.map(url => this.js(`${js}/${url}`)).join('');
|
||||
});
|
||||
|
||||
hexo.extend.helper.register('next_vendors', function(url) {
|
||||
if (url.startsWith('//')) return url;
|
||||
const internal = hexo.theme.config.vendors._internal;
|
||||
const internal = this.theme.vendors._internal;
|
||||
return this.url_for(`${internal}/${url}`);
|
||||
});
|
||||
|
||||
hexo.extend.helper.register('post_edit', function(src) {
|
||||
const theme = hexo.theme.config;
|
||||
const { theme } = this;
|
||||
if (!theme.post_edit.enable) return '';
|
||||
return this.next_url(theme.post_edit.url + src, '<i class="fa fa-pen-nib"></i>', {
|
||||
class: 'post-edit-link',
|
||||
@ -31,7 +31,7 @@ hexo.extend.helper.register('post_edit', function(src) {
|
||||
});
|
||||
|
||||
hexo.extend.helper.register('post_nav', function(post) {
|
||||
const theme = hexo.theme.config;
|
||||
const { theme } = this;
|
||||
if (theme.post_navigation === false || (!post.prev && !post.next)) return '';
|
||||
const prev = theme.post_navigation === 'right' ? post.prev : post.next;
|
||||
const next = theme.post_navigation === 'right' ? post.next : post.prev;
|
||||
|
||||
@ -2,13 +2,11 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
hexo.extend.helper.register('next_font', () => {
|
||||
const config = hexo.theme.config.font;
|
||||
hexo.extend.helper.register('next_font', function() {
|
||||
const config = this.theme.font;
|
||||
|
||||
if (!config || !config.enable) return '';
|
||||
|
||||
const fontDisplay = '&display=swap';
|
||||
const fontSubset = '&subset=latin,latin-ext';
|
||||
const fontStyles = ':300,300italic,400,400italic,700,700italic';
|
||||
const fontHost = config.host || '//fonts.googleapis.com';
|
||||
|
||||
@ -18,12 +16,10 @@ hexo.extend.helper.register('next_font', () => {
|
||||
return config[item].family + fontStyles;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
}).filter(item => item !== '');
|
||||
|
||||
fontFamilies = fontFamilies.filter(item => item !== '');
|
||||
fontFamilies = [...new Set(fontFamilies)];
|
||||
fontFamilies = fontFamilies.join('|');
|
||||
fontFamilies = [...new Set(fontFamilies)].join('|');
|
||||
|
||||
// Merge extra parameters to the final processed font string
|
||||
return fontFamilies ? `<link rel="stylesheet" href="${fontHost}/css?family=${fontFamilies.concat(fontDisplay, fontSubset)}">` : '';
|
||||
return fontFamilies ? `<link rel="stylesheet" href="${fontHost}/css?family=${fontFamilies}&display=swap&subset=latin,latin-ext">` : '';
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user