Closed FlorianWege closed 1 week ago
Hi! Yea, I will add more arguments.
Adding on to this: I would love access to DataviewJS in the Processor function. My use case is pretty simple right now but access to DataviewJS would cover a ton of future use cases.
My current use case is that I use Daily Notes with files in the YYYY-MM-DD format. The title
property contains a pretty formatted date "June 13th, 2024" and I use Frontmatter Title to swap the file name with the pretty formatted title.
Ideally, I would like to go one step further and for it to check if the file name is today and swap it with "Today". Here's what I tried to put in the Processor function:
let currentDate = moment().format("YYYY-MM-DD");
let noteName = dv.current().file.name;
if (noteName === currentDate) {
return "Today";
} else {
return title;
}
Obviously this could be solved by simply passing in the file name, but I think access to the DataviewJS API would solve a wider range of use cases too.
It can be later, but you can use now FunctionV2 Processor Type.
It can be later, but you can use now FunctionV2 Processor Type.
I think if you can give the TFile
of the file it would also be really nice!
Thank you @joshwayne for the idea! I've made a processor to change the name for today's daily note 😄
I'll share it here in case anyone wants it:
const filePath = obj.path;
const title = obj.title;
function getFileNameWithoutExtension(filePath) {
const lastSlashIndex = filePath.lastIndexOf('/');
const fileNameWithExtension = lastSlashIndex === -1 ? filePath : filePath.substring(lastSlashIndex + 1);
const lastDotIndex = fileNameWithExtension.lastIndexOf('.');
return lastDotIndex === -1 ? fileNameWithExtension : fileNameWithExtension.substring(0, lastDotIndex);
}
const basename = getFileNameWithoutExtension(filePath);
let display_name = title ?? basename;
if (display_name === moment().format("YYYY-MM-DD") ){
display_name = "ᕕ( ᐛ )ᕗ TODAY";
}
return display_name;
And @snezhig thanks for the new FunctionV2 feature, really useful!
( I originally planned to create a plugin myself to implement the "highlight today's tag" feature, but thanks to your idea, I can now achieve it directly with FrontmatterTitle, haha!
Thanks for the addition @snezhig!
@Moyf I also used it to change the name of the daily note. Here's what I came up with:
let currentDate = moment().format("MMMM Do, YYYY");
let noteName = obj.title;
if (noteName === currentDate) {
return "🌞 Today";
} else {
return obj.title;
}
It can be later, but you can use now FunctionV2 Processor Type.
I think if you can give the
TFile
of the file it would also be really nice!
I think that it should be added.
It can be later, but you can use now FunctionV2 Processor Type.
I think if you can give the
TFile
of the file it would also be really nice!I think that it should be added.
@snezhig here's a PR #229 that might cover what you're going for there.
It can be later, but you can use now FunctionV2 Processor Type.
I think if you can give the
TFile
of the file it would also be really nice!I think that it should be added.
@snezhig here's a PR #229 that might cover what you're going for there.
Thanks, I have added this property for processor.
Hello,
it seems to me like the function processor currently only gets passed a
title
. Would it be possible to pass further context information like the whole properties object of the processed note as an additional parameter?Use case 1: A note could have another optional
type
property that marks that the note is about a book for example and should then be displayed as"Book: "
+title
.Use case 2: You could want to clarify by title that a note belongs to a specific topical context. Then you want to display it as
title
+ "(" +context
+ ")", e.g.,Crane (fauna)
,Crane (construction)
. Separatingcontext
into an own property that potentially refers to a refactorable note itself can make it cleaner.