Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix absolute paths in related rules shortcode to work from /docs #15892

Merged
merged 1 commit into from May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions docs/.eleventy.js
Expand Up @@ -25,6 +25,15 @@ const {
module.exports = function(eleventyConfig) {
let now = new Date();

/*
* The site is loaded from /docs on eslint.org and so we need to adjust
* the path prefix so URLs are evaluated correctly.
*
* The path prefix is turned off for deploy previews so we can properly
* see changes before deployed.
*/
const pathPrefix = process.env.CONTEXT === "deploy-preview" ? "" : "/docs";

/*****************************************************************************************
* Filters
* ***************************************************************************************/
Expand Down Expand Up @@ -180,7 +189,7 @@ module.exports = function(eleventyConfig) {

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

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

markdownTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
Expand Down