Skip to content

Commit

Permalink
Run lebab
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Mar 22, 2020
1 parent e9d6287 commit 5120c95
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion layout/_partials/footer.swig
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{%- endif %}
</div>

{%- if theme.footer.powered.enable %}
{%- if theme.footer.powered %}
<div class="powered-by">
{%- set next_site = 'https://theme-next.org' %}
{%- if theme.scheme !== 'Gemini' %}
Expand Down
10 changes: 5 additions & 5 deletions scripts/events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ hexo.on('generateAfter', () => {
'User-Agent': 'Theme NexT Client'
}
}, res => {
var result = '';
let result = '';
res.on('data', data => {
result += data;
});
res.on('end', () => {
try {
var latest = JSON.parse(result).tag_name.replace('v', '').split('.');
var current = version.split('.');
var isOutdated = false;
for (var i = 0; i < Math.max(latest.length, current.length); i++) {
let latest = JSON.parse(result).tag_name.replace('v', '').split('.');
let current = version.split('.');
let isOutdated = false;
for (let i = 0; i < Math.max(latest.length, current.length); i++) {
if (!current[i] || latest[i] > current[i]) {
isOutdated = true;
break;
Expand Down
11 changes: 4 additions & 7 deletions scripts/events/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ function merge(target, source) {
}

module.exports = hexo => {
if (!hexo.locals.get) return;

var data = hexo.locals.get('data');
if (!data) return;
let data = hexo.locals.get('data');

/**
* Merge configs from _data/next.yml into hexo.theme.config.
Expand All @@ -45,10 +42,10 @@ module.exports = hexo => {

// Custom languages support. Introduced in NexT v6.3.0.
if (data.languages) {
var { language } = hexo.config;
var { i18n } = hexo.theme;
let { language } = hexo.config;
let { i18n } = hexo.theme;

var mergeLang = lang => {
const mergeLang = lang => {
i18n.set(lang, merge(i18n.get([lang]), data.languages[lang]));
};

Expand Down
4 changes: 2 additions & 2 deletions scripts/filters/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ hexo.extend.filter.register('after_post_render', data => {
}
if (theme.exturl) {
const url = require('url');
var siteHost = url.parse(config.url).hostname || config.url;
const siteHost = url.parse(config.url).hostname || config.url;
data.content = data.content.replace(/<a[^>]* href="([^"]+)"[^>]*>([^<]+)<\/a>/img, (match, href, html) => {
// Exit if the href attribute doesn't exists.
if (!href) return match;

// Exit if the url has same host with `config.url`, which means it's an internal link.
var link = url.parse(href);
let link = url.parse(href);
if (!link.protocol || link.hostname === siteHost) return match;

// If title atribute filled, set it as title; if not, set url as title.
Expand Down
2 changes: 1 addition & 1 deletion scripts/helpers/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ hexo.extend.helper.register('gitalk_md5', function(path) {
hexo.extend.helper.register('canonical', function() {
// https://support.google.com/webmasters/answer/139066
const { permalink } = hexo.config;
var url = this.url.replace(/index\.html$/, '');
let url = this.url.replace(/index\.html$/, '');
if (!permalink.endsWith('.html')) {
url = url.replace(/\.html$/, '');
}
Expand Down
12 changes: 6 additions & 6 deletions scripts/helpers/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
'use strict';

hexo.extend.helper.register('next_font', () => {
var config = hexo.theme.config.font;
const config = hexo.theme.config.font;

if (!config || !config.enable) return '';

var fontDisplay = '&display=swap';
var fontSubset = '&subset=latin,latin-ext';
var fontStyles = ':300,300italic,400,400italic,700,700italic';
var fontHost = config.host || '//fonts.googleapis.com';
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';

//Get a font list from config
var fontFamilies = ['global', 'title', 'headings', 'posts', 'codes'].map(item => {
let fontFamilies = ['global', 'title', 'headings', 'posts', 'codes'].map(item => {
if (config[item] && config[item].family && config[item].external) {
return config[item].family + fontStyles;
}
Expand Down
14 changes: 7 additions & 7 deletions scripts/helpers/next-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ const url = require('url');

hexo.extend.helper.register('next_url', function(path, text, options = {}) {
const { config } = this;
var data = url.parse(path);
var siteHost = url.parse(config.url).hostname || config.url;
const data = url.parse(path);
const siteHost = url.parse(config.url).hostname || config.url;

var theme = hexo.theme.config;
var exturl = '';
var tag = 'a';
var attrs = { href: this.url_for(path) };
const theme = hexo.theme.config;
let exturl = '';
let tag = 'a';
let attrs = { href: this.url_for(path) };

// If `exturl` enabled, set spanned links only on external links.
if (theme.exturl && data.protocol && data.hostname !== siteHost) {
tag = 'span';
exturl = 'exturl';
var encoded = Buffer.from(path).toString('base64');
const encoded = Buffer.from(path).toString('base64');
attrs = {
class : exturl,
'data-url': encoded
Expand Down

0 comments on commit 5120c95

Please sign in to comment.