File tree Expand file tree Collapse file tree 5 files changed +36
-3
lines changed Expand file tree Collapse file tree 5 files changed +36
-3
lines changed Original file line number Diff line number Diff line change 2424 },
2525 "devDependencies" : {
2626 "@11ty/eleventy" : " ^2.0.1" ,
27+ "@11ty/eleventy-fetch" : " ^4.0.0" ,
2728 "@11ty/eleventy-img" : " ^3.1.1" ,
2829 "@11ty/eleventy-navigation" : " ^0.3.5" ,
2930 "@11ty/eleventy-plugin-rss" : " ^1.1.1" ,
Original file line number Diff line number Diff line change 1+ /**
2+ * @fileoverview
3+ * @author Nicholas C. Zakas
4+ */
5+
6+ //-----------------------------------------------------------------------------
7+ // Requirements
8+ //-----------------------------------------------------------------------------
9+
10+ const eleventyFetch = require ( "@11ty/eleventy-fetch" ) ;
11+
12+ //-----------------------------------------------------------------------------
13+ // Exports
14+ //-----------------------------------------------------------------------------
15+
16+ module . exports = async function ( ) {
17+
18+ // if we're on the next branch, we can just read the package.json file
19+ if ( process . env . BRANCH === "next" ) {
20+ return require ( "../../package.json" ) . version ;
21+ }
22+
23+ // otherwise, we need to fetch the latest version from the GitHub API
24+ const url = "https://raw.githubusercontent.com/eslint/eslint/next/docs/package.json" ;
25+
26+ const response = await eleventyFetch ( url , {
27+ duration : "1d" ,
28+ type : "json"
29+ } ) ;
30+
31+ return response . version ;
32+ }
Original file line number Diff line number Diff line change 1414 < select name ="version selector " id ="nav-version-select " aria-describedby ="nav-version-infobox " class ="c-custom-select switcher__select auto-switcher ">
1515 < option value ="HEAD " data-url ="/docs/head/ " {% if HEAD %}selected{% endif %} > HEAD</ option >
1616 {% if config.showNextVersion == true %}
17- < option value ="NEXT " data-url ="/docs/next/ " {% if GIT_BRANCH == "next " %}selected{% endif %} > NEXT </ option >
17+ < option value ="{{ eslintNextVersion }} " data-url ="/docs/next/ " {% if GIT_BRANCH == "next " %}selected{% endif %} > v{{ eslintNextVersion }} </ option >
1818 {% endif %}
1919 < option value ="{{ eslintVersion }} " data-url ="/docs/latest/ " {% if GIT_BRANCH == "latest " %}selected{% endif %} > v{{ eslintVersion }}</ option >
2020 {% for version in versions.items %}
Original file line number Diff line number Diff line change 1414 < select name ="version selector " id ="version-select " aria-describedby ="version-infobox " class ="c-custom-select switcher__select auto-switcher ">
1515 < option value ="HEAD " data-url ="/docs/head/ " {% if HEAD %}selected{% endif %} > HEAD</ option >
1616 {% if config.showNextVersion == true %}
17- < option value ="NEXT " data-url ="/docs/next/ " {% if GIT_BRANCH =="next " %}selected{% endif %} > NEXT </ option >
17+ < option value ="{{ eslintNextVersion }} " data-url ="/docs/next/ " {% if GIT_BRANCH =="next " %}selected{% endif %} > v{{ eslintNextVersion }} </ option >
1818 {% endif %}
1919 < option value ="{{ eslintVersion }} " data-url ="/docs/latest/ " {% if GIT_BRANCH == "latest " %}selected{% endif %} > v{{ eslintVersion }}</ option >
2020 {% for version in versions.items %}
Original file line number Diff line number Diff line change 11< ul class ="versions-list ">
22 < li > < a href ="/docs/head/ " {% if HEAD %} data-current ="true " {% endif %} > HEAD</ a > </ li >
33 {% if config.showNextVersion == true %}
4- < li > < a href ="/docs/next/ " {% if GIT_BRANCH == "next " %} data-current ="true " {% endif %} > NEXT </ a > </ li >
4+ < li > < a href ="/docs/next/ " {% if GIT_BRANCH == "next " %} data-current ="true " {% endif %} > v{{ eslintNextVersion }} </ a > </ li >
55 {% endif %}
66 < li > < a href ="/docs/latest/ " {% if GIT_BRANCH == "latest " %} data-current ="true " {% endif %} > v{{ eslintVersion }}</ a > </ li >
77 {%- for version in versions.items -%}
You can’t perform that action at this time.
0 commit comments