Make sure directories are included in the pagination date for files.ts

d716589af234cc36896fdf5c04f25c5dba10fc1b

Tucker McKnight <tucker@pangolin.lan> | Sun Jun 28 2026

Make sure directories are included in the pagination date for files.ts

Also some URL fixes and changing the width of the boxes on the index page.

Directories are now found in a separate function call from files, so that they
can be added to the pagination data on the files page (since every directory
should have its own HTML page for files), but omitted from the raw.ts page
(since only actual files need the raw output).
js_templates/file.ts:32
Before
31
32
33
34
35
36
      m('div', {class: "col"},
        m('h3', [
          m('span', {class: "bezel-gray p-1 my-1 d-inline-block"},
            m('a', {href: `${data.reposPath}/${fileInfo.repoName}/${fileInfo.type}/${fileInfo.refName}/files`}, './')
          ),
          fileInfo.file.split('/').map((dir, index, arr) => {
            if (index === arr.length - 1) {
After
31
32
33
34
35
36
      m('div', {class: "col"},
        m('h3', [
          m('span', {class: "bezel-gray p-1 my-1 d-inline-block"},
            m('a', {href: `${data.reposPath}/${slugify(fileInfo.repoName)}/${fileInfo.type}/${slugify(fileInfo.refName)}/files`}, './')
          ),
          fileInfo.file.split('/').map((dir, index, arr) => {
            if (index === arr.length - 1) {
js_templates/file.ts:41
Before
40
41
42
43
44
45
46
47
48
49
50
51
52
            else {
              return m('span', {class: "bezel-gray p-1 my-1 d-inline-block"}, [
                m('a', {
                  href: `${data.reposPath}/${fileInfo.repoName}/${fileInfo.type}/${fileInfo.refName}/files/${arr.slice(0, index + 1).map((part) => slugify(part)).join('/')}.html`}, `${dir}/`)
              ])
            }
          })
        ])
      )
    ),
    (isDirectory(fileInfo.file, fileInfo.repoName, fileInfo.refName, fileInfo.type) ?
      m('div', {class: "row"},
        m('div', {class: "col"},
          m('ul', {class: "list-group"},
After
40
41
42
43
44
45
46
47
48
49
50
51
52
            else {
              return m('span', {class: "bezel-gray p-1 my-1 d-inline-block"}, [
                m('a', {
                  href: `${data.reposPath}/${slugify(fileInfo.repoName)}/${fileInfo.type}/${slugify(fileInfo.refName)}/files/${arr.slice(0, index + 1).map((part) => slugify(part)).join('/')}`}, `${dir}/`)
              ])
            }
          })
        ])
      )
    ),
    (fileInfo.isDirectory ?
      m('div', {class: "row"},
        m('div', {class: "col"},
          m('ul', {class: "list-group"},
js_templates/file.ts:60
Before
59
60
61
62
63
64
                    return pathPart.split('.').map((subPart) => {
                      return slugify(subPart)
                    }).join('.')
                  }).join('/')}.html`},
                  getRelativePath(fileInfo.file, dir.name)
                )
              ])
After
59
60
61
62
63
64
                    return pathPart.split('.').map((subPart) => {
                      return slugify(subPart)
                    }).join('.')
                  }).join('/')}`},
                  getRelativePath(fileInfo.file, dir.name)
                )
              ])
js_templates/index.ts:13
Before
12
13
14
15
16
17
    m('div', {class: "row d-flex flex-wrap"},
      data.repos.map((repo) => {
        return (
          m('div', {class: "col", style: "flex-basis: 50%; max-width: 50%;"},
            m('div', {class: "my-2 card bezel-gray flex-grow-1"},
              m('div', {class: "card-header"},
                m('a', {class: "card-title fs-5", href: `${data.reposPath}/${slugify(repo.name)}`}, repo.name)
After
12
13
14
15
16
17
    m('div', {class: "row d-flex flex-wrap"},
      data.repos.map((repo) => {
        return (
          m('div', {class: "col", style: "flex-basis: 30rem;"},
            m('div', {class: "my-2 card bezel-gray flex-grow-1"},
              m('div', {class: "card-header"},
                m('a', {class: "card-title fs-5", href: `${data.reposPath}/${slugify(repo.name)}`}, repo.name)
main.ts:3
Before
2
3
4
5
6
7
import childProcess from 'child_process'
import {repos, getBranchesAndTags} from './src/repos.ts'
import getFlatRefs from './src/flatRefs.ts'
import flatFiles from './src/flatFiles.ts'
import flatPatches from './src/flatPatches.ts'
import paginatedPatches, {type PatchPage} from './src/paginatedPatches.ts'
import {getLocation} from './src/helpers.ts'
After
2
3
4
5
6
7
import childProcess from 'child_process'
import {repos, getBranchesAndTags} from './src/repos.ts'
import getFlatRefs from './src/flatRefs.ts'
import { flatFiles, flatDirectories } from './src/flatFiles.ts'
import flatPatches from './src/flatPatches.ts'
import paginatedPatches, {type PatchPage} from './src/paginatedPatches.ts'
import {getLocation} from './src/helpers.ts'
main.ts:265
Before
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
    return sortedByDirectory
  })

  eleventyConfig.addFilter("isDirectory", (filename: string, repoName: string, refName: string, refType: 'branch' | 'tag') => {
    const repo = reposData.find(repo => repo.name === repoName)
    const refKey = refType === 'branch' ? 'branches' : 'tags'
    const files = repo[refKey].find(ref => ref.name === refName).fileList
    const isDirectory = Array.from(files.keys()).some((testFile) => {
        return testFile.startsWith(filename + '/') && (testFile !== filename)
      })
    return isDirectory
  })

  eleventyConfig.addFilter("pagesJustForRef", (pages: Array<PatchPage>, repoName: string, refName: string, refType: "branch" | "tag") => {
    return pages.filter(page => page.repoName === repoName && page.refName === refName && page.type === refType)
  })
After
264
265
266










267
268
    return sortedByDirectory
  })

⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
  eleventyConfig.addFilter("pagesJustForRef", (pages: Array<PatchPage>, repoName: string, refName: string, refType: "branch" | "tag") => {
    return pages.filter(page => page.repoName === repoName && page.refName === refName && page.type === refType)
  })
main.ts:389
Before
388
389
390


391
392

  // FILE.TS
  const flatFilesData = flatFiles(reposData)
⁣
⁣
  eleventyConfig.addTemplate(
    'repos/file.11ty.js',
    commonPage(fileJsTemplate, reposConfiguration, eleventyConfig),
After
388
389
390
391
392
393
394

  // FILE.TS
  const flatFilesData = flatFiles(reposData)
  const flatDirectoriesData = flatDirectories(reposData)

  eleventyConfig.addTemplate(
    'repos/file.11ty.js',
    commonPage(fileJsTemplate, reposConfiguration, eleventyConfig),
main.ts:398
Before
397
398
399
400
401
402
        size: 1,
        alias: "fileInfo",
      },
      flatFiles: flatFilesData,
      permalink: (data) => {
        const repoName = data.fileInfo.repoName
        const refName = data.fileInfo.refName
After
397
398
399
400
401
402
        size: 1,
        alias: "fileInfo",
      },
      flatFiles: flatFilesData.concat(flatDirectoriesData),
      permalink: (data) => {
        const repoName = data.fileInfo.repoName
        const refName = data.fileInfo.refName
main.ts:445
Before
444
445
446
447
448
449
        const repoName = data.fileInfo.repoName
        const refName = data.fileInfo.refName
        const refType = data.fileInfo.type
        return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/${refType}/${eleventyConfig.getFilter("slugify")(refName)}/raw/${data.fileInfo.file.split('.').map(filePart => eleventyConfig.getFilter("slugify")(filePart)).join('.')}`
      },
      eleventyComputed: {
        currentRepo: (data) => reposData.find(repo => {
After
444
445
446
447
448
449
        const repoName = data.fileInfo.repoName
        const refName = data.fileInfo.refName
        const refType = data.fileInfo.type
        return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/${refType}/${eleventyConfig.getFilter("slugify")(refName)}/raw/${data.fileInfo.file.split('/').map((filePart) => filePart.split('.').map((subPart) => eleventyConfig.getFilter("slugify")(subPart)).join('.')).join('/')}`
      },
      eleventyComputed: {
        currentRepo: (data) => reposData.find(repo => {
src/flatPatches.ts:14
Before
13
14
15


16
17
18
  if (cachedFlatPatches !== null) { return cachedFlatPatches }

  const itemsForRef: (
⁣
⁣
    ref: Repository['tags'][0], refType: 'branch' | 'tag', repo: Repository
  ) => Array<FlatPatchRecord> = (ref, refType, repo) => {
    const flatPatches: Array<FlatPatchRecord> = []
    let currentCommit: ReturnType<Repository['commits']['get']> | undefined = repo.commits.get(ref.sha)
After
13
14
15
16
17
18
19
20
  if (cachedFlatPatches !== null) { return cachedFlatPatches }

  const itemsForRef: (
    ref: Repository['tags'][0],
    refType: 'branch' | 'tag',
    repo: Repository
  ) => Array<FlatPatchRecord> = (ref, refType, repo) => {
    const flatPatches: Array<FlatPatchRecord> = []
    let currentCommit: ReturnType<Repository['commits']['get']> | undefined = repo.commits.get(ref.sha)