readwise-mirror icon indicating copy to clipboard operation
readwise-mirror copied to clipboard

Ability to include document notes and summaries in export

Open 1ncontinentia opened this issue 1 year ago • 6 comments

Hi, relatively small request—is it possible to include variables in the export template to handle {{document_note}} and {{summary}} as per the official plugin? This is awesome by the way, thank you so much for putting it together!

1ncontinentia avatar Feb 07 '24 13:02 1ncontinentia

Hey @1ncontinentia , thank you, and glad to hear you're enjoying the plugin!

Sure, it's definitely possible to add new fields as long as they're exposed by Readwise's API. I double checked the API documents and see the new document_note field that you mentioned, but I don't see any field named summary. You can see all of the available fields exposed by the API here: https://readwise.io/api_deets.

If you're comfortable opening a pull request adding in the new field(s), I'd be happy to merge in the changes. Otherwise, I'll add it the roadmap but no ETA on when I'll actually have time to focus on this given other work commitments

jsonMartin avatar Feb 22 '24 19:02 jsonMartin

Hey @jsonMartin, thanks so much for getting back to me! Happy to do that; I assume I just add the fields in the main.ts and it should be good to go? If so, mind adding me as a collaborator? I can't open a pull request at the moment apparently. Cheers!

1ncontinentia avatar Feb 23 '24 16:02 1ncontinentia

Hi @1ncontinentia , you should be able to open a pull request. Have you forked the repository first? To create a pull request, you need to make the changes in your fork first, then submit a pull request from there.

And the changes will be a little more involved than just changing main.ts; the field(s) have to be added both in readwiseApi.ts for adding the new field types, then in main.ts for displaying in the template.

So at a high level for example, if adding document_note for example, that is a field on the Books response object. So, a new line could be added on line 44 in readwiseApi.ts adding a type document_note: string. Then, in main.ts, the new field will be deconstructed from the books response object (line 256) and added to the metadata variable so it's available for frontmatter.

Once that's working, then it can be added to the Frontmatter template. Ideally adjusting the headerTemplate of DEFAULT_SETTINGS to display the field (only when it exists, similar to the other fields)

Then, after all the changes are completed in your fork, build it and test the plugin with your Obsidian environment to make sure it all works as intended before submitting the pull request.

Happy to work with you to implement this change, but if it's too much no worries I'll put this on the roadmap for the future when I have spare time.

jsonMartin avatar Feb 29 '24 19:02 jsonMartin

Ah gotcha! I think in that case it goes a bit above my head and I'd rather not mess things up. If you'd be happy to add to the roadmap that would be amazing! Thanks @jsonMartin

1ncontinentia avatar Mar 04 '24 18:03 1ncontinentia

Sure, it's definitely possible to add new fields as long as they're exposed by Readwise's API. I double checked the API documents and see the new document_note field that you mentioned, but I don't see any field named summary. You can see all of the available fields exposed by the API here: https://readwise.io/api_deets.

@jsonMartin, the summary field is only present in the newer export API endpoint. Wanting both in my Obsidian was a good incentive to write and propose #41.

johannrichard avatar Apr 03 '24 13:04 johannrichard

@johannrichard ok, thank you for these pull requests! I will review soon 👍🏼

jsonMartin avatar Apr 03 '24 15:04 jsonMartin