Skip to content

Commit 52c40cd

Browse files
get prerelease info from eslintVersion,js
1 parent 17db95f commit 52c40cd

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

docs/.eleventy.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,11 @@ module.exports = function(eleventyConfig) {
5656
// Load site-specific data
5757
const siteName = process.env.ESLINT_SITE_NAME || "en";
5858

59-
/**
60-
* Determines whether we are in the prerelease phase.
61-
* @returns {Promise<boolean>} `true` if there is a prerelease of the next major version, `false` otherwise.
62-
*/
63-
async function isPrereleasePhase() {
64-
const eslintVersions = await require("./src/_data/eslintVersions")();
65-
66-
return eslintVersions.items.some(item => item.branch === "next");
67-
}
68-
6959
eleventyConfig.addGlobalData("site_name", siteName);
7060
eleventyConfig.addGlobalData("GIT_BRANCH", process.env.BRANCH);
7161
eleventyConfig.addGlobalData("HEAD", process.env.BRANCH === "main");
7262
eleventyConfig.addGlobalData("NOINDEX", process.env.BRANCH !== "latest");
7363
eleventyConfig.addGlobalData("PATH_PREFIX", pathPrefix);
74-
eleventyConfig.addGlobalData("is_prerelease_phase", isPrereleasePhase);
7564
eleventyConfig.addGlobalData("is_number_version", isNumberVersion);
7665
eleventyConfig.addDataExtension("yml", contents => yaml.load(contents));
7766

docs/src/_data/eslintVersions.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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
};

docs/src/_includes/layouts/doc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ <h1>{{ title }}</h1>
102102
{% if edit_link %}
103103
{{ edit_link }}
104104
{% else %}
105-
{% if is_prerelease_phase and GIT_BRANCH === 'latest' %}
105+
{% if eslintVersions.isPrereleasePhase and GIT_BRANCH === 'latest' %}
106106
{{ site.edit_link.start_with_latest }}{{ page.inputPath }}
107107
{% elseif is_number_version %}
108108
https://github.com/eslint/eslint/edit/{{ GIT_BRANCH }}/docs/{{ page.inputPath }}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy