farling42 / obsidian-import-json

Plug-in for Obsidian.md which will create Notes from JSON files
MIT License
85 stars 5 forks source link

Add append option #40

Closed jschne88 closed 1 year ago

jschne88 commented 1 year ago

Adds the ability to append to existing notes if the note name in the CSV or JSON matches an existing note in the specified folder.

Side note: I would suggest running this whole thing through a linter to get some consistent formatting. I tried to match what you have in the interest of not having too many changes in the PR, but it created some odd formatting. I would recommend prettier as a good linter.

farling42 commented 1 year ago

With regards to formatting, the indentation is handled automatically by Visual Studio Code, and it looks perfectly fine on my screen. I'm not sure which editor you use, but there's certainly a lot of white space changes in your PR.

The only real formatting change in your PR seems to be putting each parameter on a separate line when calling a function with many parameters.

I'll need to modify the nested if statements when deciding how to create/modify a note, since there is some unnecessary duplication of checks, and I'll have to decide how best to present a choice of Overwrite, Append or Ignore to the user in order to handle this situation with multiple mutually exclusive options.

jschne88 commented 1 year ago

I use VSCode with the prettier extension. I had to revert all of the auto-formatting from prettier because I didn't want to distract from the actual code changes. Sounds like you do already have a default linter configured in VS Code so you should be able to run that and get it to look how you prefer.

Admittedly, my specific use case called for the particular set of conditionals I added, but I probably didn't consider other use cases. Obviously, feel free to modify as needed. Just thought I'd offer some help and a head start.

farling42 commented 1 year ago

Version 0.29.0 replaces the overwrite button with a select option to allow for APPEND, OVERWRITE, or IGNORE, which should satisfy your requirement.

(I've also reworked how settings are passed around, to get rid of the function calls with lots of parameters.)

jschne88 commented 1 year ago

Looks great! Thanks for adding this. One small nit though - in the instructions it says OVERWRITE but in your dropdown it says REPLACE and similarly IGNORE with KEEP in the dropdown.

farling42 commented 1 year ago

The text should be fixed in 0.29.1 - I've updated both to use capital letters, so that non-native English speakers can match the same letters.