From bc06aa2a78c42b94864349b3dd2aac3a4b2e0d9a Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Wed, 18 May 2022 04:16:51 -0700 Subject: [PATCH 1/2] let post_link use original post title as title attribute --- lib/plugins/tag/post_link.js | 4 ++-- test/scripts/tags/post_link.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/plugins/tag/post_link.js b/lib/plugins/tag/post_link.js index f27cec0c4e..5b2f53d27c 100644 --- a/lib/plugins/tag/post_link.js +++ b/lib/plugins/tag/post_link.js @@ -27,8 +27,8 @@ module.exports = ctx => { if (!post) return error; let title = args.length ? args.join(' ') : post.title; - const attrTitle = escapeHTML(title); - if (escape === 'true') title = attrTitle; + 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 e0a9d3c6a5..ac7549731b 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('no slug', () => { From a99693b8f6a78a7d7bf761f306c22ba5d1968a89 Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Wed, 18 May 2022 04:24:27 -0700 Subject: [PATCH 2/2] add comment --- lib/plugins/tag/post_link.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/plugins/tag/post_link.js b/lib/plugins/tag/post_link.js index 5b2f53d27c..ed03669bdf 100644 --- a/lib/plugins/tag/post_link.js +++ b/lib/plugins/tag/post_link.js @@ -27,6 +27,7 @@ module.exports = ctx => { if (!post) return error; let title = args.length ? args.join(' ') : post.title; + // Let attribute be the true post title so it appears in tooltip. const attrTitle = escapeHTML(post.title); if (escape === 'true') title = escapeHTML(title);