Skip to content

Commit 6669413

Browse files
snitin315mdjermanovicnzakas
authored
docs: deploy prerelease docs under the /docs/next/ path (#16541)
* docs: deploy prerelease docs under the `/next` path * docs: deploy prerelease docs under the /docs/next/ path * docs: fix versions list * docs: fix versions page * fix: update docs/.eleventy.js Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * docs: update docs/.eleventy.js Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> * docs: fix lint * docs: show NEXT based on config * docs: update docs/src/_includes/components/nav-version-switcher.html Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
1 parent 2952d6e commit 6669413

6 files changed

Lines changed: 32 additions & 9 deletions

File tree

Makefile.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,18 @@ function generatePrerelease(prereleaseId) {
345345
*/
346346
function publishRelease() {
347347
ReleaseOps.publishRelease();
348+
const releaseInfo = JSON.parse(cat(".eslint-release-info.json"));
349+
const isPreRelease = /[a-z]/u.test(releaseInfo.version);
348350

349-
// push to latest branch to trigger docs deploy
350-
exec("git push origin HEAD:latest -f");
351+
/*
352+
* for a pre-release, push to the "next" branch to trigger docs deploy
353+
* for a release, push to the "latest" branch to trigger docs deploy
354+
*/
355+
if (isPreRelease) {
356+
exec("git push origin HEAD:next -f");
357+
} else {
358+
exec("git push origin HEAD:latest -f");
359+
}
351360

352361
publishSite();
353362
}

docs/.eleventy.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ module.exports = function(eleventyConfig) {
2525
* it's easier to see if URLs are broken.
2626
*
2727
* When a release is published, HEAD is pushed to the "latest" branch.
28-
* Netlify deploys that branch as well, and in that case, we want the
29-
* docs to be loaded from /docs/latest on eslint.org.
28+
* When a pre-release is published, HEAD is pushed to the "next" branch.
29+
* Netlify deploys those branches as well, and in that case, we want the
30+
* docs to be loaded from /docs/latest or /docs/next on eslint.org.
3031
*
3132
* The path prefix is turned off for deploy previews so we can properly
3233
* see changes before deployed.
@@ -38,6 +39,8 @@ module.exports = function(eleventyConfig) {
3839
pathPrefix = "/";
3940
} else if (process.env.BRANCH === "latest") {
4041
pathPrefix = "/docs/latest/";
42+
} else if (process.env.BRANCH === "next") {
43+
pathPrefix = "/docs/next/";
4144
}
4245

4346
//------------------------------------------------------------------------------
@@ -49,6 +52,7 @@ module.exports = function(eleventyConfig) {
4952

5053
eleventyConfig.addGlobalData("site_name", siteName);
5154
eleventyConfig.addGlobalData("GIT_BRANCH", process.env.BRANCH);
55+
eleventyConfig.addGlobalData("HEAD", process.env.BRANCH === "main");
5256
eleventyConfig.addGlobalData("NOINDEX", process.env.BRANCH !== "latest");
5357
eleventyConfig.addDataExtension("yml", contents => yaml.load(contents));
5458

docs/src/_data/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"lang": "en",
3-
"version": "7.26.0"
3+
"version": "7.26.0",
4+
"showNextVersion": false
45
}

docs/src/_includes/components/nav-version-switcher.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
<span class="label__text">Version</span>
1313
</label>
1414
<select name="version selector" id="nav-version-select" aria-describedby="nav-version-infobox" class="c-custom-select switcher__select auto-switcher">
15-
<option value="HEAD" data-url="/docs/head/" {% if GIT_BRANCH !="latest" %}selected{% endif %}>HEAD</option>
16-
<option value="{{ eslintVersion }}" data-url="/docs/latest/" {% if GIT_BRANCH=="latest" %}selected{% endif %}>v{{ eslintVersion }}</option>
15+
<option value="HEAD" data-url="/docs/head/" {% if HEAD %}selected{% endif %}>HEAD</option>
16+
{% if config.showNextVersion == true %}
17+
<option value="NEXT" data-url="/docs/next/" {% if GIT_BRANCH == "next" %}selected{% endif %}>NEXT</option>
18+
{% endif %}
19+
<option value="{{ eslintVersion }}" data-url="/docs/latest/" {% if GIT_BRANCH == "latest" %}selected{% endif %}>v{{ eslintVersion }}</option>
1720
{% for version in versions.items %}
1821
<option value="{{ version.number }}"
1922
data-url="{{ version.url }}">

docs/src/_includes/components/version-switcher.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
<span class="label__text">Version</span>
1313
</label>
1414
<select name="version selector" id="version-select" aria-describedby="version-infobox" class="c-custom-select switcher__select auto-switcher">
15-
<option value="HEAD" data-url="/docs/head/" {% if GIT_BRANCH != "latest" %}selected{% endif %}>HEAD</option>
15+
<option value="HEAD" data-url="/docs/head/" {% if HEAD %}selected{% endif %}>HEAD</option>
16+
{% if config.showNextVersion == true %}
17+
<option value="NEXT" data-url="/docs/next/" {% if GIT_BRANCH=="next" %}selected{% endif %}>NEXT</option>
18+
{% endif %}
1619
<option value="{{ eslintVersion }}" data-url="/docs/latest/" {% if GIT_BRANCH == "latest" %}selected{% endif %}>v{{ eslintVersion }}</option>
1720
{% for version in versions.items %}
1821
<option value="{{ version.number }}"

docs/src/_includes/partials/versions-list.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<ul class="versions-list">
2-
<li><a href="/docs/head/" {% if GIT_BRANCH != "latest" %} data-current="true" {% endif %}>HEAD</a></li>
2+
<li><a href="/docs/head/" {% if HEAD %} data-current="true" {% endif %}>HEAD</a></li>
3+
{% if config.showNextVersion == true %}
4+
<li><a href="/docs/next/" {% if GIT_BRANCH == "next" %} data-current="true" {% endif %}>NEXT</a></li>
5+
{% endif %}
36
<li><a href="/docs/latest/" {% if GIT_BRANCH == "latest" %} data-current="true" {% endif %}>v{{ eslintVersion }}</a></li>
47
{%- for version in versions.items -%}
58
<li><a href="{{ version.url }}">v{{ version.number }}</a></li>

0 commit comments

Comments
 (0)