Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Dynamic Document Title #126

Open
ZachEngstrom opened this issue Jun 14, 2022 · 1 comment
Open

feature: Dynamic Document Title #126

ZachEngstrom opened this issue Jun 14, 2022 · 1 comment

Comments

@ZachEngstrom
Copy link

Problem:

module.exports = {
    document_title: `${__filename}`,
    stylesheet: "./assets/custom.css",
    pdf_options: {
        displayHeaderFooter: true,
        headerTemplate: `
        <div><span class="title"></span> | Page <span class="pageNumber"></span> of <span class="totalPages"></span></div>
      `,
        footerTemplate: `
        <div>&copy;${new Date().getFullYear()} Spongebob</div>
        `,
    },
};

Outputs:
/Users/user/path/config.js | Page 1 of 5

Setting document_title to a string value is a static value. Not setting document_title outputs an empty string.

Desired Outputs:

  • File.md | Page 1 of 5
  • File | Page 1 of 5

Request:
Add the ability for the code to determine the file name of the document it is currently converting and being able to use that as the "title" value.

@simonhaenisch
Copy link
Owner

https://nodejs.org/api/modules.html#__filename:

__filename

The file name of the current module. This is the current module file's absolute path with symlinks resolved.

So yeah of course that would reference your config file.

Anyway, wasn't really aware that the document title is what's used for the title in the header template. So yeah I see the use case. I'm assuming manually adding a front-matter with

---
document_title: File
---

to each markdown file will be too cumbersome for you? (what's in the front-matter takes precedence over the config file)

Otherwise, can't really think of a fast solution for this, other than some better defaults for the title, e. g. file name or first h1 content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants