Tucker McKnight
Make files.ts be a mithril template
1
1
import m from 'mithril'
import render from 'mithril-node-render'
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
return `
<div class="row mt-3 mb-1">
<div class="col">
<p>Files snapshot from <span class="font-monospace">${data.branchInfo.branchName}</span></p>
</div>
</div>
<div class="row my-1">
<div class="col">
<h3>
<span>./</span>
</h3>
</div>
</div>
<ul class="list-group">
${files.map((file) => {
return `
<li class="list-group-item">
${file.isDirectory ? '<span>📁</span>' : ''}
<a href="${data.reposPath}/${slugify(data.branchInfo.repoName)}/branches/${slugify(data.branchInfo.branchName)}/files/${
file.fullPath.split('/')
.map((pathPart) => {
return pathPart.split('.').map((subPart) => {
return slugify(subPart)
}).join('.')
}).join('/')}.html">${file.name}</a>
</li>
`
}).join('')}
</ul>
`
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
return render([
m('div', {class: "row mt-3 mb-1"}, [
m('div', {class: "col"},
m('p', [
'Files snapshot from ',
m('span', {class: "font-monospace"}, data.branchInfo.branchName)
])
)
]),
m('div', {class: "row my-1"},
m('div', {class: "col"},
m('h3', './')
)
),
m('ul', {class: "list-group"}, files.map((file) => {
return m('li', [
file.isDirectory ? '<span>📁</span>' : null,
m('a', {
href: `${data.reposPath}/${slugify(data.branchInfo.repoName)}/branches/${slugify(data.branchInfo.branchName)}/files/${
file.fullPath.split('/')
.map((pathPart) => {
return pathPart.split('.').map((subPart) => {
return slugify(subPart)
}).join('.')
}).join('/')}.html`
}, file.name)
])
}))
])