Skip to content

Commit b356efe

Browse files
apply suggestion
1 parent 779a935 commit b356efe

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

docs/.eleventy.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,23 @@ module.exports = function(eleventyConfig) {
5555
// Load site-specific data
5656
const siteName = process.env.ESLINT_SITE_NAME || "en";
5757

58-
// Current version of ESLint
59-
const currentVersion = require("../package.json").version;
60-
6158
/**
6259
* Determines whether the given version is a prerelease.
63-
* @param {string} version The version to check.
6460
* @returns {boolean} `true` if it is a prerelease, `false` otherwise.
6561
*/
66-
function isPreRelease(version) {
67-
return /[a-z]/u.test(version);
62+
async function isPreRelease() {
63+
const eslintVersions = await require("./src/_data/eslintVersions")();
64+
65+
return eslintVersions.items.some(item => item.branch === "next");
6866
}
6967

7068
eleventyConfig.addGlobalData("site_name", siteName);
7169
eleventyConfig.addGlobalData("GIT_BRANCH", process.env.BRANCH);
7270
eleventyConfig.addGlobalData("HEAD", process.env.BRANCH === "main");
7371
eleventyConfig.addGlobalData("NOINDEX", process.env.BRANCH !== "latest");
7472
eleventyConfig.addGlobalData("PATH_PREFIX", pathPrefix);
75-
eleventyConfig.addGlobalData("is_pre_release", isPreRelease(currentVersion));
73+
eleventyConfig.addGlobalData("is_pre_release", isPreRelease);
74+
eleventyConfig.addGlobalData("is_number_version", process.env.BRANCH && /^v\d+\.x$/u.test(process.env.BRANCH));
7675
eleventyConfig.addDataExtension("yml", contents => yaml.load(contents));
7776

7877
//------------------------------------------------------------------------------

docs/src/_includes/layouts/doc.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,10 @@ <h1>{{ title }}</h1>
102102
{% if edit_link %}
103103
{{ edit_link }}
104104
{% else %}
105-
{% if is_pre_release %}
106-
{% if PATH_PREFIX === '/docs/latest/' %}
107-
{{ site.edit_link.start_with_latest }}{{ page.inputPath }}
108-
{% else %}
109-
{{ site.edit_link.start_with }}{{ page.inputPath }}
110-
{% endif %}
105+
{% if is_pre_release 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 }}
111109
{% else %}
112110
{{ site.edit_link.start_with }}{{ page.inputPath }}
113111
{% endif %}

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