konodyuk / obsidian-typing

Programmatic customizations for groups of notes
https://konodyuk.github.io/obsidian-typing/
MIT License
134 stars 8 forks source link

Is there a way to set a field to the current date? #14

Closed bluerosegarden closed 11 months ago

bluerosegarden commented 11 months ago

Hello! This as very quickly become one of my all-time favorite plugins for obsidian. However looking through the docs and I couldn't find a way to automatically set a field to the current date, nor documentation on how to include javascript in an OTL file so I could grab it that way. Is this a feature that exists? Thank you so much in advance!

konodyuk commented 11 months ago

The following should already work:

type A {
    fields {
        date: Date = "today"
    }
}

as well as tomorrow or +2w or something else.

The slight problem is that the feature is not completely ready and you need to additionally press Enter or Cmd+Enter on that field to seal the rendered value, because otherwise it will save the note with date :: today instead of date :: 2023-11-30.

konodyuk commented 11 months ago

I think I've just fixed the aforementioned problem, so the fix will be included into the next release.

As for your question about JS, you can use import syntax inside hooks, actions, methods and marginals. (My documentation sucks and I am working on it.)

Example:

type A {
    style {
        header = fn"""
            import {Component} from "./component.tsx"
            return <Component />
        """
    }
}
bluerosegarden commented 11 months ago

Thank you so much!! That's perfect, I can't wait for the update!

Also if I was more familiar with OTL I'd offer to help with the documentation writing hahaha.

konodyuk commented 11 months ago

Fixed in release 0.3.0