Avoid rendering if the repo data isn't there

a62ca22005235b5b0b9c8d60c2a7027a83c231e7

Tucker McKnight | 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
1
    const nav = NavHelper(reposConfig, slugify, data.currentRepo.name, data.currentBranch.name)
After
1
import { type Repository } from '../src/dataTypes.ts'
    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)
js_templates/repo.ts:11
Before
11
          <title>${data.currentRepo.name}</title>
After
11
          <title>${repo.name}</title>
js_templates/repo.ts:24
Before
24
                      <a class="nav-link" href="#">${data.currentRepo.name}</a>
After
24
                      <a class="nav-link" href="#">${repo.name}</a>
js_templates/repo.ts:59
Before
59
60
                      <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>' : ''}
After
59
60
                      <h1 class="display-2 text-white"><em>${repo.name}</em></h1>
                      ${repo.description ? '<p class="text-white fs-5">' + repo.description + '</p>' : ''}
js_templates/repo.ts:97
Before
97
                      <p class="font-monospace text-white">Some text with a <a href="#">link</a> in it.</p>
After
97
                      <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>