Make repo page use commonPage

ce6a4772a46cb166387dede59ad9adee9b640345

Tucker McKnight <tmcknight@instructure.com> | Thu Feb 19 2026

Make repo page use commonPage
js_templates/repo.ts:1
Before
0
1
2
3

4
5
6
7

8
9
10
11
12
13


14
15
import m from 'mithril'
import { type Repository } from '../src/dataTypes.ts'
import { NavHelper } from './helpers/nav.ts'

⁣
export default async (eleventyConfig: any, data: any, nav: ReturnType<typeof NavHelper>) => {
  const repo: Repository = data.currentRepo
  const branch: Repository['branches'][0] = data.currentBranch
  const renderContentIfAvailable = eleventyConfig.getFilter("renderContentIfAvailable")
⁣
  const getReadMe = eleventyConfig.getFilter("getReadMe")
  const latestCommit = repo.commits.get(branch.head)
  const latestCommitMessage = latestCommit.message.length > 72
    ? latestCommit.message.split('\n')[0].substr(0, 72) + '...'
    : latestCommit.message

⁣
⁣
  const languageCounts = branch.fileList.reduce((counts, currentFile) => {
    const fileParts = currentFile.split(".")
    const fileExtension = fileParts[fileParts.length - 1]
After
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import m from 'mithril'
import { type Repository } from '../src/dataTypes.ts'
import { NavHelper } from './helpers/nav.ts'
import htmlPage from './common/htmlPage.ts'

export default async (reposConfig: any, eleventyConfig: any, data: any) => {
  const repo: Repository = data.currentRepo
  const branch: Repository['branches'][0] = data.currentBranch
  const renderContentIfAvailable = eleventyConfig.getFilter("renderContentIfAvailable")
  const slugify = eleventyConfig.getFilter("slugify")
  const getReadMe = eleventyConfig.getFilter("getReadMe")
  const latestCommit = repo.commits.get(branch.head)
  const latestCommitMessage = latestCommit.message.length > 72
    ? latestCommit.message.split('\n')[0].substr(0, 72) + '...'
    : latestCommit.message

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

  const languageCounts = branch.fileList.reduce((counts, currentFile) => {
    const fileParts = currentFile.split(".")
    const fileExtension = fileParts[fileParts.length - 1]
js_templates/repo.ts:44
Before
43
44
45
46
47
48

  const readmeContent = await renderContentIfAvailable(await getReadMe(repo.name, branch.name), branch.name)

  return [
    m('div', {class: "row"}, [
      m('div', {class: "col"}, [
        m('div', {class: "px-4 pt-3 bezel-header"}, [
After
43
44
45
46
47
48

  const readmeContent = await renderContentIfAvailable(await getReadMe(repo.name, branch.name), branch.name)

  const pageContent = [
    m('div', {class: "row"}, [
      m('div', {class: "col"}, [
        m('div', {class: "px-4 pt-3 bezel-header"}, [
js_templates/repo.ts:117
Before
116
117
118

      m('div', {class: "col readme"}, m.trust(readmeContent))
    )
  ]
⁣
⁣
}
After
116
117
118
119
120
      m('div', {class: "col readme"}, m.trust(readmeContent))
    )
  ]

  return await htmlPage(reposConfig, eleventyConfig, data, pageContent)
}
main.ts:13
Before
12
13
14
15
16
17
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'
After
12
13
14
15
16
17
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'
main.ts:401
Before
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
  // )

  // 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)
After
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
  // )

  // REPO.TS
  eleventyConfig.addTemplate(
    'repos/repo.11ty.js',
    commonPage(repoJsTemplate, reposConfiguration, eleventyConfig),
    {
      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)