* Install liquidjs, uninstall liquid * Comment a bunch of stuff out to get going * Fix invalid includes * Fix all includes (path => 'path') * Get the homepage to render * Do link-in-list kinda * Revert "Fix all includes (path => 'path')" This reverts commit d6fead646353aa5041d9229470a62a1d487456b9. * Support non-dynamic partials * Extract getTemplate helper * Do remaining custom Liquid tags * Fix some custom tag bugs * Moar bugs * Re-add link tag * Cleaner diff * Actually fix extended markdown tags * Fully comment out version matchers * Smaller diff * Rely only on Liquid internals for conditionals * Use new operators option in Liquid engine * Fix link.js * Don't need options * Updoot to the right doot * Fix some bugs * Fix another bug * Pass a test * Fix the translate bits * Adjust a test * Fix another invalid Liquid bug * Two more borked translations * Found some more * Don't need this change * Revert "Don't need this change" This reverts commit a916d619747f0492865a69c3e237c97c4d4e7fad. * This should fix the broken links * Missed one * Revert "This should fix the broken links" This reverts commit e6c2cc0d9055d958706260d57edbe293281c150e. * Revert "Missed one" This reverts commit bbe1f23baf16e020f6f7931589decb1afc75dfbd. * Updoot liquidjs
47 lines
1.8 KiB
JavaScript
47 lines
1.8 KiB
JavaScript
const GithubSlugger = require('github-slugger')
|
|
const renderContent = require('./renderContent')
|
|
const { ExtendedMarkdown, tags } = require('../liquid-tags/extended-markdown')
|
|
|
|
// Include custom tags like {% link_with_intro /article/foo %}
|
|
renderContent.liquid.registerTag('link', require('../liquid-tags/link')('link'))
|
|
renderContent.liquid.registerTag('link_with_intro', require('../liquid-tags/link-with-intro'))
|
|
renderContent.liquid.registerTag('homepage_link_with_intro', require('../liquid-tags/homepage-link-with-intro'))
|
|
renderContent.liquid.registerTag('link_in_list', require('../liquid-tags/link-in-list'))
|
|
renderContent.liquid.registerTag('topic_link_in_list', require('../liquid-tags/topic-link-in-list'))
|
|
renderContent.liquid.registerTag('indented_data_reference', require('../liquid-tags/indented-data-reference'))
|
|
renderContent.liquid.registerTag('data', require('../liquid-tags/data'))
|
|
renderContent.liquid.registerTag('octicon', require('../liquid-tags/octicon'))
|
|
renderContent.liquid.registerTag('link_as_article_card', require('../liquid-tags/link-as-article-card'))
|
|
|
|
for (const tag in tags) {
|
|
// Register all the extended markdown tags, like {% note %} and {% warning %}
|
|
renderContent.liquid.registerTag(tag, ExtendedMarkdown)
|
|
}
|
|
|
|
/**
|
|
* Like the `size` filter, but specifically for
|
|
* getting the number of keys in an object
|
|
*/
|
|
renderContent.liquid.registerFilter('obj_size', input => {
|
|
if (!input) return 0
|
|
return Object.keys(input).length
|
|
})
|
|
|
|
/**
|
|
* Returns the version number of a GHES version string
|
|
* ex: enterprise-server@2.22 => 2.22
|
|
*/
|
|
renderContent.liquid.registerFilter('version_num', input => {
|
|
return input.split('@')[1]
|
|
})
|
|
|
|
/**
|
|
* Convert the input to a slug
|
|
*/
|
|
renderContent.liquid.registerFilter('slugify', input => {
|
|
const slugger = new GithubSlugger()
|
|
return slugger.slug(input)
|
|
})
|
|
|
|
module.exports = renderContent
|