-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
BUGFIX: Pages Excluded from Collections
- Loading branch information
Showing
8 changed files
with
94 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tests/fixtures/sample-with-excluded-file/_layouts/default.liquid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div>{{ content }}</div> | ||
<div>{%- for link in backlinks %}<a href="{{ link.url }}">{{ link.title }}</a>{%- endfor %}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: About | ||
layout: default.liquid | ||
--- | ||
|
||
This wikilink to [[something]] will not parse because the destination has eleventyExcludeFromCollections set true. |
12 changes: 12 additions & 0 deletions
12
tests/fixtures/sample-with-excluded-file/eleventy.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = function (eleventyConfig) { | ||
eleventyConfig.addPlugin( | ||
require('../../../index.js'), | ||
); | ||
|
||
return { | ||
dir: { | ||
includes: "_includes", | ||
layouts: "_layouts", | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: Something | ||
layout: default.liquid | ||
eleventyExcludeFromCollections: true | ||
--- | ||
|
||
Hello World, no links, wiki or otherwise will be parsed by the interlinker due to being excluded from collections. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
const path = require("node:path"); | ||
|
||
function normalize(str) { | ||
return str.trim().replace(/\r?\n|\r/g, ''); | ||
} | ||
|
||
function consoleMockMessages(mock) { | ||
let logLines = []; | ||
for (let i = 0; i < mock.callCount; i++) { | ||
const line = normalize(mock.getCall(i).args.join(' ')) | ||
// Sometimes 11ty will output benchmark info, failing the test randomly. | ||
if (line.includes('[11ty]')) continue; | ||
logLines.push(line); | ||
} | ||
return logLines; | ||
} | ||
|
||
function findResultByUrl(results, url) { | ||
const [result] = results.filter(result => result.url === url); | ||
return result; | ||
} | ||
|
||
const fixturePath = (p) => path.normalize(path.join(__dirname, 'fixtures', p)); | ||
|
||
module.exports = { | ||
normalize, | ||
consoleMockMessages, | ||
findResultByUrl, | ||
fixturePath, | ||
} |