mirror of https://gitlab.com/curben/blog
style: standard
This commit is contained in:
parent
ffd57460c7
commit
3fca979939
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
const moment = require('moment')
|
const moment = require('moment')
|
||||||
const { escapeHTML, htmlTag, stripHTML } = require('hexo-util')
|
const { escapeHTML, htmlTag, stripHTML } = require('hexo-util')
|
||||||
const micromatch = require('micromatch')
|
|
||||||
|
|
||||||
function meta (name, content, escape) {
|
function meta (name, content, escape) {
|
||||||
if (escape !== false && typeof content === 'string') {
|
if (escape !== false && typeof content === 'string') {
|
||||||
|
@ -67,7 +66,7 @@ function openGraphHelper (options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!images.length && content && content.includes('<img')) {
|
if (!images.length && content && content.includes('<img')) {
|
||||||
images = images.slice();
|
images = images.slice()
|
||||||
|
|
||||||
let img
|
let img
|
||||||
const imgPattern = /<img [^>]*src=['"]([^'"]+)([^>]*>)/gi
|
const imgPattern = /<img [^>]*src=['"]([^'"]+)([^>]*>)/gi
|
||||||
|
@ -103,14 +102,17 @@ function openGraphHelper (options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
images = images.map(path => {
|
images = images.map(path => {
|
||||||
// parse relative url to full url
|
let url
|
||||||
|
// resolve `path`'s absolute path relative to current page's url
|
||||||
|
// `path` can be both absolute (starts with `/`) or relative.
|
||||||
try {
|
try {
|
||||||
new URL(path)
|
url = new URL(path).href
|
||||||
} catch {
|
} catch (e) {
|
||||||
return new URL(path, config.url).href
|
url = new URL(path, config.url).href
|
||||||
|
return url
|
||||||
}
|
}
|
||||||
|
|
||||||
return path
|
return url
|
||||||
})
|
})
|
||||||
|
|
||||||
images.forEach(path => {
|
images.forEach(path => {
|
||||||
|
|
Loading…
Reference in New Issue