Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨[Feature Request] Add support for dataviewjs syntax #8

Open
soumendrak opened this issue May 27, 2024 · 1 comment
Open

✨[Feature Request] Add support for dataviewjs syntax #8

soumendrak opened this issue May 27, 2024 · 1 comment

Comments

@soumendrak
Copy link

Thanks for this awesome budding plugin.
If dataviewjs syntax also can be supported it will be further useful.
A sample dataviewjs script for notes created/modified today:

// default dateformat in case it’s forgotten in front matter
var dateformat = "YYYY-MM-DD";
if (dv.current().dateformat) { dateformat = dv.current().dateformat; }

dv.table(["File", "LastModifiedOn", "CreatedOn"],
  dv.pages()
  .where(p => p.file.mday.equals(dv.current().file.day) || p.file.cday.equals(dv.current().file.day))
  .sort(p => p.file.mtime, 'asc')
  .map(p => [
    p.file.link,
    moment(p.file.mtime.toString()).format(dateformat),
    moment(p.file.ctime.toString()).format(dateformat),
  ])
);
@soumendrak soumendrak changed the title Add support for dataviewjs syntax ✨[Feature Request] Add support for dataviewjs syntax May 27, 2024
@unxok
Copy link
Owner

unxok commented May 28, 2024

Dataviewjs is supported

Instead of doing dv.table(headers, values) just return an object with keys for headers and values

Let me know if the following doesn't work :)
Note I am unsure about the dateformat being respected as I hadn't considered that.

// default dateformat in case it’s forgotten in front matter
var dateformat = "YYYY-MM-DD";
if (dv.current().dateformat) { dateformat = dv.current().dateformat; }

return{
  headers: ["File", "LastModifiedOn", "CreatedOn"],
  values:
  dv.pages()
  .where(p => p.file.mday.equals(dv.current().file.day) || p.file.cday.equals(dv.current().file.day))
  .sort(p => p.file.mtime, 'asc')
  .map(p => [
    p.file.link,
    moment(p.file.mtime.toString()).format(dateformat),
    moment(p.file.ctime.toString()).format(dateformat),
  ])
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants