Add fonts and styling for articles

Note: Due to nodepub limitations, the fonts are only named, but
not actually embedded. To embed them, you'll have to do something
roundabout like opening the ePub in the Calibre ePub Editor and
embedding them from there. Hopefully this will get resolved at
some point :/
This commit is contained in:
Hippo 2021-04-03 22:02:21 +05:30
parent d475a5bde9
commit 1ddc5f4e7c

View file

@ -744,8 +744,8 @@ class Seance {
allPosts.push(post)
}
// prepare for image downloads
let pics = []
// prepare for image downloads, starting with the scissors!
let pics = [path.join(__dirname, 'scissors.png')]
let picFolder = path.join(options.outputFolder, 'seance-images')
if (!fs.existsSync(picFolder)) {
fs.mkdirSync(picFolder, { recursive: true })
@ -835,6 +835,50 @@ class Seance {
epub.addSection(post.title, post.body)
}
// add the styles
epub.addCSS(`
img {
width: 100%;
height: auto;
}
h1 {
font-family: "Abhaya Libre Extrabold";
text-transform: lowercase;
text-align: center;
font-size: 3.6em;
line-height: 1em;
margin-bottom: 0;
}
h1 + h2 {
font-family: "Open Sans Light";
font-variant: small-caps;
text-align: center;
font-size: 1.2em;
line-height: 1em;
margin-bottom: 2.4em;
}
p {
font-family: "Crimson Text Regular";
font-size: 1em;
line-height: 1.2em;
}
hr {
display: block;
border: 0px;
height: 1em;
background-image:url('../images/scissors.png');
background-size: contain;
background-repeat: no-repeat;
background-position: 50%;
margin-top: 1.5em;
margin-bottom: 1.5em;
}
`)
// generate it!
await epub.writeEPUB(options.outputFolder, options.title)
}