Fix article headers
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 58s

This commit is contained in:
thepaperpilot 2024-06-15 00:18:15 -05:00
parent 31d9933942
commit 6dac140893

View file

@ -47,7 +47,7 @@ module.exports = {
const pageStart = code.indexOf("</h1>");
const firstCommit = (await exec(`git log -n 1 --diff-filter=A --format="<a href='https://code.incremental.social/thepaperpilot/pages/commit/%H' title='%ad'><time class='dt-published' datetime='%ad'>%ar</time></a>" site/${context.page}`)).stdout;
const lastCommit = (await exec(`git log -n 1 --diff-filter=M --format="<a href='https://code.incremental.social/thepaperpilot/pages/commit/%H' title='%ad'><time class='dt-updated' datetime='%ad'>%ar</time></a>" site/${context.page}`)).stdout;
const header = code.slice(0, pageStart < 0 ? 0 : pageStart - 5).replace('<h1 ', '<h1 class="p-name" ');
const header = code.slice(0, pageStart < 0 ? 0 : pageStart + 5).replace('<h1 ', '<h1 class="p-name" ');
return `<article class="h-entry">${header + `<p>${wc} words, ~${Math.round(wc / 183)} minute read. Planted ${firstCommit}.${lastCommit ? ` Last tended to ${lastCommit}.` : ''}</p><hr/><div class="e-content">` + code.slice(pageStart + 5)}</div></article>`;
}
return code;