feat: add roman numeral filter for volume numbering
Some checks failed
Deploy to Cloudflare Pages / publish (push) Failing after 21s
Some checks failed
Deploy to Cloudflare Pages / publish (push) Failing after 21s
This commit is contained in:
parent
0e0c30116e
commit
c28f8f3198
2 changed files with 14 additions and 1 deletions
|
|
@ -29,7 +29,7 @@ layout: base
|
||||||
<hr class="rule">
|
<hr class="rule">
|
||||||
|
|
||||||
<div class="dateline">
|
<div class="dateline">
|
||||||
<span class="vol">Volume {{ volume_number }}, Edition No. {{ edition_number }}</span>
|
<span class="vol">Volume {{ volume_number | roman }}, Edition No. {{ edition_number }}</span>
|
||||||
<span class="place">Opelousas, Louisiana, {{ date | newsDate }}</span>
|
<span class="place">Opelousas, Louisiana, {{ date | newsDate }}</span>
|
||||||
<span class="price">Price 3 Acorns</span>
|
<span class="price">Price 3 Acorns</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,19 @@ module.exports = function(eleventyConfig) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
eleventyConfig.addFilter("roman", function(num) {
|
||||||
|
const lookup = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};
|
||||||
|
let roman = '';
|
||||||
|
for (let i in lookup) {
|
||||||
|
while (num >= lookup[i]) {
|
||||||
|
roman += i;
|
||||||
|
num -= lookup[i];
|
||||||
|
}
|
||||||
|
} return roman; }
|
||||||
|
);
|
||||||
|
|
||||||
|
module.exports = function(eleventyConfig) {
|
||||||
return {
|
return {
|
||||||
dir: {
|
dir: {
|
||||||
input: "content",
|
input: "content",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue