From e44b48c7a212294d5fc38588d1cf965bed3afa9d Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Sat, 27 Aug 2022 01:52:53 -0700 Subject: [PATCH] feat(tag/post_link): use original post title as title attribute (#4973) --- lib/plugins/tag/post_link.js | 5 +++-- test/scripts/tags/post_link.js | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/plugins/tag/post_link.js b/lib/plugins/tag/post_link.js index d70ada3726..d8d94fbfb8 100644 --- a/lib/plugins/tag/post_link.js +++ b/lib/plugins/tag/post_link.js @@ -30,8 +30,9 @@ module.exports = ctx => { } let title = args.length ? args.join(' ') : post.title; - const attrTitle = escapeHTML(title); - if (escape === 'true') title = attrTitle; + // Let attribute be the true post title so it appears in tooltip. + const attrTitle = escapeHTML(post.title); + if (escape === 'true') title = escapeHTML(title); const link = encodeURL(resolve(ctx.config.root, post.path)); diff --git a/test/scripts/tags/post_link.js b/test/scripts/tags/post_link.js index 473edd5f41..22696cf553 100644 --- a/test/scripts/tags/post_link.js +++ b/test/scripts/tags/post_link.js @@ -33,7 +33,7 @@ describe('post_link', () => { }); it('title', () => { - postLink(['foo', 'test']).should.eql('test'); + postLink(['foo', 'test']).should.eql('test'); }); it('should escape tag in title by default', () => { @@ -45,7 +45,7 @@ describe('post_link', () => { }); it('should escape tag in custom title', () => { - postLink(['title-with-tag', '', 'title', 'true']).should.eql('<test> title'); + postLink(['title-with-tag', '', 'title', 'true']).should.eql('<test> title'); }); it('should not escape tag in title', () => { @@ -54,7 +54,7 @@ describe('post_link', () => { it('should not escape tag in custom title', () => { postLink(['title-with-tag', 'This is a Bold "statement"', 'false']) - .should.eql('This is a Bold "statement"'); + .should.eql('This is a Bold "statement"'); }); it('should throw if no slug', () => {