style: standard

This commit is contained in:
curben 2019-08-09 22:32:51 +09:30
parent 5e40a69534
commit e20e621c73
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
5 changed files with 21 additions and 8 deletions

View File

@ -1,3 +1,6 @@
'use strict'
/* global hexo */
/*
* Put {% cloudinary 'folder/filename.jpg' 'description' %} in your post.
* Change the username in data-src tag

View File

@ -1,3 +1,6 @@
'use strict'
/* global hexo */
/*
* Add "Copy" button to code snippet
* cheerio is provided by hexo package

View File

@ -1,3 +1,6 @@
'use strict'
/* global hexo */
/*
* Modified from the hexo version,
* https://github.com/hexojs/hexo/blob/master/lib/plugins/helper/link_to.js
@ -8,7 +11,7 @@
const { htmlTag } = require('hexo-util')
function linkHelper(path, text) {
function linkHelper (path, text) {
if (!text) text = path.replace(/^https?:\/\/|\/$/g, '')
const attrs = Object.assign({

View File

@ -1,3 +1,6 @@
'use strict'
/* global hexo */
/*
* Modified from the hexo version,
* https://github.com/hexojs/hexo/blob/master/lib/plugins/helper/list_tags.js
@ -7,8 +10,8 @@
'use strict'
function listTagsHelper(tags, options) {
if (!options && (!tags || !tags.hasOwnProperty('length'))) {
function listTagsHelper (tags, options) {
if (!options && (!tags || !Object.prototype.hasOwnProperty.call(tags, 'length'))) {
options = tags
tags = this.site.tags
}
@ -17,7 +20,7 @@ function listTagsHelper(tags, options) {
options = options || {}
const { style = 'list', transform, separator = ', ', suffix = '' } = options
const showCount = options.hasOwnProperty('show_count') ? options.show_count : true
const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count') ? options.show_count : true
const className = options.class || 'tag'
const orderby = options.orderby || 'name'
const order = options.order || 1

View File

@ -1,3 +1,6 @@
'use strict'
/* global hexo */
/*
* Modified from the hexo version,
* https://github.com/hexojs/hexo/blob/master/lib/plugins/helper/open_graph.js
@ -8,7 +11,6 @@
'use strict'
const urlFn = require('url')
const moment = require('moment')
const { escapeHTML, htmlTag, stripHTML } = require('hexo-util')
const cheerio = require('cheerio')
@ -102,10 +104,10 @@ function openGraphHelper (options = {}) {
}
images = images.map(path => {
if (!urlFn.parse(path).host) {
if (!new URL(path).host) {
// resolve `path`'s absolute path relative to current page's url
// `path` can be both absolute (starts with `/`) or relative.
return urlFn.resolve(url || config.url, path)
return new URL(path, url || config.url)
}
return path
@ -115,7 +117,6 @@ function openGraphHelper (options = {}) {
result += og('og:image', path, false)
})
if (published) {
if ((moment.isMoment(published) || moment.isDate(published)) && !isNaN(published.valueOf())) {
// Skip timezone conversion