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 24
24
},
25
25
"devDependencies" : {
26
26
"@11ty/eleventy" : " ^2.0.1" ,
27
+ "@11ty/eleventy-fetch" : " ^4.0.0" ,
27
28
"@11ty/eleventy-img" : " ^3.1.1" ,
28
29
"@11ty/eleventy-navigation" : " ^0.3.5" ,
29
30
"@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 14
14
< select name ="version selector " id ="nav-version-select " aria-describedby ="nav-version-infobox " class ="c-custom-select switcher__select auto-switcher ">
15
15
< option value ="HEAD " data-url ="/docs/head/ " {% if HEAD %}selected{% endif %} > HEAD</ option >
16
16
{% 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 >
18
18
{% endif %}
19
19
< option value ="{{ eslintVersion }} " data-url ="/docs/latest/ " {% if GIT_BRANCH == "latest " %}selected{% endif %} > v{{ eslintVersion }}</ option >
20
20
{% for version in versions.items %}
Original file line number Diff line number Diff line change 14
14
< select name ="version selector " id ="version-select " aria-describedby ="version-infobox " class ="c-custom-select switcher__select auto-switcher ">
15
15
< option value ="HEAD " data-url ="/docs/head/ " {% if HEAD %}selected{% endif %} > HEAD</ option >
16
16
{% 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 >
18
18
{% endif %}
19
19
< option value ="{{ eslintVersion }} " data-url ="/docs/latest/ " {% if GIT_BRANCH == "latest " %}selected{% endif %} > v{{ eslintVersion }}</ option >
20
20
{% for version in versions.items %}
Original file line number Diff line number Diff line change 1
1
< ul class ="versions-list ">
2
2
< li > < a href ="/docs/head/ " {% if HEAD %} data-current ="true " {% endif %} > HEAD</ a > </ li >
3
3
{% 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 >
5
5
{% endif %}
6
6
< li > < a href ="/docs/latest/ " {% if GIT_BRANCH == "latest " %} data-current ="true " {% endif %} > v{{ eslintVersion }}</ a > </ li >
7
7
{%- for version in versions.items -%}
You can’t perform that action at this time.
0 commit comments