Files snapshot from mithril-server-side-rendering

./js_templates/files.ts

1
2
3
4
5
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
39
40
41
42
da80ba Tucker McKnight
da80ba Tucker McKnight
88b515 Tucker McKnight
88b515 Tucker McKnight
7f8822 Tucker McKnight
7f8822 Tucker McKnight
7f8822 Tucker McKnight
7f8822 Tucker McKnight
7f8822 Tucker McKnight
88b515 Tucker McKnight
7f8822 Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
da80ba Tucker McKnight
7f8822 Tucker McKnight
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) => {
  const branch: Repository['branches'][0] = data.currentBranch
  const topLevelFilesOnly = eleventyConfig.getFilter("topLevelFilesOnly")
  const slugify = eleventyConfig.getFilter("slugify")

  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)
      ])
    }))
  ])
}