1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-06-28 05:25:11 +00:00

Added some PR talk

This commit is contained in:
2023-06-29 14:37:39 +02:00
parent eba7e84fc8
commit 823ae1328b
10 changed files with 56 additions and 9 deletions

View File

@ -90,10 +90,21 @@ module.exports = function (eleventyConfig) {
});
// Retrieve content of a file
eleventyConfig.addShortcode('filecontent', function (fname, startLine = 0) {
const buf = fs.readFileSync(path.join(indir, fname));
const str = buf.toString().split('\n').slice(startLine).join('\n');
return str;
eleventyConfig.addShortcode('filecontent', function (fname, a, b) {
let str = fs.readFileSync(path.join(indir, fname)).toString();
if (typeof a === 'number') {
// Line indexes
str = str.split('\n').slice(a, b).join('\n');
}
else if (typeof a === 'string') {
// Anchors
const aIndex = str.indexOf(a) + a.length;
const bIndex = b ? str.indexOf(b, aIndex) : undefined;
str = str.slice(aIndex, bIndex);
}
return str.trim();
});
// Global options