Tucker McKnight <tucker@pangolin.lan> | Sun Oct 12 2025
Add a "raw" file template, which shows the plain text of a file Add a link to said raw file when viewing the file in the Files tab. Also remove an unnecessary "async" from a filter that was not async. Also .gitignore the docs directory, which gets generated when `npm run build` is run.
1 2
node_modules
example_site/node_modules
example_site/_site1 2 3
node_modules
example_site/node_modules
example_site/_site
docs200 201 202 203 204 205
return repoOperations[config._type].getFileLastTouchInfo(repo, branch, filename, location)
})
eleventyConfig.addAsyncFilter("isDirectory", async(filename, repoName, branchName) => {
const files = reposData[repoName].branches[branchName].files
const isDirectory = files.some((testFile) => {
return testFile.startsWith(filename + '/') && (testFile !== filename)200 201 202 203 204 205
return repoOperations[config._type].getFileLastTouchInfo(repo, branch, filename, location)
})
eleventyConfig.addFilter("isDirectory", (filename, repoName, branchName) => {
const files = reposData[repoName].branches[branchName].files
const isDirectory = files.some((testFile) => {
return testFile.startsWith(filename + '/') && (testFile !== filename)321 322 323 324 325
}
)
// FILES.NJK
const filesTemplate = fsImport.readFileSync(`${import.meta.dirname}/templates/files.njk`).toString()
eleventyConfig.addTemplate(321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
}
)
// RAW.NJK
const rawTemplate = fsImport.readFileSync(`${import.meta.dirname}/templates/raw.njk`).toString()
eleventyConfig.addTemplate(
'repos/raw.njk',
rawTemplate,
{
pagination: {
data: "flatFiles",
size: 1,
alias: "fileInfo",
},
eleventyAllowMissingExtension: true,
flatFiles: flatFilesData,
permalink: (data) => {
const repoName = data.fileInfo.repoName
const branchName = data.fileInfo.branchName
return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branchName)}/raw/${eleventyConfig.getFilter("slugify")(data.fileInfo.file)}`
},
}
)
// FILES.NJK
const filesTemplate = fsImport.readFileSync(`${import.meta.dirname}/templates/files.njk`).toString()
eleventyConfig.addTemplate(14 15 16 17 18 19 20 21 22 23 24
</ul>
{% else %}
<div class="row py-2">
<div class="col">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="showLastTouch">
<label class="form-check-label" for="showLastTouch">Show last line change</label>
</div>
</div>
</div>
<div class="row">
<div class="col-auto border-end">14 15 16 17 18 19 20 21 22 23 24 25 26 27
</ul>
{% else %}
<div class="row py-2">
<div class="col-auto">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="showLastTouch">
<label class="form-check-label" for="showLastTouch">Show last line change</label>
</div>
</div>
<div class="col">
<a href="{{reposPath}}/{{fileInfo.repoName | slugify}}/branches/{{fileInfo.branchName | slugify}}/raw/{{fileInfo.file | slugify}}">View raw file</a>
</div>
</div>
<div class="row">
<div class="col-auto border-end">