Tucker McKnight
Add bezel boxes on files nav, dropdown menu height limit, others Limit the commit message length on the readme page Make the commit sha a link to that commit Make the nav get (optionally) passed to the page from htmlPage, so that the page itself can use the NavHelper class if it needs to (like when linking to a commit).
94
dropdownBranchesResults.innerHTML = branchesListItems(branches, window.defaultBranch)
94
dropdownBranchesResults.innerHTML = branchesListItems(branches, window.defaultBranch, window.currentBranch)
2 3 4
export const branchesListItems = (branches: Array<{name: string, href: string, date: string}>, defaultBranch: string): string => {
const badge = defaultBranch === branch.name ? '<div class="badge rounded-pill bg-primary ms-2">default</div>' : ''
return `<a href='${branch.href}' class='dropdown-item my-1'><span class="branch-dropdown-branch-name">${branch.name}</span>${badge}<span class="text-body d-block ms-2">updated ${branch.date}</span></a>`
2 3 4
export const branchesListItems = (branches: Array<{name: string, href: string, date: string}>, defaultBranch: string, currentBranch: string): string => {
const currentBadge = currentBranch === branch.name ? '<div class="badge rounded-pill bg-primary mx-1">current</div>' : ''
const defaultBadge = defaultBranch === branch.name ? '<div class="badge rounded-pill bg-info text-body mx-1">default</div>' : ''
return `<a href='${branch.href}' class='dropdown-item my-1'><span class="branch-dropdown-branch-name me-1">${branch.name}</span>${currentBadge}${defaultBadge}<span class="text-body d-block ms-2">updated ${branch.date}</span></a>`
41
41
window.currentBranch = "${branch.name}";
90
${branchesListItems(branchesWithHrefs, repo.defaultBranch)}
90
${branchesListItems(branchesWithHrefs, repo.defaultBranch, branch.name)}
104
<a class="nav-link ${data.navTab === 'home' ? 'active' : ''}" aria-current="page" href="${nav.repoCurrentBranchHome()}">Home</a>
104
<a class="nav-link ${data.navTab === 'home' ? 'active' : ''}" aria-current="page" href="${nav.repoCurrentBranchHome()}">ReadMe</a>
125
${await pageContent(eleventyConfig, data)}
125
${await pageContent(eleventyConfig, data, nav)}
1
const getFileName = eleventyConfig.getFilter("getFileName")
1
12 13 14 15 16 17 18 19 20 21 22 23
<h3>./${data.fileInfo.file}</h3>
<p>Files snapshot from <span class="font-monospace">${data.fileInfo.branchName}</span></p>
`<ul class="list-group">
${topLevelFilesOnly(getDirectoryContents(data.fileInfo.repoName, data.fileInfo.branchName, data.fileInfo.file), data.fileInfo.file + '/').map((dir) => {
return `<li class="list-group-item">
${dir.isDirectory ?
`<i class="bi bi-folder-fill"></i>`
: `<i class="bi bi-file-earmark"></i>`}
<a href="${data.reposPath}/${slugify(data.fileInfo.repoName)}/branches/${slugify(data.fileInfo.branchName)}/files/${slugify(dir.fullPath)}.html">${getRelativePath(data.fileInfo.file, dir.name)}</a>
</li>`
}).join('')}
</ul>`
12 13 14 15 16 17 18 19 20 21 22 23
<div class="row my-3">
<div class="col">
<h3>
<span class="bezel-gray px-1"><a href="#">🏠 ./</a></span>${
data.fileInfo.file.split('/').map((dir, index, arr) => {
if (index === arr.length - 1) {
return `<span class="px-2">${dir}</span>`
}
else {
return `<span class="bezel-gray px-1"><a href="#">${dir}</a></span>`
}
}).join('')
}
</h3>
</div>
</div>
<div class="row">
<div class="col">
<p>Files snapshot from <span class="font-monospace">${data.fileInfo.branchName}</span></p>
</div>
</div>
`<div class="row">
<div class="col">
<ul class="list-group">
${topLevelFilesOnly(getDirectoryContents(data.fileInfo.repoName, data.fileInfo.branchName, data.fileInfo.file), data.fileInfo.file + '/').map((dir) => {
return `<li class="list-group-item">
${dir.isDirectory ? `<span>&#x1F4C1;</span>` : ''}
<a href="${data.reposPath}/${slugify(data.fileInfo.repoName)}/branches/${slugify(data.fileInfo.branchName)}/files/${slugify(dir.fullPath)}.html">${getRelativePath(data.fileInfo.file, dir.name)}</a>
</li>`
}).join('')}
</ul>
</div>
</div>`
8 9
<h3>./</h3>
<p>Files snapshot from <span class="font-monospace">${data.branchInfo.branchName}</span></p>
8 9
<div class="row my-3">
<div class="col">
<h3>
<span>🏠 ./</span>
</h3>
</div>
</div>
<div class="row">
<div class="col">
<p>Files snapshot from <span class="font-monospace">${data.branchInfo.branchName}</span></p>
</div>
</div>
9
9
const repoBranchCommitsBase = `${currentBranchPath}/commits/`
33
repoCurrentBranchCommits: () => `${currentBranchPath}/commits/page1`,
33
repoBranchCommitsBase: () => repoBranchCommitsBase,
repoCurrentBranchCommits: () => `${repoBranchCommitsBase}page1`,
1
export default async (eleventyConfig: any, data: any) => {
1
import { NavHelper } from './helpers/nav.ts'
export default async (eleventyConfig: any, data: any, nav: ReturnType<typeof NavHelper>) => {
const latestCommit = repo.commits.get(branch.head)
58 59
<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}
58 59
<p class="font-monospace text-white text-truncate">
Latest commit: ${latestCommit.date.toDateString()} <a class="fw-bold link-info" href="${nav.repoBranchCommitsBase()}${latestCommit.hash}">${latestCommit.hash.substr(0, 6)}</a> ${latestCommit.message.split('\n')[0]}
156
156
max-height: 80vh;
overflow-y: scroll;