Skip to content

Commit 36287c0

Browse files
authored
docs: fix absolute paths in related rules shortcode to work from /docs (#15892)
1 parent 90b6990 commit 36287c0

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

docs/.eleventy.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ const {
2525
module.exports = function(eleventyConfig) {
2626
let now = new Date();
2727

28+
/*
29+
* The site is loaded from /docs on eslint.org and so we need to adjust
30+
* the path prefix so URLs are evaluated correctly.
31+
*
32+
* The path prefix is turned off for deploy previews so we can properly
33+
* see changes before deployed.
34+
*/
35+
const pathPrefix = process.env.CONTEXT === "deploy-preview" ? "" : "/docs";
36+
2837
/*****************************************************************************************
2938
* Filters
3039
* ***************************************************************************************/
@@ -180,7 +189,7 @@ module.exports = function(eleventyConfig) {
180189

181190
rules.forEach(function(rule) {
182191
let list_item = `<li class="related-rules__list__item">
183-
<a href="/rules/${rule}">
192+
<a href="${pathPrefix}/rules/${rule}">
184193
<span>${rule}</span>
185194
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false">
186195
<path d="M5 12H19M19 12L12 5M19 12L12 19" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
@@ -343,14 +352,7 @@ module.exports = function(eleventyConfig) {
343352
return {
344353
passthroughFileCopy: true,
345354

346-
/*
347-
* The site is loaded from /docs on eslint.org and so we need to adjust
348-
* the path prefix so URLs are evaluated correctly.
349-
*
350-
* The path prefix is turned off for deploy previews so we can properly
351-
* see changes before deployed.
352-
*/
353-
pathPrefix: process.env.CONTEXT === "deploy-preview" ? "" : "/docs",
355+
pathPrefix,
354356

355357
markdownTemplateEngine: 'njk',
356358
dataTemplateEngine: 'njk',

0 commit comments

Comments
 (0)