silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.06k stars 146 forks source link

Pass page details to registerAttributeExtractor #768

Open bnason opened 4 months ago

bnason commented 4 months ago

It would be helpful to have the details of the page passed into registerAttributeExtractor. My use case is for extracting a date from the page a task is on to use as a created date instead of having to add that to every task in the page.

zefhemel commented 4 months ago

Before I implement this, let's make sure that this will actually give you want you want. What I could implement is that I pass in either a page name, or with a bit more effort PageMeta information which would include the page name, lastModified date, createdDate, any frontmatter etc. Will that be useful to you, though?

This won't tell you when the task was created, just when the page was created or last modified, and the latter will change every save, and therefore also change for each of your index calls. Indexing indexes everything on a page from scratch, it wipes old data for that page from the index and then calculates the new data. So you won't be able to distinguish "old tasks" from "new tasks".

bnason commented 4 months ago

I was planning on primarily using the date from the name of the page if it includes YYYY-MM-DD and as a backup a date field from frontmatter.