Skip to content

Commit

Permalink
let post_link use original post title as title attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed May 18, 2022
1 parent afc4d7f commit bc06aa2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/plugins/tag/post_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
6 changes: 3 additions & 3 deletions test/scripts/tags/post_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('post_link', () => {
});

it('title', () => {
postLink(['foo', 'test']).should.eql('<a href="/foo/" title="test">test</a>');
postLink(['foo', 'test']).should.eql('<a href="/foo/" title="Hello world">test</a>');
});

it('should escape tag in title by default', () => {
Expand All @@ -45,7 +45,7 @@ describe('post_link', () => {
});

it('should escape tag in custom title', () => {
postLink(['title-with-tag', '<test>', 'title', 'true']).should.eql('<a href="/title-with-tag/" title="&lt;test&gt; title">&lt;test&gt; title</a>');
postLink(['title-with-tag', '<test>', 'title', 'true']).should.eql('<a href="/title-with-tag/" title="&quot;Hello&quot; &lt;new world&gt;!">&lt;test&gt; title</a>');
});

it('should not escape tag in title', () => {
Expand All @@ -54,7 +54,7 @@ describe('post_link', () => {

it('should not escape tag in custom title', () => {
postLink(['title-with-tag', 'This is a <b>Bold</b> "statement"', 'false'])
.should.eql('<a href="/title-with-tag/" title="This is a &lt;b&gt;Bold&lt;&#x2F;b&gt; &quot;statement&quot;">This is a <b>Bold</b> "statement"</a>');
.should.eql('<a href="/title-with-tag/" title="&quot;Hello&quot; &lt;new world&gt;!">This is a <b>Bold</b> "statement"</a>');
});

it('no slug', () => {
Expand Down

0 comments on commit bc06aa2

Please # to comment.