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

Create note with differing filename and metadata title #1126

Closed
1 task done
Dynge opened this issue Oct 24, 2023 · 5 comments · Fixed by #1128
Closed
1 task done

Create note with differing filename and metadata title #1126

Dynge opened this issue Oct 24, 2023 · 5 comments · Fixed by #1128
Labels
feature Issues related to feature proposals. Please attach a module.

Comments

@Dynge
Copy link
Contributor

Dynge commented Oct 24, 2023

Issues

  • I have checked existing issues and there are no existing ones with the same request.

Feature description

Goal

Create an API that makes it simple to extend Neorg file creation.

Why

My motivation stems from a desire to create my files with a timestamp template for the filename (e.g. YYMMDD-HHMMSS.norg), however I do not want the file to get auto generated the same timestamp into the title - because then I always need to edit the metadata.

I believe this feature would make file creation in Neorg better suited to extension and make it easier for anyone to modify it to their own needs.

Proposed Solution

I am thinking about something like:

require("neorg").get_module("core.dirman").new_note(
    "notes",
    "path/filename",
    { title="awesome note" }
)

The above code would then create a file path/filename.norg in the workspace notes, prefilled with metadata with the title awesome note.
The table i am thinking about not just adding a title but potentially also other metadata fields.

Help

Yes

Implementation help

I would like to help implement a lua function to call in order to accomplish this.

I am thinking the proper place for this would by in the dirman module, but i may be wrong :)

If you can help me with where best to place this functionality (assuming it aligns with the vision for the project) - that would be great :)

@Dynge Dynge added the feature Issues related to feature proposals. Please attach a module. label Oct 24, 2023
@max397574
Copy link
Contributor

I definitely think this could be useful. Not sure whether it should be in the dirman module (which creates new notes) or the metagen module though
I think it should be a parameter of new_note like you proposed but the question is whether this should be then passed on to metagen (which imo it should be but idk how extensible that api is)

@Dynge
Copy link
Contributor Author

Dynge commented Oct 24, 2023

I agree that it seems most logical to add the metadata updates for the note into metagen, however that would make dirman depend on metagen, right?

I am not sure how to avoid such dependencies..

Maybe its better to make a two-step solution.

One method in dirman to create a note (assume it already exists) and another in metagen to update with custom defaults.

What do you think?

@max397574
Copy link
Contributor

quite sure we can check if the user has automatic metadata injection enabled
so metagen wouldn't become a dependency

@Dynge
Copy link
Contributor Author

Dynge commented Oct 24, 2023

Alright. Thats good.

I can take a look at the code for dirman and metagen soon and see if i can come up with some more concrete suggestions.

Thanks for your feedback so far, @max397574 !

Do you know if there is any code besides the module files that i should look at relating to this?

@max397574
Copy link
Contributor

afaik there are no important things outside of the module files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issues related to feature proposals. Please attach a module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants