From 66694136b67277c050bd27f60050779687a88c9f Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 11 Jan 2023 23:56:46 +0530 Subject: [PATCH] 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 * docs: update docs/.eleventy.js Co-authored-by: Nicholas C. Zakas * docs: fix lint * docs: show NEXT based on config * docs: update docs/src/_includes/components/nav-version-switcher.html Co-authored-by: Milos Djermanovic Co-authored-by: Nicholas C. Zakas --- Makefile.js | 13 +++++++++++-- docs/.eleventy.js | 8 ++++++-- docs/src/_data/config.json | 3 ++- .../_includes/components/nav-version-switcher.html | 7 +++++-- docs/src/_includes/components/version-switcher.html | 5 ++++- docs/src/_includes/partials/versions-list.html | 5 ++++- 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Makefile.js b/Makefile.js index f74c8c44e97..4bf2c580645 100644 --- a/Makefile.js +++ b/Makefile.js @@ -345,9 +345,18 @@ function generatePrerelease(prereleaseId) { */ function publishRelease() { ReleaseOps.publishRelease(); + const releaseInfo = JSON.parse(cat(".eslint-release-info.json")); + const isPreRelease = /[a-z]/u.test(releaseInfo.version); - // push to latest branch to trigger docs deploy - exec("git push origin HEAD:latest -f"); + /* + * for a pre-release, push to the "next" branch to trigger docs deploy + * for a release, push to the "latest" branch to trigger docs deploy + */ + if (isPreRelease) { + exec("git push origin HEAD:next -f"); + } else { + exec("git push origin HEAD:latest -f"); + } publishSite(); } diff --git a/docs/.eleventy.js b/docs/.eleventy.js index 374ab1b93e5..01801d389e3 100644 --- a/docs/.eleventy.js +++ b/docs/.eleventy.js @@ -25,8 +25,9 @@ module.exports = function(eleventyConfig) { * it's easier to see if URLs are broken. * * When a release is published, HEAD is pushed to the "latest" branch. - * Netlify deploys that branch as well, and in that case, we want the - * docs to be loaded from /docs/latest on eslint.org. + * When a pre-release is published, HEAD is pushed to the "next" branch. + * Netlify deploys those branches as well, and in that case, we want the + * docs to be loaded from /docs/latest or /docs/next on eslint.org. * * The path prefix is turned off for deploy previews so we can properly * see changes before deployed. @@ -38,6 +39,8 @@ module.exports = function(eleventyConfig) { pathPrefix = "/"; } else if (process.env.BRANCH === "latest") { pathPrefix = "/docs/latest/"; + } else if (process.env.BRANCH === "next") { + pathPrefix = "/docs/next/"; } //------------------------------------------------------------------------------ @@ -49,6 +52,7 @@ module.exports = function(eleventyConfig) { eleventyConfig.addGlobalData("site_name", siteName); eleventyConfig.addGlobalData("GIT_BRANCH", process.env.BRANCH); + eleventyConfig.addGlobalData("HEAD", process.env.BRANCH === "main"); eleventyConfig.addGlobalData("NOINDEX", process.env.BRANCH !== "latest"); eleventyConfig.addDataExtension("yml", contents => yaml.load(contents)); diff --git a/docs/src/_data/config.json b/docs/src/_data/config.json index 4acb4820247..9bd751d1809 100644 --- a/docs/src/_data/config.json +++ b/docs/src/_data/config.json @@ -1,4 +1,5 @@ { "lang": "en", - "version": "7.26.0" + "version": "7.26.0", + "showNextVersion": false } diff --git a/docs/src/_includes/components/nav-version-switcher.html b/docs/src/_includes/components/nav-version-switcher.html index f4e0f5fe025..a01e5ddf30c 100644 --- a/docs/src/_includes/components/nav-version-switcher.html +++ b/docs/src/_includes/components/nav-version-switcher.html @@ -12,8 +12,11 @@ Version - + + {% if config.showNextVersion == true %} + + {% endif %} {% for version in versions.items %}