From 5891c7533f500110129fdea7b9b63c8a409da0bd Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 13 May 2022 16:27:37 -0700 Subject: [PATCH] chore: Refactor rule docs format (#15869) * chore: Refactor rule docs format * Fix HTTP -> HTTPS --- docs/.eleventy.js | 2 -- docs/src/_includes/components/docs-toc.html | 4 +-- docs/src/_includes/layouts/doc.html | 29 ++++++++++++++++++++- docs/src/rules/block-scoped-var.md | 8 +++--- docs/src/rules/no-ternary.md | 8 +++--- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/docs/.eleventy.js b/docs/.eleventy.js index 56ce2de99f1..b9e27c8fd7b 100644 --- a/docs/.eleventy.js +++ b/docs/.eleventy.js @@ -126,8 +126,6 @@ module.exports = function(eleventyConfig) { eleventyConfig.addNunjucksAsyncShortcode("link", async function(link) { const { body: html, url } = await got(link); const metadata = await metascraper({ html, url }); - - const encodedURL = encodeURIComponent(link); const the_url = (new URL(link)); // same as url const domain = the_url.hostname; diff --git a/docs/src/_includes/components/docs-toc.html b/docs/src/_includes/components/docs-toc.html index 94e9a6672fe..20befc02d3e 100644 --- a/docs/src/_includes/components/docs-toc.html +++ b/docs/src/_includes/components/docs-toc.html @@ -1,8 +1,8 @@ diff --git a/docs/src/_includes/layouts/doc.html b/docs/src/_includes/layouts/doc.html index b3f301f76ed..b8fbd3b9847 100644 --- a/docs/src/_includes/layouts/doc.html +++ b/docs/src/_includes/layouts/doc.html @@ -13,12 +13,39 @@ {% include 'components/docs-index.html' %} + {# Add in related rules and further reading sections to content so TOC is accurate #} + {% set all_content = content %} + {% if related_rules %} + {% set related_rules_content %} + + {% related_rules related_rules %} + {% endset %} + + {% set all_content = [all_content, related_rules_content] | join %} + {% endif %} + + {% if further_reading %} + {% set further_reading_content %} +

Further Reading

+ {# async shortcodes don't work here so need to manually insert later #} + {% endset %} + + {% set all_content = [all_content, further_reading_content] | join %} + {% endif %} +

{{ title }}

{% include 'components/docs-toc.html' %} - {{ content | safe }} + {{ all_content | safe }} + + {# now insert the async-fetched link data if necessary #} + {% if further_reading %} + {% for url in further_reading %} + {% link url %} + {% endfor %} + {% endif %}