Make files.ts be a mithril template

da80ba5ba84d6fab7c662a9a0fd3eab8d898fa18

Tucker McKnight <tucker@pangolin.lan> | Tue Jan 20 2026

Make files.ts be a mithril template
js_templates/files.ts:1
Before

0
1
i⁣
⁣
mport { type SortedFileList, type Repository } from "../src/dataTypes.ts"

export default async (eleventyConfig: any, data: any) => {
After
0
1
2
3
import m from 'mithril'
import render from 'mithril-node-render'
import { type SortedFileList, type Repository } from "../src/dataTypes.ts"

export default async (eleventyConfig: any, data: any) => {
js_templates/files.ts:7
Before
6
7
8
9
10
11


12

13
14
15
16
17
18
19
20
21
22
23
24
25
26

27
28
29
30
31
32

33
34
35
36
37
38

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

  return `
    <div class="row mt-3 mb-1">
      <div class="col">
⁣
⁣
        <p>Files snapshot from <span class="font-monospace">${data.branchInfo.branchName}</span></p></div>
    </div>
    <div class="row my-1">
      <div class="col">
        <h3>
          <span>./</span>
        </h3>
      </div>
    </div>
    <ul class="list-group">
    ${files.map((file) => {
        return `
          <li class="list-group-item">
            ${file.isDirectory ? '<span>&#x1F4C1;</span>' : ''}            <a href="${data.reposPath}/${slugify(data.branchInfo.repoName)}/branches/${slugify(data.branchInfo.branchName)}/files/${
              file.fullPath.split('/')
              .map((pathPart) => {
                return pathPart.split('.').map((subPart) => {
                  return slugify(subPart)
                }).join('.')
⁣
              }).join('/')}.html">${file.name}</a>
          </li>
        `
    }).join('')}
    </ul>
  `
}
After
6
7
8
9
10
11
12
13
14
15
16
17
18
19

20

21
22

23

24
25
26
27
28
29
30
31
32
33
34
35

36

37

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

  return render([
    m('div', {class: "row mt-3 mb-1"}, [
      m('div', {class: "col"},
        m('p', [
          'Files snapshot from ',
          m('span', {class: "font-monospace"}, data.branchInfo.branchName)
        ])
      )
    ]),
    m('div', {class: "row my-1"},
      m('div', {class: "col"},m('h3', './'))
    ),m('ul', {class: "list-group"}, files.map((file) => {
⁣
      return m('li', [
        file.isDirectory ? '<span>&#x1F4C1;</span>' : null,
        m('a', {
          href: `${data.reposPath}/${slugify(data.branchInfo.repoName)}/branches/${slugify(data.branchInfo.branchName)}/files/${
            file.fullPath.split('/')
            .map((pathPart) => {
              return pathPart.split('.').map((subPart) => {
                return slugify(subPart)
              }).join('.')
            }).join('/')}.html`
        }, file.name)
      ])
⁣
    }))
⁣
  ])
}