Obsidian Bit by Bit

Robert collected notes as assets with the belief that they could be integrated into wiki workflows with an ad-hoc html script.

I offered a list of operations that such a script would need based on my own experience and offered to help with any one in any order.

I composed the list by imagining the incremental coding which allows each step to be tested as one progressed. I now return to that list to suggest what I would probably try at each step and what I might learn.

tips

> html <div> that will show the list of files.

Most projects start by printing "Hello World" to show that some code runs. Start with "working" which will reassure some success throughout the life of the script.

> script that would do the rest.

Watch the frame.js module load in the inspector's network tab. The script tag must say module and be paired with the closing </script> before import works.

> script gets the list of assets and filters .md files.

Console.log(assets) to confirm that we can see our inputs and what fields we will have to work with. The filtering is a nice touch that can be added later.

const assets = await frame.assets() .filter(asset => asset.file.endsWith('.md')

> script formats the list as <li> items to click.

Perfect this formatting as the script progresses. Start simple, maybe just show assets as json.

window.result.innerTEXT = JSON.stringify(assets)

> script click handler reads the asset file.

Interpret the click based on what is already known of the assets. There are many ways to bind click handlers and many ways to pass information to one. Here we expect all of our choices will inherit the same handler named above and now inserted into the window to be found upon click.

window.doclick = event => { ... }

> script click handler formats page title and story.

Make title and story, the two parts of a new page to be opened in the lineup. Look at the JSON of any page you like to get ideas. The item ids and journal details can be specified if they matter otherwise the next step will create good defaults.

> script click handler opens ghost pages.

Code this to use while perfecting the story and title. The shiftKey allows us to lineup ghost pages as we are making formatting choices.

.

Shift-hover over quotes above to scroll to the corresponding code in the original page. This and the cmnd-m hack helped me write this page in order.