Avoid rendering if the repo data isn't there

a62ca22005235b5b0b9c8d60c2a7027a83c231e7

Tucker McKnight <tucker@pangolin.lan> | Thu Dec 04 2025

Avoid rendering if the repo data isn't there

Also, need to figure out why this happens. Seems like sometimes
it tries to render the template when the page's data isn't there.
js_templates/repo.ts:1
Before
0
1
2

3
4






5
6
7
import { NavHelper } from './helpers/nav.ts'
import { type ReposConfiguration } from '../src/configTypes.ts'

⁣
export default (reposConfig: ReposConfiguration, slugify: Function) => {
  return (data) => {
⁣
⁣
⁣
⁣
⁣
⁣
    const nav = NavHelper(reposConfig, slugify, data.currentRepo.name, data.currentBranch.name)

    return `
      <!doctype html>
After
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { NavHelper } from './helpers/nav.ts'
import { type ReposConfiguration } from '../src/configTypes.ts'
import { type Repository } from '../src/dataTypes.ts'

export default (reposConfig: ReposConfiguration, slugify: Function) => {
  return (data) => {
    if (data.currentRepo === '') {
      return
    }
    const repo: Repository = data.currentRepo
    const branch: Repository['branches'][0] = data.currentBranch

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

    return `
      <!doctype html>
js_templates/repo.ts:11
Before
10
11
12
13
14
15
        <head>
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <title>${data.currentRepo.name}</title>
          <link rel="stylesheet" href="/css/design-board.css">
        </head>
        <body>
After
10
11
12
13
14
15
        <head>
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <title>${repo.name}</title>
          <link rel="stylesheet" href="/css/design-board.css">
        </head>
        <body>
js_templates/repo.ts:24
Before
23
24
25
26
27
28
                      <a class="nav-link" href="${nav.rootPath()}">&larr; All repositories</a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link" href="#">${data.currentRepo.name}</a>
                    </li>
                  </ul>
                </nav>
After
23
24
25
26
27
28
                      <a class="nav-link" href="${nav.rootPath()}">&larr; All repositories</a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link" href="#">${repo.name}</a>
                    </li>
                  </ul>
                </nav>
js_templates/repo.ts:59
Before
58
59
60
61
62
63
64
                <div class="px-4 pt-3 bezel">
                  <div class="row">
                    <div class="col-12 col-xl-6">
                      <h1 class="display-2 text-white"><em>${data.currentRepo.name}</em></h1>
                      ${data.currentRepo.description ? '<p class="text-white fs-5">' + data.currentRepo.description + '</p>' : ''}
                    </div>
                    <div class="col-12 col-xl-6 d-flex flex-column">
                      <div class="row py-3 flex-grow-1 align-items-center">
After
58
59
60
61
62
63
64
                <div class="px-4 pt-3 bezel">
                  <div class="row">
                    <div class="col-12 col-xl-6">
                      <h1 class="display-2 text-white"><em>${repo.name}</em></h1>
                      ${repo.description ? '<p class="text-white fs-5">' + repo.description + '</p>' : ''}
                    </div>
                    <div class="col-12 col-xl-6 d-flex flex-column">
                      <div class="row py-3 flex-grow-1 align-items-center">
js_templates/repo.ts:97
Before
96
97
98


99
100
101
                  </div>
                  <div class="row mt-2">
                    <div class="col">
⁣
⁣
                      <p class="font-monospace text-white">Some text with a <a href="#">link</a> in it.</p>
                    </div>
                  </div>
                </div>
After
96
97
98
99
100
101
102
103
                  </div>
                  <div class="row mt-2">
                    <div class="col">
                      <p class="font-monospace text-white">
                        Latest commit: ${repo.commits.get(branch.head).hash.substr(0, 6)} ${repo.commits.get(branch.head).date.toDateString()} - ${repo.commits.get(branch.head).message}
                      </p>
                    </div>
                  </div>
                </div>