Fix exturl title (#193)

This commit is contained in:
小柚子 2021-02-08 15:05:39 +08:00 committed by GitHub
parent 941e9817c6
commit 3a1b30afee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,10 @@ hexo.extend.filter.register('after_post_render', data => {
const link = parse(href); const link = parse(href);
if (!link.protocol || link.hostname === siteHost) return match; if (!link.protocol || link.hostname === siteHost) return match;
// Return encrypted URL with title.
const title = match.match(/title="([^"]+)"/);
if (title) return `<span class="exturl" data-url="${Buffer.from(href).toString('base64')}" title="${title[1]}">${html}<i class="fa fa-external-link-alt"></i></span>`;
return `<span class="exturl" data-url="${Buffer.from(href).toString('base64')}">${html}<i class="fa fa-external-link-alt"></i></span>`; return `<span class="exturl" data-url="${Buffer.from(href).toString('base64')}">${html}<i class="fa fa-external-link-alt"></i></span>`;
}); });
} }