Make files template use commonPage

3700da2f6e5c038799adc556549748805c4b5545

Tucker McKnight <tucker@pangolin.lan> | Sun Feb 22 2026

Make files template use commonPage
js_templates/files.ts:1
Before
0
1
2

3
4
5
6
7
8
9
10
11
12
import m from 'mithril'
import { type SortedFileList, type Repository } from "../src/dataTypes.ts"

⁣
export default async (eleventyConfig: any, data: any) => {
  const branch: Repository['branches'][0] = data.currentBranch
  const topLevelFilesOnly = eleventyConfig.getFilter("topLevelFilesOnly")
  const slugify = eleventyConfig.getFilter("slugify")

  const files: SortedFileList = topLevelFilesOnly(branch.fileList, '')

  return [
    m('div', {class: "row mt-3 mb-1"}, [
      m('div', {class: "col"},
        m('p', [
After
0
1
2
3
4
5
6
7
8
9
10
11
12
13
import m from 'mithril'
import { type SortedFileList, type Repository } from "../src/dataTypes.ts"
import htmlPage from './common/htmlPage.ts'

export default async (reposConfig: any, eleventyConfig: any, data: any) => {
  const branch: Repository['branches'][0] = data.currentBranch
  const topLevelFilesOnly = eleventyConfig.getFilter("topLevelFilesOnly")
  const slugify = eleventyConfig.getFilter("slugify")

  const files: SortedFileList = topLevelFilesOnly(branch.fileList, '')

  const pageContent = [
    m('div', {class: "row mt-3 mb-1"}, [
      m('div', {class: "col"},
        m('p', [
js_templates/files.ts:37
Before
36
37
38

      ])
    }))
  ]
⁣
⁣
}
After
36
37
38
39
40
      ])
    }))
  ]

  return await htmlPage(reposConfig, eleventyConfig, data, pageContent)
}
main.ts:14
Before
13
14
15
16
17
18
import ConfigSchema from './schemas/ReposConfiguration.json' with { type: 'json' }
import commonPage from './js_templates/common/commonPage.ts'
import repoJsTemplate from './js_templates/repo.ts'
// import filesJsTemplate from './js_templates/files.ts'
import fileJsTemplate from './js_templates/file.ts'
import commitJsTemplate from './js_templates/commit.ts'
// import commitsJsTemplate from './js_templates/commits.ts'
After
13
14
15
16
17
18
import ConfigSchema from './schemas/ReposConfiguration.json' with { type: 'json' }
import commonPage from './js_templates/common/commonPage.ts'
import repoJsTemplate from './js_templates/repo.ts'
import filesJsTemplate from './js_templates/files.ts'
import fileJsTemplate from './js_templates/file.ts'
import commitJsTemplate from './js_templates/commit.ts'
// import commitsJsTemplate from './js_templates/commits.ts'
main.ts:367
Before
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
  )

  // FILES.TS
  // eleventyConfig.addTemplate(
  //   'repos/files.11ty.js',
  //   htmlPage(reposConfiguration, eleventyConfig, filesJsTemplate),
  //   {
  //     pagination: {
  //       data: "branches",
  //       size: 1,
  //       alias: "branchInfo",
  //     },
  //     permalink: (data) => {
  //       const repoName = data.branchInfo.repoName
  //       const branchName = data.branchInfo.branchName
  //       return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branchName)}/files/`
  //     },
  //     eleventyComputed: {
  //       nav: {
  //         repoName: (data) => data.branchInfo.repoName,
  //         branchName: (data) => data.branchInfo.branchName,
  //         path: "files",
  //       },
  //       currentRepo: (data) => reposData.find(repo => {
  //         return repo.name === data.branchInfo.repoName
  //       }),
  //       currentBranch: (data) => reposData.find(repo => {
  //         return repo.name === data.branchInfo.repoName
  //       }).branches.find(branch => {
  //         return branch.name === data.branchInfo.branchName
  //       })
  //     },
  //     navTab: "files",
  //   }
  // )

  // REPO.TS
  eleventyConfig.addTemplate(
After
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
  )

  // FILES.TS
  eleventyConfig.addTemplate(
    'repos/files.11ty.js',
    commonPage(filesJsTemplate, reposConfiguration, eleventyConfig),
    {
      pagination: {
        data: "branches",
        size: 1,
        alias: "branchInfo",
      },
      permalink: (data) => {
        const repoName = data.branchInfo.repoName
        const branchName = data.branchInfo.branchName
        return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branchName)}/files/`
      },
      eleventyComputed: {
        nav: {
          repoName: (data) => data.branchInfo.repoName,
          branchName: (data) => data.branchInfo.branchName,
          path: "files",
        },
        currentRepo: (data) => reposData.find(repo => {
          return repo.name === data.branchInfo.repoName
        }),
        currentBranch: (data) => reposData.find(repo => {
          return repo.name === data.branchInfo.repoName
        }).branches.find(branch => {
          return branch.name === data.branchInfo.branchName
        })
      },
      navTab: "files",
    }
  )

  // REPO.TS
  eleventyConfig.addTemplate(