omnivore-app / logseq-omnivore

Logseq plugin to fetch articles and highlights from Omnivore
MIT License
278 stars 15 forks source link

Brackets added automatically to dates on import #184

Open Petemir opened 2 months ago

Petemir commented 2 months ago

Hello!

First of all, thanks for this whole ecosystem, is really a great help :) (if only I'd manage to use it consistently...).

That said, I have been trying to import my (read) omnivore items into logseq for processing. On first sync, I ended up with lots of pages that I didn't wanted/needed, product of the attributes et al. I then edited the article and highlight templates, but I still end up with pages I don't want to be created. Namely, the dateSaved and datePublished variables seem to add brackets to the imported note, even when there are no brackets in the template.

The consequence is lots of created pages on the Journal section (which I expect to use for journaling) with reference links to information I don't want there (Omnivore's articles/highlights). This doesn't happen with other variables (such as labels.name), where I removed the brackets and successfully avoided the creation of spurious pages.

Any advice on how to fix this would be greatly appreciated. Thanks!

Redacted plugin settings:

{
  "generalSettings": "",
  "apiKey": "REDACTED",
  "filter": "advanced",
  "customQuery": "in:archive label:REDACTED",
  "highlightOrder": "the time that highlights are updated",
  "isSinglePage": false,
  "createTemplate": "",
  "createTemplateDesc": "",
  "articleTemplate": "[{{{title}}}]({{{omnivoreUrl}}})\ncollapsed:: false\nsite: {{#siteName}}[{{{siteName}}}]{{/siteName}}({{{originalUrl}}})\n{{#labels.length}}\nlabels: {{#labels}}{{{name}}}, {{/labels}}\n{{/labels.length}}\ndate-saved: {{{dateSaved}}}\n{{#datePublished}}\ndate-published: {{{datePublished}}}\n{{/datePublished}}",
  "highlightTemplate": "> {{{text}}} [⤴️]({{{highlightUrl}}}) {{#labels}} #[[{{{name}}}]] {{/labels}}\n\n{{#note.length}}{{{note}}}{{/note.length}}",
  "syncContent": false,
  "advancedSettings": "",
  "frequency": 60,
  "syncAt": "REDACTED",
  "graph": "REDACTED",
  "pageName": "{{{title}}}",
  "headingBlockTitle": "",
  "endpoint": "https://api-prod.omnivore.app/api/graphql",
  "disabled": false,
  "version": "v1.16.4",
  "syncJobId": 17,
  "loading": false
}
thiswillbeyourgithub commented 2 months ago

I noticed that too and for me it's also an inconvenience. I think that by not adding brackets it would leave the choice to the user to have this or not by simply modifying the template. It could even be in the default template ! As long as we can disable it.

Petemir commented 2 months ago

Probably the reason:

Link

export const dateReference = (
  date: Date,
  preferredDateFormat: string
): string => {
  return `[[${formatDate(date, preferredDateFormat)}]]`
}