Skip to content

Commit eaacb54

Browse files
authored
small liquid link tag cleanup (#17280)
* remove unnecessary `render` methods * we don't use `link_with_short_title` anymore * remove `shortTitle` option * remove ink_with_short_title tag test
1 parent 2f03bf7 commit eaacb54

10 files changed

Lines changed: 6 additions & 42 deletions

File tree

includes/liquid-tags/link-with-short-title.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/liquid-tags/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ Note that link tags will only render links that are available in the current pag
6363
| `{% homepage_link_with_intro /href %}` | The linked page's title and intro, with homepage-specific styling.
6464
| `{% link_in_list /href %}` | The linked page's title in a list item.
6565
| `{% topic_link_in_list /href %}` | The linked map topic's title in a list item (used in category TOCs).
66-
| `{% link_with_short_title /href %}` | The linked page's title, where the title is pulled from the page's `shortTitle` frontmatter.
6766
| `{% indented_data_reference site.data.foo.bar spaces=NUMBER %}` | The data reference with the specified number of spaces prepended to each line.
6867

6968
## Creating tags
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
const Link = require('./link')
22

33
// For details, see class method in lib/liquid-tags/link.js
4-
module.exports = class HomepageLinkWithIntro extends Link {
5-
async render (context) {
6-
return super.parseTemplate(context)
7-
}
8-
}
4+
module.exports = class HomepageLinkWithIntro extends Link {}

lib/liquid-tags/link-in-list.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
const Link = require('./link')
22

33
// For details, see class method in lib/liquid-tags/link.js
4-
module.exports = class LinkInList extends Link {
5-
async render (context) {
6-
return super.parseTemplate(context)
7-
}
8-
}
4+
module.exports = class LinkInList extends Link {}

lib/liquid-tags/link-with-intro.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
const Link = require('./link')
22

33
// For details, see class method in lib/liquid-tags/link.js
4-
module.exports = class LinkWithIntro extends Link {
5-
async render (context) {
6-
return super.parseTemplate(context)
7-
}
8-
}
4+
module.exports = class LinkWithIntro extends Link {}

lib/liquid-tags/link-with-short-title.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/liquid-tags/link.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = class Link extends LiquidTag {
2727
super(template, tagName, href.trim())
2828
}
2929

30-
async parseTemplate (context, opts = { shortTitle: false }) {
30+
async parseTemplate (context) {
3131
const template = await this.getTemplate()
3232

3333
const ctx = context.environments[0]
@@ -64,9 +64,7 @@ module.exports = class Link extends LiquidTag {
6464
}
6565

6666
// find and render the props
67-
const title = opts.shortTitle
68-
? await page.renderProp('shortTitle', ctx, { textOnly: true, encodeEntities: true })
69-
: await page.renderProp('title', ctx, { textOnly: true, encodeEntities: true })
67+
const title = await page.renderProp('title', ctx, { textOnly: true, encodeEntities: true })
7068

7169
// we want markdown in intros to be parsed, so we do not pass textOnly here
7270
const intro = await page.renderProp('intro', ctx, { unwrap: true })
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
const Link = require('./link')
22

33
// For details, see class method in lib/liquid-tags/link.js
4-
module.exports = class TopicLinkInList extends Link {
5-
async render (context) {
6-
return super.parseTemplate(context)
7-
}
8-
}
4+
module.exports = class TopicLinkInList extends Link {}

lib/render-content/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ renderContent.liquid.registerTag('link_with_intro', require('../liquid-tags/link
99
renderContent.liquid.registerTag('homepage_link_with_intro', require('../liquid-tags/homepage-link-with-intro'))
1010
renderContent.liquid.registerTag('link_in_list', require('../liquid-tags/link-in-list'))
1111
renderContent.liquid.registerTag('topic_link_in_list', require('../liquid-tags/topic-link-in-list'))
12-
renderContent.liquid.registerTag('link_with_short_title', require('../liquid-tags/link-with-short-title'))
1312
renderContent.liquid.registerTag('indented_data_reference', require('../liquid-tags/indented-data-reference'))
1413
renderContent.liquid.registerTag('data', require('../liquid-tags/data'))
1514
renderContent.liquid.registerTag('octicon', require('../liquid-tags/octicon'))

tests/unit/liquid-helpers.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ describe('liquid helper tags', () => {
7979
expect(output).toBe(expected)
8080
})
8181

82-
test('link_with_short_title tag', async () => {
83-
const template = '{% link_with_short_title /contributing-and-collaborating-using-github-desktop %}'
84-
const expected = '<a class="link-title Bump-link--hover no-underline" href="/en/desktop/contributing-and-collaborating-using-github-desktop">Contributing and collaborating</a>'
85-
const output = await liquid.parseAndRender(template, context)
86-
expect(output).toBe(expected)
87-
})
88-
8982
describe('indented_data_reference tag', () => {
9083
test('without any number of spaces specified', async () => {
9184
const template = '{% indented_data_reference site.data.reusables.example %}'

0 commit comments

Comments
 (0)