How to customize the title page with template-require?
See original GitHub issueI would like to customize the title page using a template.js file, to add complicated corporate document tables containing a lot of metadata. Also the following pages footers would endure the same treatment (embedding a small table in the footer).
My understanding is that to do this, you have to override the document node in templates.js module.exports, which contains a lot of pre-defined stuff going on in there. I saw this in the source code :
const titlePage = (node) => {
if (node.getDocumentTitle()) {
const doc = node.getDocument()
if (hasTitlePage(doc)) {
return `<div id="cover" class="title-page">
<h1>${node.getDocumentTitle()}</h1>
<h2>${node.getDocument().getAuthor()}</h2>
</div>`
}
return `<div class="title-document">
<h1>${node.getDocumentTitle()}</h1>
</div>`
}
return ''
}
Which is then used in the document node:
<body class="article">
${titlePage(node)}
${contentHTML}
${footnotes(node)}
Alongside other things which I would rather not want to touch to, especially if things evolve in this lib’s code in the future, I’d just want to edit that specific part of the document generation.
I tried copying all the contents of the /lib folder to my document directory and then edit from there, but I’m having some trouble with npm and the resolving of all the dependencies. Forking the project does work, except I’m limited to using the alpha3 (with all my f***ing corporate PC problems) and I think it’s not very practical and surely I’m missing something. My understanding of node, npm and other related things is shallow as I don’t work on these technologies.
So my questions are:
- Can I edit/override just this const method somehow and how would you proceed to do that?
- And how do I customize the footer’s content too by the way?
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (6 by maintainers)
Top GitHub Comments
I’m actually trying to do a POC at work, that we can get rid of MS Word and all the problems that arise with it, and to promote Asciidoc instead. So I’m trying to mimic what our documents look like at work. I’ve started with one of the most used templates in A4 format: Title page:
Following pages footer:
You can see how much data this table is supposed to contain, and it’s all document metadata that would be a breeze to use with Asciidoctor, I could pass them using attributes in the doc or directly from the CLI…
So far, these tables coming straight from hell are made with MS Word. I let you imagine all the problems related to people using different versions and how MS Word manages its stylesheets inside (a deep auto-generated mess).
So that’s why I want to use tables, or grids or whatever most suitable in modern web development! I am not a web developer so I’m still struggling with some of the basics it seems.
Alright. Also I’m wondering how the margins are actually calculated with all of this. If I put a high footer content, I expect it to be placed in between the body of the document and the bottom margin. It seems here that with the default template the page numbers are inserted inside the “margin” boxes. I don’t know if I’m making any sense. Here is a photo of the problem I’m trying to describe:
It could work, as long as the size of the bottom boxes resize accordingly on each page and is not of a predefined fixed size. I want the footer to always show correctly and not to bleed out, I want the body to move over to the next page sooner if that’s necessary. But that seems not to really be the case right now. Maybe I’m just not using the right tool for the job. It seems the footnotes actually use the page area and not the margin boxes.
Here are the relevants bits from the previous comments:
Please join https://chat.asciidoctor.org or post your question using GitHub Discussion.
Issue tracker is reserved for bug.
Thanks!