File tree Expand file tree Collapse file tree 5 files changed +19
-2
lines changed
Expand file tree Collapse file tree 5 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -37,14 +37,15 @@ module.exports = function(eleventyConfig) {
3737 */
3838
3939 let pathPrefix = "/docs/head/" ;
40+ const isNumberVersion = process . env . BRANCH && / ^ v \d + \. x $ / u. test ( process . env . BRANCH ) ;
4041
4142 if ( process . env . CONTEXT === "deploy-preview" ) {
4243 pathPrefix = "/" ;
4344 } else if ( process . env . BRANCH === "latest" ) {
4445 pathPrefix = "/docs/latest/" ;
4546 } else if ( process . env . BRANCH === "next" ) {
4647 pathPrefix = "/docs/next/" ;
47- } else if ( process . env . BRANCH && / ^ v \d + \. x $ / u . test ( process . env . BRANCH ) ) {
48+ } else if ( isNumberVersion ) {
4849 pathPrefix = `/docs/${ process . env . BRANCH } /` ; // `/docs/v8.x/`, `/docs/v9.x/`, `/docs/v10.x/` ...
4950 }
5051
@@ -60,6 +61,7 @@ module.exports = function(eleventyConfig) {
6061 eleventyConfig . addGlobalData ( "HEAD" , process . env . BRANCH === "main" ) ;
6162 eleventyConfig . addGlobalData ( "NOINDEX" , process . env . BRANCH !== "latest" ) ;
6263 eleventyConfig . addGlobalData ( "PATH_PREFIX" , pathPrefix ) ;
64+ eleventyConfig . addGlobalData ( "is_number_version" , isNumberVersion ) ;
6365 eleventyConfig . addDataExtension ( "yml" , contents => yaml . load ( contents ) ) ;
6466
6567 //------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ module.exports = async function() {
3131 const { items } = data ;
3232
3333 let foundItemForThisBranch = false ;
34+ let isPrereleasePhase = false ;
3435
3536 for ( const item of items ) {
3637 const isItemForThisBranch = item . branch === thisBranch ;
@@ -54,6 +55,10 @@ module.exports = async function() {
5455 if ( isItemForThisBranch ) {
5556 item . selected = true ;
5657 }
58+
59+ if ( item . branch === "next" ) {
60+ isPrereleasePhase = true ;
61+ }
5762 }
5863
5964 // Add an empty item if this is not a production branch
@@ -67,5 +72,7 @@ module.exports = async function() {
6772 } ) ;
6873 }
6974
75+ data . isPrereleasePhase = isPrereleasePhase ;
76+
7077 return data ;
7178} ;
Original file line number Diff line number Diff line change @@ -121,4 +121,5 @@ footer:
121121
122122edit_link :
123123 start_with : https://github.com/eslint/eslint/edit/main/docs/
124+ start_with_latest : https://github.com/eslint/eslint/edit/latest/docs/
124125 text : Edit this page
Original file line number Diff line number Diff line change @@ -119,4 +119,5 @@ footer:
119119
120120edit_link :
121121 start_with : https://github.com/eslint/eslint/edit/main/docs/
122+ start_with_latest : https://github.com/eslint/eslint/edit/latest/docs/
122123 text : 编辑此页
Original file line number Diff line number Diff line change @@ -102,7 +102,13 @@ <h1>{{ title }}</h1>
102102 {% if edit_link %}
103103 {{ edit_link }}
104104 {% else %}
105- {{ site.edit_link.start_with }}{{ page.inputPath }}
105+ {% if eslintVersions.isPrereleasePhase and GIT_BRANCH === 'latest' %}
106+ {{ site.edit_link.start_with_latest }}{{ page.inputPath }}
107+ {% elseif is_number_version %}
108+ https://github.com/eslint/eslint/edit/{{ GIT_BRANCH }}/docs/{{ page.inputPath }}
109+ {% else %}
110+ {{ site.edit_link.start_with }}{{ page.inputPath }}
111+ {% endif %}
106112 {% endif %}
107113 "
108114 class ="c-btn c-btn--secondary "> {{ site.edit_link.text }}</ a >
You can’t perform that action at this time.
0 commit comments