roam-highlighter
roam-highlighter copied to clipboard
Populate {%author%} token from metadata
This extension is awesome! I've already used it a ton for getting notes into my Obsidian knowledge base. The ability to customize your own templates is super helpful. One feature I would love to see is the ability to grab the document author if present on the page's metadata. It's fairly easy to grab:
var authorData = document.querySelector('meta[name="author"]');
var author = authorData ? authorData.content : "";
It would rule to be able to add {%author%} to my templates. I'd be happy to open a PR if I knew where to look. I've poked around in highlighter.js a little bit, but I'm not sure all the places I'd need to hit to add it. Any thoughts? Would others find this useful?
EDIT: I just noticed the note in https://github.com/GitMurf/roam-highlighter/issues/39 about being able to consistently parse the document author. I don't suppose you'd consider adding it with a caveat in the readme that it depends on whether it's been set?
@JonathanTR thank you for the code above. I actually have several requests on getting more metadata from pages.... myself included! I am going to merge the other similar issues together.
@JonathanTR btw, funny you provided the code for me, I have actually been playing around with the idea that you can define your own elements to go after. So for example, instead of {%author%} you could put like {%meta[name="author"]%} or in alot of other examples a classname or ID represents stuff people want so could do {%id=AuthorName%} or {%class=author%}. Still half baked idea so don't count on it anytime soon but it is on my radar!
Can you provide me the specific website you were trying to pull the meta author value from? I will use it is a test case when I build this out.
Here is what was from the other similar issue by @DmitriR:
... at least the citation_* namespace; possibly others as well, prism in particular.
Simply passing them through will be excellent.
No need to integrate / coerce into a single namespace, except that the two de-facto universal IDs: DOI and PMID (PubMed ID); these probably deserve their own standard tokens, regardless of how they are represented on the page.
The utility: the header / title line could be configured to include publication year and authors, and outgoing links not only to the source page but to the "canonical" home page (DOI crossref) and to the PubMed page. The DOI link could be intercepted locally to open the corresponding PDF.
Metadata tags are described here: http://div.div1.com.au/div-thoughts/div-commentaries/66-div-commentary-metadata
@DmitriR can you please provide a couple example pages / articles / websites where there is specific metadata you want? I can then use them as test cases for when I develop this feature. Thanks!