Sun Apr 13 2025
Tucker McKnight
Adds a branches tab to the top nav, which shows a list of branches. Adds a description field to each branch, which is shown on the branches page. Adds a select box to the top nav that allows you to change between branches.
9a8d8349120255fa78d56bc28127a10db26ed107
<a href="/" class="text-decoration-none">Darcs Repositories</a>{% if nav.repoName %}<span class="text-secondary mx-2">></span><a href="/repos/{{nav.repoName | slugify}}/branches/{{darcsConfig.repos[nav.repoName].defaultBranch | slugify}}" class="text-decoration-none">{{nav.repoName}}</a>{% endif %}{% if nav.branchName %}<span class="text-secondary mx-2">></span><a class="text-decoration-none" href="/repos/{{nav.repoName | slugify}}/branches/{{nav.branchName | slugify}}">{{nav.branchName}}</a>{% endif %}
<a href="/" class="text-decoration-none">Darcs Repositories</a>{% if nav.repoName %}<span class="text-secondary mx-2">></span><a href="/repos/{{nav.repoName | slugify}}/branches/{{darcsConfig.repos[nav.repoName].defaultBranch | slugify}}" class="text-decoration-none">{{nav.repoName}}</a>{% endif %}
<nav class="nav-tabs mb-4">
<ul class="nav">
<li class="nav-item">
<a class="nav-link {% if navTab == "landing" %}active{% endif %}" href="/repos/{{nav.repoName | slugify}}/branches/{{nav.branchName}}">Landing Page</a>
</li>
<li class="nav-item">
<a class="nav-link {% if navTab == "files" %}active{% endif %}" href="/repos/{{nav.repoName | slugify}}/branches/{{nav.branchName}}/files">Files</a>
</li>
<li class="nav-item">
<a class="nav-link {% if navTab == "patches" %}active{% endif %}" href="/repos/{{nav.repoName | slugify}}/branches/{{nav.branchName}}/patches/page1">Patches</a>
</li>
</ul>
</nav>
<div class="row mb-4">
<div class="col pe-0">
<nav class="nav-tabs">
<ul class="nav">
<li class="nav-item">
<a class="nav-link {% if navTab == "landing" %}active{% endif %}" href="/repos/{{nav.repoName | slugify}}/branches/{{nav.branchName}}">Landing Page</a>
</li>
<li class="nav-item">
<a class="nav-link {% if navTab == "files" %}active{% endif %}" href="/repos/{{nav.repoName | slugify}}/branches/{{nav.branchName}}/files">Files</a>
</li>
<li class="nav-item">
<a class="nav-link {% if navTab == "patches" %}active{% endif %}" href="/repos/{{nav.repoName | slugify}}/branches/{{nav.branchName}}/patches/page1">Patches</a>
</li>
<li class="nav-item">
<a class="nav-link {% if navTab == "branches" %}active{% endif %}" href="/repos/{{nav.repoName | slugify}}/branches/{{nav.branchName | slugify}}/list">Branches</a>
</li>
</ul>
</nav>
</div>
<div class="col-auto border-bottom">
<div class="input-group input-group-sm">
<span class="input-group-text">Branch</span>
<select class="form-select" onchange="selectBranch(this)" aria-label="Repository branch selector">
{% for branch in branches %}
<option value="{{branch.repoName | slugify}},{{branch.branchName | slugify}},{{nav.path}}" {% if branch.branchName == nav.branchName %}selected{% endif %}>{{branch.branchName}}</option>
{% endfor %}
</select>
</div>
</div>
</div>
}
const selectBranch = (e) => {
const values = e.value.split(",")
window.location = `/repos/${values[0]}/branches/${values[1]}/${values[2]}`
export default {
eleventyComputed: {
nav: {
repoName: (data) => {
return data.branchInfo.repoName
},
branchName: (data) => {
return data.branchInfo.branchName
},
path: "list",
}
}
}
---
pagination:
data: branches
size: 1
alias: branchInfo
permalink: "repos/{{branchInfo.repoName | slugify}}/branches/{{branchInfo.branchName | slugify}}/list/"
navTab: branches
---
<ul>
{% for branch in branches %}
{% set description = darcsConfig.repos[branch.repoName].branches[branch.branchName].description %}
<li><a href="/repos/{{branch.repoName | slugify}}/branches/{{branch.branchName | slugify}}">{{branch.branchName}}</a>{% if branch.branchName == branchInfo.branchName %} (current){% endif %}{% if description %} - {{ description }}{% endif %}</li>
{% endfor %}
</ul>
defaultBranch: 'eleventy-darcs-main',
defaultBranch: 'main',
'eleventy-darcs-main': {
'main': {
description: "Main branch of this project."
},
'works-in-progress': {
location: "../clone-of-eleventy-darcs/eleventy-darcs-clone/",
description: "Ongoing dev work in this project. Patches here may be unrecorded and modified at any time.",
eleventyConfig.addFilter("pagesJustForRepo", (pages, repoName) => {
return pages.filter(page => page.repoName === repoName )
eleventyConfig.addFilter("pagesJustForBranch", (pages, repoName, branchName) => {
return pages.filter(page => page.repoName === repoName && page.branchName === branchName)
},
path: (data) => {
return `files/${data.fileInfo.file}`
}
},
path: "files"
<ul>
{% set files = repos[branchInfo.repoName][branchInfo.branchName].files | topLevelFilesOnly %}
{% for file in files %}
<li><a href="/repos/{{branchInfo.repoName | slugify}}/branches/{{branchInfo.branchName}}/files/{{file}}.html">{{file}}</a></li>
{% endfor %}
</ul>
<div class="row">
<div class="col">
<ul>
{% set files = repos[branchInfo.repoName][branchInfo.branchName].files | topLevelFilesOnly %}
{% for file in files %}
<li><a href="/repos/{{branchInfo.repoName | slugify}}/branches/{{branchInfo.branchName}}/files/{{file}}.html">{{file}}</a></li>
{% endfor %}
</ul>
</div>
</div>
},
path: (data) => {
return `patches/${data.patchInfo.patch.hash}`
}
},
path: "patches/page1",
{% for pageObj in (paginatedPatches | pagesJustForRepo(patchPage.repoName)) %}
{% for pageObj in (paginatedPatches | pagesJustForBranch(patchPage.repoName, patchPage.branchName)) %}
{% for pageObj in (paginatedPatches | pagesJustForRepo(patchPage.repoName)) %}
{% for pageObj in (paginatedPatches | pagesJustForBranch(patchPage.repoName, patchPage.branchName)) %}
}
},
path: "",