[WIP] Make some pages use the commonPage wrapper

7bbc3b6a3f8fd416f39faa7479b149bd023857b2

Tucker McKnight <tmcknight@instructure.com> | Tue Feb 17 2026

[WIP] Make some pages use the commonPage wrapper
js_templates/commit.ts:1
Before
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import m from 'mithril'
import {NavHelper} from './helpers/nav.ts'

export default async (
  eleventyConfig: any,
  data: any,
  nav: ReturnType<typeof NavHelper>
) => {
  const date = eleventyConfig.getFilter("date")
  const slugify = eleventyConfig.getFilter("slugify")
  const lineNumbers = eleventyConfig.getFilter("lineNumbers")
  const languageExtension = eleventyConfig.getFilter("languageExtension")

  return [
    m('div', {class: "row"},
      m('div', {class: "col-auto"},
        m('div', {class: "bezel-secondary px-3 py-2"}, [
After
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import m from 'mithril'
import htmlPage from './common/htmlPage.ts'

export default async (
  reposConfig: any,
  eleventyConfig: any,
  data: any,
) => {
  const date = eleventyConfig.getFilter("date")
  const slugify = eleventyConfig.getFilter("slugify")
  const lineNumbers = eleventyConfig.getFilter("lineNumbers")
  const languageExtension = eleventyConfig.getFilter("languageExtension")

  return await htmlPage(reposConfig, eleventyConfig, data, [
    m('div', {class: "row"},
      m('div', {class: "col-auto"},
        m('div', {class: "bezel-secondary px-3 py-2"}, [
js_templates/commit.ts:104
Before
103
104
105
106
}
`)
    )
  ]
}
After
103
104
105
106
}
`)
    )
  ])
}
js_templates/common/commonPage.ts:1
Before
0
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
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58

59
60
61
import m from 'mithril'
import render from 'mithril-node-render'

export default async (rootPath: string, pageContent: Function) => {
⁣
⁣
⁣
  return render([
    m.trust('<!doctype html>'),
    m('html', {lang: "en"}, [
      m('head', [
        m('meta', {charset: "utf-8"}),
        m('meta', {name: "viewport", content: "width=device-width, initial-scale=1"}),
        // CUSTOMIZEABLE TITLE
        m('title', 'Repositories'),
        m('link', {rel: "stylesheet", href: "/css/design-board.css"}),
        // ADDITIONAL SCRIPT CONTENT HERE
        m('script', {src: `${rootPath}frontend/top.js`}),
        // ADDITIONAL LINK CONTENT FOR PRISM THEME HERE
      ]),
      m('body', [
        m('div', {class: "container-fluid container-lg"}, [
          m('div', {class: "row"}, [
            m('div', {class: "col"}, [
              // INSERT NAVBAR CONTENT HERE
            ]),
            m('div', {class: "col-auto pt-2"}, [
              m('div', {class: "dropdown"}, [
                m('button', {class: "dropdown-toggle btn btn-bg", id: "dark-mode-switch", type: "button", 'data-bs-toggle': "dropdown", 'aria-expanded': 'false'},
                  m('span', m.trust('&#xFE0F;'))
                ),
                m('ul', {class: "dropdown-menu"}, [
                  m('li',
                    m('button', {class: "btn shadow-none", 'data-theme-pref': "light", onclick: "toggleDarkMode(this)"}, [
                      m('span', {class: "me-1"}, m.trust('&#x1F31E;')),
                      'Light'
                    ])
                  ),
                  m('li',
                    m('button', {class: "btn shadow-none", 'data-theme-pref': "dark", onclick: "toggleDarkMode(this)"}, [
                      m('span', {class: "me-1"}, m.trust('&#x1F319;')),
                      'Dark'
                    ])
                  ),
                  m('li',
                    m('button', {class: "btn shadow-none", 'data-theme-pref': "auto", onclick: "toggleDarkMode(this)"}, [
                      m('span', {class: "me-1"}, m.trust('&#x1F5A5;&#xFE0F;')),
                      'Match OS'
                    ])
⁣
                  )
                ])
              ])
            ])
          ]),
          await pageContent,
        ]),
        m('script', {
          src: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js",
          integrity: "sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI",
          crossorigin: "anonymous"
        }),
        m('script', {src: `${rootPath}frontend/main-frontend.bundle.js`})
⁣
      ])
    ])
  ])
}
After
0
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
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58
59
60
61
62
63
import m from 'mithril'
import render from 'mithril-node-render'

export default async (template, reposConfiguration, eleventyConfig) => {
  return async (data) => {
    const opts = await template(reposConfiguration, eleventyConfig, data)
    
    return render([
      m.trust('<!doctype html>'),
      m('html', {lang: "en"}, [
        m('head', [
          m('meta', {charset: "utf-8"}),
          m('meta', {name: "viewport", content: "width=device-width, initial-scale=1"}),
⁣
          m('title', opts.pageTitle),
          m('link', {rel: "stylesheet", href: "/css/design-board.css"}),
          opts.additionalHeadContent || null,
          m('script', {src: `${opts.rootPath}frontend/top.js`}),
⁣
        ]),
        m('body', [
          m('div', {class: "container-fluid container-lg"}, [
            m('div', {class: "row"}, [
              m('div', {class: "col"}, [
                opts.navbarContent || null,
              ]),
              m('div', {class: "col-auto pt-2"}, [
                m('div', {class: "dropdown"}, [
                  m('button', {class: "dropdown-toggle btn btn-bg", id: "dark-mode-switch", type: "button", 'data-bs-toggle': "dropdown", 'aria-expanded': 'false'},
                    m('span', m.trust('&#xFE0F;'))
                  ),
                  m('ul', {class: "dropdown-menu"}, [
                    m('li',
                      m('button', {class: "btn shadow-none", 'data-theme-pref': "light", onclick: "toggleDarkMode(this)"}, [
                        m('span', {class: "me-1"}, m.trust('&#x1F31E;')),
                        'Light'
                      ])
                    ),
                    m('li',
                      m('button', {class: "btn shadow-none", 'data-theme-pref': "dark", onclick: "toggleDarkMode(this)"}, [
                        m('span', {class: "me-1"}, m.trust('&#x1F319;')),
                        'Dark'
                      ])
                    ),
                    m('li',
                      m('button', {class: "btn shadow-none", 'data-theme-pref': "auto", onclick: "toggleDarkMode(this)"}, [
                        m('span', {class: "me-1"}, m.trust('&#x1F5A5;&#xFE0F;')),
                        'Match OS'
                      ])
                    )
                  ])
                ])
              ])
⁣
            ]),
            await opts.pageContent,
          ]),
          m('script', {
            src: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js",
            integrity: "sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI",
            crossorigin: "anonymous"
          }),
          m('script', {src: `${opts.rootPath}frontend/main-frontend.bundle.js`})
        ])
      ])
    ])
  }
}
js_templates/common/htmlPage.ts:1
Before
0
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import m from 'mithril'
import render from 'mithril-node-render'
import { type ReposConfiguration } from '../../src/configTypes.ts'
import { type Repository } from '../../src/dataTypes.ts'
import { NavHelper } from '../helpers/nav.ts'
import branchesListItems from './branchesListItems.ts'

export default async (reposConfig: ReposConfiguration, eleventyConfig: any, pageContent: Function) => {
  return async (data) => {
    // this still necessary?
    if (data.currentRepo === '') {
      return
    }

    const repo: Repository = data.currentRepo
    const branch: Repository['branches'][0] = data.currentBranch

    const slugify = eleventyConfig.getFilter("slugify")
    const nav = NavHelper(reposConfig, slugify, repo.name, branch.name)

    const branchesWithHrefs = repo.branches.map((branch) => {
      return {
        name: branch.name,
        href: nav.repoBranchHome(branch.name) + '/' + data.nav.path,
        date: repo.commits.get(branch.head).date.toISOString(),
      }
    })

    return render([
      m.trust('<!doctype html>'),
      m('html', {lang: "en"}, [
        m('head', [
          m('meta', {charset: "utf-8"}),
          m('meta', {name: "viewport", content: "width=device-width, initial-scale=1"}),
          m('title', repo.name),
          m('link', {rel: "stylesheet", href: "/css/design-board.css"}),
          m('script', m.trust(`
            window.branchesWithHrefs = ${JSON.stringify(branchesWithHrefs)};
            window.defaultBranch = "${repo.defaultBranch}";
            window.currentBranch = "${branch.name}";
            window.cloneUrl = "${repo.cloneUrl}";
          `)),
          m('script', {src: `${nav.rootPath()}frontend/top.js`}),
          m('link', {
            rel: "stylesheet",
            id: "prism-theme",
            type: "text/css",
            href: `${data.reposPath}/vendor/prism.css`
          }),
        ]),
        m('body', [
          m('div', {class: "container-fluid container-lg"}, [
            m('div', {class: "row"}, [
              m('div', {class: "col"}, [
                m('nav', {class: "navbar navbar-expand"}, [
                  m('ul', {class: "navbar-nav flex-wrap"}, [
                    m('li', {class: "nav-item"},
                      m('a', {
                        class: "nav-link",
                        href: nav.rootPath()
                      }, m.trust('&#10094; Repos'))
                    ),
                    m('li', {class: "nav-item"},
                      m('a', {
                        class: "nav-link",
                        href: nav.repoCurrentBranchHome()
                      }, repo.name)
                    ),
                    m('li', {class: "nav-item"}, [
                      m('span', {class: "nav-link d-inline-block"}, 'Branch:'),
                      m('div', {class: "branch-selector dropdown-center d-inline-block"}, [
                        m('button', {
                          class: "branches nav-link d-inline-block btn btn-bg dropdown-toggle",
                          'data-bs-toggle': "dropdown",
                          'data-bs-auto-close': "outside",
                          'aria-expanded': "false"
                        }, branch.name),
                        m('div', {class: "dropdown-menu"}, [
                          m('form', {class: "mx-3 my-1"}, [
                            m('input', {type: "text", class: "form-control", id: "dropdownBranchSearch", placeholder: "Search branches..."}),
                            m('div', [
                              m('div', {class: "row mt-3"},
                                m('div', {class: "col"},
                                  m('label', {class: "form-label"}, 'Sort by:')
                                )
                              ),
                              m('div', {class: "sortRadioButtons"}, [
                                m('div', {class: "sortRadioButton pe-1"}, [
                                  m('input', {class: "form-check-input sort-filter", type: "radio", name: "branchSort", value: 'date', id: "branchSortByDate", checked: true}),
                                  m('label', {class: "form-check-label", for: "branchSortByDate"}, 'Last commit')
                                ]),
                                m('div', {class: "sortRadioButton ps-1"}, [
                                  m('input', {class: "form-check-input sort-filter", type: "radio", name: "branchSort", value: 'name', id: "branchSortByName"}),
                                  m('label', {class: "form-check-label", for: "branchSortByName"}, 'Name')
                                ])
                              ])
                            ])
                          ]),
                          m('div', {class: "dropdown-divider"}),
                          m('div', {id: "dropdown-branches-results", class: "dropdown-branches"},
                            branchesListItems(branchesWithHrefs, repo.defaultBranch, branch.name, 'date')
                          )
                        ])
                      ])
                    ])
                  ])
                ])
              ]),
              m('div', {class: "col-auto pt-2"}, [
                m('div', {class: "dropdown"}, [
                  m('button', {class: "dropdown-toggle btn btn-bg", id: "dark-mode-switch", type: "button", 'data-bs-toggle': "dropdown", 'aria-expanded': 'false'},
                    m('span', m.trust('&#xFE0F;'))
                  ),
                  m('ul', {class: "dropdown-menu"}, [
                    m('li',
                      m('button', {class: "btn shadow-none", 'data-theme-pref': "light", onclick: "toggleDarkMode(this)"}, [
                        m('span', {class: "me-1"}, m.trust('&#x1F31E;')),
                        'Light'
                      ])
                    ),
                    m('li',
                      m('button', {class: "btn shadow-none", 'data-theme-pref': "dark", onclick: "toggleDarkMode(this)"}, [
                        m('span', {class: "me-1"}, m.trust('&#x1F319;')),
                        'Dark'
                      ])
                    ),
                    m('li',
                      m('button', {class: "btn shadow-none", 'data-theme-pref': "auto", onclick: "toggleDarkMode(this)"}, [
                        m('span', {class: "me-1"}, m.trust('&#x1F5A5;&#xFE0F;')),
                        'Match OS'
                      ])
                    )
                  ])
                ])
              ])
            ]),
            m('div', {class: "row"},
              m('div', {class: "col"},
                m('nav', {class: "navbar navbar-expand"},
                  m('ul', {class: "main-nav navbar-nav flex-wrap"}, [
                    m('li', {class: "nav-item"},
                      m('a', {class: `nav-link ${data.navTab === 'home' ? 'active' : ''}`, 'aria-current': "page", href: nav.repoCurrentBranchHome()}, 'Home')
                    ),
                    m('li', {class: "nav-item"},
                      m('a', {class: `nav-link ${data.navTab === 'files' ? 'active' : ''}`, href: nav.repoCurrentBranchFiles()}, 'Files')
                    ),
                    m('li', {class: "nav-item"},
                      m('a', {class: `nav-link ${data.navTab === 'commits' ? 'active' : ''}`, href: nav.repoCurrentBranchCommits()}, 'Commits')
                    ),
                    m('li', {class: "nav-item"},
                      m('a', {class: `nav-link ${data.navTab === 'branches' ? 'active' : ''}`, href: nav.repoCurrentBranchBranches()}, 'Branches')
                    )
                  ])
                )
              )
            ),
            m('div', {class: "row"},
              m('div', {class: "col-12"},
                await pageContent(eleventyConfig, data, nav)
              )
            ),
          ]),
          m('script', {
            src: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js",
            integrity: "sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI",
            crossorigin: "anonymous"
          }),
          m('script', {src: `${nav.rootPath()}frontend/main-frontend.bundle.js`})
        ])
      ])
    ])
  }
}
After
0

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




43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

95
96



























97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119









120
121
122
123
import m from 'mithril'
⁣
import { type ReposConfiguration } from '../../src/configTypes.ts'
import { type Repository } from '../../src/dataTypes.ts'
import { NavHelper } from '../helpers/nav.ts'
import branchesListItems from './branchesListItems.ts'

⁣
export default async (reposConfig: ReposConfiguration, eleventyConfig: any, data: any, pageContent: any) => {
  // this still necessary?
  if (data.currentRepo === '') {
    return
  }

  const repo: Repository = data.currentRepo
  const branch: Repository['branches'][0] = data.currentBranch

  const slugify = eleventyConfig.getFilter("slugify")
  const nav = NavHelper(reposConfig, slugify, repo.name, branch.name)

  const branchesWithHrefs = repo.branches.map((branch) => {
    return {
      name: branch.name,
      href: nav.repoBranchHome(branch.name) + '/' + data.nav.path,
      date: repo.commits.get(branch.head).date.toISOString(),
    }
  })

⁣
⁣
  return {
⁣
    rootPath: nav.rootPath(),
⁣
    pageTitle: repo.name,
    additionalHeadContent: [
      m('script', m.trust(`
        window.branchesWithHrefs = ${JSON.stringify(branchesWithHrefs)};
        window.defaultBranch = "${repo.defaultBranch}";
        window.currentBranch = "${branch.name}";
        window.cloneUrl = "${repo.cloneUrl}";
      `)),
⁣
      m('link', {
        rel: "stylesheet",
        id: "prism-theme",
        type: "text/css",
        href: `${data.reposPath}/vendor/prism.css`
      }),
    ],
⁣
⁣
⁣
⁣
    navbarContent: m('nav', {class: "navbar navbar-expand"}, [
      m('ul', {class: "navbar-nav flex-wrap"}, [
        m('li', {class: "nav-item"},
          m('a', {
            class: "nav-link",
            href: nav.rootPath()
          }, m.trust('&#10094; Repos'))
        ),
        m('li', {class: "nav-item"},
          m('a', {
            class: "nav-link",
            href: nav.repoCurrentBranchHome()
          }, repo.name)
        ),
        m('li', {class: "nav-item"}, [
          m('span', {class: "nav-link d-inline-block"}, 'Branch:'),
          m('div', {class: "branch-selector dropdown-center d-inline-block"}, [
            m('button', {
              class: "branches nav-link d-inline-block btn btn-bg dropdown-toggle",
              'data-bs-toggle': "dropdown",
              'data-bs-auto-close': "outside",
              'aria-expanded': "false"
            }, branch.name),
            m('div', {class: "dropdown-menu"}, [
              m('form', {class: "mx-3 my-1"}, [
                m('input', {type: "text", class: "form-control", id: "dropdownBranchSearch", placeholder: "Search branches..."}),
                m('div', [
                  m('div', {class: "row mt-3"},
                    m('div', {class: "col"},
                      m('label', {class: "form-label"}, 'Sort by:')
                    )
                  ),
                  m('div', {class: "sortRadioButtons"}, [
                    m('div', {class: "sortRadioButton pe-1"}, [
                      m('input', {class: "form-check-input sort-filter", type: "radio", name: "branchSort", value: 'date', id: "branchSortByDate", checked: true}),
                      m('label', {class: "form-check-label", for: "branchSortByDate"}, 'Last commit')
                    ]),
                    m('div', {class: "sortRadioButton ps-1"}, [
                      m('input', {class: "form-check-input sort-filter", type: "radio", name: "branchSort", value: 'name', id: "branchSortByName"}),
                      m('label', {class: "form-check-label", for: "branchSortByName"}, 'Name')
                    ])
                  ])
                ])
              ]),
              m('div', {class: "dropdown-divider"}),
              m('div', {id: "dropdown-branches-results", class: "dropdown-branches"},
                branchesListItems(branchesWithHrefs, repo.defaultBranch, branch.name, 'date')
              )
            ])
          ])
        ])
      ])
⁣
    ]),
    pageContent: [
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
      m('div', {class: "row"},
        m('div', {class: "col"},
          m('nav', {class: "navbar navbar-expand"},
            m('ul', {class: "main-nav navbar-nav flex-wrap"}, [
              m('li', {class: "nav-item"},
                m('a', {class: `nav-link ${data.navTab === 'home' ? 'active' : ''}`, 'aria-current': "page", href: nav.repoCurrentBranchHome()}, 'Home')
              ),
              m('li', {class: "nav-item"},
                m('a', {class: `nav-link ${data.navTab === 'files' ? 'active' : ''}`, href: nav.repoCurrentBranchFiles()}, 'Files')
              ),
              m('li', {class: "nav-item"},
                m('a', {class: `nav-link ${data.navTab === 'commits' ? 'active' : ''}`, href: nav.repoCurrentBranchCommits()}, 'Commits')
              ),
              m('li', {class: "nav-item"},
                m('a', {class: `nav-link ${data.navTab === 'branches' ? 'active' : ''}`, href: nav.repoCurrentBranchBranches()}, 'Branches')
              )
            ])
          )
        )
      ),
      m('div', {class: "row"},
        m('div', {class: "col-12"},
          await pageContent
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
        )
      ),
    ]
  }
}
js_templates/file.ts:1
Before
0
1

2
3
4
import m from 'mithril'

⁣
export default async (eleventyConfig: any, data: any) => {
  const isDirectory = eleventyConfig.getFilter("isDirectory")
  const topLevelFilesOnly = eleventyConfig.getFilter("topLevelFilesOnly")
  const getDirectoryContents = eleventyConfig.getFilter("getDirectoryContents")
After
0
1
2
3
4
5
import m from 'mithril'
import htmlPage from './common/htmlPage.ts'

export default async (reposConfig: any, eleventyConfig: any, data: any) => {
  const isDirectory = eleventyConfig.getFilter("isDirectory")
  const topLevelFilesOnly = eleventyConfig.getFilter("topLevelFilesOnly")
  const getDirectoryContents = eleventyConfig.getFilter("getDirectoryContents")
js_templates/file.ts:13
Before
12
13
14
15
16
17
  const languageExtension = eleventyConfig.getFilter("languageExtension")
  const renderContentIfAvailable = eleventyConfig.getFilter("renderContentIfAvailable")

  return [
    m('div', {class: "row mt-3 mb-1"},
      m('div', {class: "col"},
        m('p', [
After
12
13
14
15
16
17
  const languageExtension = eleventyConfig.getFilter("languageExtension")
  const renderContentIfAvailable = eleventyConfig.getFilter("renderContentIfAvailable")

  const pageContent = [
    m('div', {class: "row mt-3 mb-1"},
      m('div', {class: "col"},
        m('p', [
js_templates/file.ts:165
Before
164
165
166

      ]
    )
  ]
⁣
⁣
}
After
164
165
166
167
168
      ]
    )
  ]

  return await htmlPage(reposConfig, eleventyConfig, data, pageContent)
}
js_templates/index.ts:1
Before
0
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
43
44
45
46

47
48



49
50
import m from 'mithril'
import render from 'mithril-node-render'
import commonPage from './common/commonPage.ts'

export default (eleventyConfig: any) => {
  const slugify = eleventyConfig.getFilter("slugify")

  return async (data: any) => {
    const pageContent = m('div', {class: "container"}, [
      m('div', {class: "row my-3"},
        m('div', {class: "col"},
          m('h1', data.reposConfig.defaultTemplateConfiguration?.allRepositoriesPageTitle || "All Repositories")
        )
      ),
      m('div', {class: "row"},
        m('div', {class: "col d-flex flex-wrap"},
          data.repos.map((repo) => {
            return (
              m('div', {class: "m-2 card bezel-gray flex-grow-1", style: "flex-basis: 20rem;"},
                m('div', {class: "card-header"},
                  m('a', {class: "card-title fs-5", href: `${data.reposPath}/${slugify(repo.name)}/branches/${repo.defaultBranch}`}, repo.name)
                ),
                m('div', {class: "card-body"},
                  repo.description ? m('p', {class: "card-text"}, repo.description) : null
                ),
                m('div', {class: "card-footer"}, [
                  m('a', {
                    href: `${data.reposPath}/${slugify(repo.name)}/branches/${repo.defaultBranch}`,
                    class: "ms-0 me-2 my-2 btn btn-primary text-white"
                  }, 'Go to site'),
                  m('button', {
                    class: "mx-1 my-2 btn btn-outline-secondary shadow-none dropdown-toggle clone-popover-btn",
                    'data-copy-text': repo.cloneUrl
                  }, 'Clone'),
                  (data.reposConfig.repos[repo.name].defaultTemplateConfiguration?.homepageButtons || []).map((button) => {
                    return m('a', {
                      class: "mx-1 my-2 btn btn-outline-secondary shadow-none",
                      href: button.url,
                      target: button.newTab ? '_blank' : '_self'
                    }, [button.text, button.newTab ? [' ', m('span', m.trust('&#x29C9;'))] : null])
                  })
                ])
              )
            )
          })
        )
      )
⁣
    ])

⁣
⁣
⁣
    return commonPage(`${data.reposPath}/`, pageContent)
  }
}
After
0
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
43
44
45
46
47
48
49
50
51
import m from 'mithril'
import render from 'mithril-node-render'

⁣
export default (_reposConfig: any, eleventyConfig: any, data: any) => {
  const slugify = eleventyConfig.getFilter("slugify")

⁣
  const pageContent = m('div', {class: "container"}, [
    m('div', {class: "row my-3"},
      m('div', {class: "col"},
        m('h1', data.reposConfig.defaultTemplateConfiguration?.allRepositoriesPageTitle || "All Repositories")
      )
    ),
    m('div', {class: "row"},
      m('div', {class: "col d-flex flex-wrap"},
        data.repos.map((repo) => {
          return (
            m('div', {class: "m-2 card bezel-gray flex-grow-1", style: "flex-basis: 20rem;"},
              m('div', {class: "card-header"},
                m('a', {class: "card-title fs-5", href: `${data.reposPath}/${slugify(repo.name)}/branches/${repo.defaultBranch}`}, repo.name)
              ),
              m('div', {class: "card-body"},
                repo.description ? m('p', {class: "card-text"}, repo.description) : null
              ),
              m('div', {class: "card-footer"}, [
                m('a', {
                  href: `${data.reposPath}/${slugify(repo.name)}/branches/${repo.defaultBranch}`,
                  class: "ms-0 me-2 my-2 btn btn-primary text-white"
                }, 'Go to site'),
                m('button', {
                  class: "mx-1 my-2 btn btn-outline-secondary shadow-none dropdown-toggle clone-popover-btn",
                  'data-copy-text': repo.cloneUrl
                }, 'Clone'),
                (data.reposConfig.repos[repo.name].defaultTemplateConfiguration?.homepageButtons || []).map((button) => {
                  return m('a', {
                    class: "mx-1 my-2 btn btn-outline-secondary shadow-none",
                    href: button.url,
                    target: button.newTab ? '_blank' : '_self'
                  }, [button.text, button.newTab ? [' ', m('span', m.trust('&#x29C9;'))] : null])
                })
              ])
⁣
            )
          )
        })
      )
    )
  ])

  return {
    rootPath: `${data.reposPath}/`,
    pageTitle: 'Repositories',
    pageContent
  }
}
main.ts:12
Before
11
12
13
14
15
16
17
18
19
20
21
22
23
import { type SortedFileList } from './src/dataTypes.ts'
import {Ajv} from 'ajv'
import ConfigSchema from './schemas/ReposConfiguration.json' with { type: 'json' }
import htmlPage from './js_templates/common/htmlPage.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'
import indexJsTemplate from './js_templates/index.ts'
import branchesJsTemplate from './js_templates/branches.ts'
import rawJsTemplate from './js_templates/raw.ts'
import feedJsTemplate from './js_templates/feed.ts'
After
11
12
13
14
15
16
17
18
19
20
21
22
23
import { type SortedFileList } from './src/dataTypes.ts'
import {Ajv} from 'ajv'
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'
import indexJsTemplate from './js_templates/index.ts'
// import branchesJsTemplate from './js_templates/branches.ts'
import rawJsTemplate from './js_templates/raw.ts'
import feedJsTemplate from './js_templates/feed.ts'
main.ts:270
Before
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
  // INDEX.TS
  eleventyConfig.addTemplate(
    'repos/index.11ty.js',
    indexJsTemplate(eleventyConfig),
    {
      permalink: `${reposPath}/index.html`,
    }
  )

  // BRANCHES.TS
  eleventyConfig.addTemplate(
    'repos/branches.11ty.js',
    htmlPage(reposConfiguration, eleventyConfig, branchesJsTemplate),
    {
      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)}/branches/`
      },
      eleventyComputed: {
        nav: {
          repoName: (data) => data.branchInfo.repoName,
          branchName: (data) => data.branchInfo.branchName,
          path: "branches"
        },
        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: "branches",
    }
  )

  // FILE.TS
  const flatFilesData = flatFiles(reposData)
  eleventyConfig.addTemplate(
    'repos/file.11ty.js',
    htmlPage(reposConfiguration, eleventyConfig, fileJsTemplate),
    {
      pagination: {
        data: "flatFiles",
After
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
  // INDEX.TS
  eleventyConfig.addTemplate(
    'repos/index.11ty.js',
    commonPage(indexJsTemplate, {}, eleventyConfig),
    {
      permalink: `${reposPath}/index.html`,
    }
  )

  // BRANCHES.TS
  // eleventyConfig.addTemplate(
  //   'repos/branches.11ty.js',
  //   htmlPage(reposConfiguration, eleventyConfig, branchesJsTemplate),
  //   {
  //     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)}/branches/`
  //     },
  //     eleventyComputed: {
  //       nav: {
  //         repoName: (data) => data.branchInfo.repoName,
  //         branchName: (data) => data.branchInfo.branchName,
  //         path: "branches"
  //       },
  //       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: "branches",
  //   }
  // )

  // FILE.TS
  const flatFilesData = flatFiles(reposData)
  eleventyConfig.addTemplate(
    'repos/file.11ty.js',
    commonPage(fileJsTemplate, reposConfiguration, eleventyConfig),
    {
      pagination: {
        data: "flatFiles",
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
  )

  // 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(
    'repos/repo.11ty.js',
    htmlPage(reposConfiguration, eleventyConfig, repoJsTemplate),
    {
      pagination: {
        data: "branches",
        size: 1,
        alias: "branch",
      },
      permalink: (data) => {
        const repoName = data.branch.repoName
        const branchName = data.branch.branchName
        return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branchName)}/`
      },
      eleventyComputed: {
        nav: {
          repoName: (data) => data.branch.repoName,
          branchName: (data) => data.branch.branchName,
          path: (data) => '', // ask about why empty string here shows up as a function
        },
        currentRepo: (data) => reposData.find(repo => {
          return repo.name === data.branch.repoName
        }),
        currentBranch: (data) => reposData.find(repo => {
          return repo.name === data.branch.repoName
        }).branches.find(branch => {
          return branch.name === data.branch.branchName
        }),
      },
      navTab: "home"
    }
  )

  // COMMITS.TS
  const paginatedPatchesData = await paginatedPatches(reposData)
  eleventyConfig.addTemplate(
    `repos/patches.11ty.js`,
    htmlPage(reposConfiguration, eleventyConfig, commitsJsTemplate),
    {
      pagination: {
        data: "paginatedPatches",
        size: 1,
        alias: "patchPage",
      },
      paginatedPatches: paginatedPatchesData,
      permalink: (data) => {
        const repoName = data.patchPage.repoName
        const branchName = data.patchPage.branchName
        return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branchName)}/commits/page${data.patchPage.pageNumber}/`
      },
      eleventyComputed: {
        nav: {
          repoName: (data) => data.patchPage.repoName,
          branchName: (data) => data.patchPage.branchName,
          path: 'commits/page1',
        },
        currentRepo: (data) => reposData.find(repo => {
          return repo.name === data.patchPage.repoName
        }),
        currentBranch: (data) => reposData.find(repo => {
          return repo.name === data.patchPage.repoName
        }).branches.find(branch => {
          return branch.name === data.patchPage.branchName
        }),
      },
      navTab: "commits",
    }
  )

  // COMMIT.TS
  const flatPatchesData = await flatPatches(reposData)
  eleventyConfig.addTemplate(
    `repos/commit.11ty.js`,
    htmlPage(reposConfiguration, eleventyConfig, commitJsTemplate),
    {
      pagination: {
        data: "flatPatches",
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
  )

  // 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(
  //   'repos/repo.11ty.js',
  //   htmlPage(reposConfiguration, eleventyConfig, repoJsTemplate),
  //   {
  //     pagination: {
  //       data: "branches",
  //       size: 1,
  //       alias: "branch",
  //     },
  //     permalink: (data) => {
  //       const repoName = data.branch.repoName
  //       const branchName = data.branch.branchName
  //       return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branchName)}/`
  //     },
  //     eleventyComputed: {
  //       nav: {
  //         repoName: (data) => data.branch.repoName,
  //         branchName: (data) => data.branch.branchName,
  //         path: (data) => '', // ask about why empty string here shows up as a function
  //       },
  //       currentRepo: (data) => reposData.find(repo => {
  //         return repo.name === data.branch.repoName
  //       }),
  //       currentBranch: (data) => reposData.find(repo => {
  //         return repo.name === data.branch.repoName
  //       }).branches.find(branch => {
  //         return branch.name === data.branch.branchName
  //       }),
  //     },
  //     navTab: "home"
  //   }
  // )

  // COMMITS.TS
  // const paginatedPatchesData = await paginatedPatches(reposData)
  // eleventyConfig.addTemplate(
  //   `repos/patches.11ty.js`,
  //   htmlPage(reposConfiguration, eleventyConfig, commitsJsTemplate),
  //   {
  //     pagination: {
  //       data: "paginatedPatches",
  //       size: 1,
  //       alias: "patchPage",
  //     },
  //     paginatedPatches: paginatedPatchesData,
  //     permalink: (data) => {
  //       const repoName = data.patchPage.repoName
  //       const branchName = data.patchPage.branchName
  //       return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branchName)}/commits/page${data.patchPage.pageNumber}/`
  //     },
  //     eleventyComputed: {
  //       nav: {
  //         repoName: (data) => data.patchPage.repoName,
  //         branchName: (data) => data.patchPage.branchName,
  //         path: 'commits/page1',
  //       },
  //       currentRepo: (data) => reposData.find(repo => {
  //         return repo.name === data.patchPage.repoName
  //       }),
  //       currentBranch: (data) => reposData.find(repo => {
  //         return repo.name === data.patchPage.repoName
  //       }).branches.find(branch => {
  //         return branch.name === data.patchPage.branchName
  //       }),
  //     },
  //     navTab: "commits",
  //   }
  // )

  // COMMIT.TS
  const flatPatchesData = await flatPatches(reposData)
  eleventyConfig.addTemplate(
    `repos/commit.11ty.js`,
    commonPage(commitJsTemplate, reposConfiguration, eleventyConfig),
    {
      pagination: {
        data: "flatPatches",