Add the title of the page as "# header" into the MD
Closed this issue · 3 comments
I'm converting a site where the title is displayed as part of the WP template, so I'm loosing that info in the MD file.
If would be really useful to add to the MD as header at the first line like this:
# title of the WP post
[Rest of the content]
Quick and dirty solution:
function getPostContent(post, turndownService, config) {
...
// add title as header to the top of the page
content = "# " + post.title[0] + "\n\n" + content ;
return content;
}
This looks like a layout concern, not a data concern. The title is already provided in the frontmatter, and ideally whatever template consumes the markdown file should render it where needed.
If this works for your case, then that's cool, looks like you got what you need with your quick and dirty solution. 🙂 But I can't assume that everyone wants the title smooshed into the content as an h1
like this.
Indeed it was there on the frontmatter, the matter of fact my even quicker and dirtier fix was this: (title\: \"(.*)"\n.*\n.*)
replaced by $1\n\n# $2
:)
Yeah, it may be a special problem I have. I wondered if as a configurable option could help others. But I agree that it may not be needed for others. I'm using docfx, there the frontmatter does not used during rendering.