Skip to content

Commit

Permalink
ensure @importSourceIndex is created
Browse files Browse the repository at this point in the history
  • Loading branch information
farling42 committed Apr 28, 2024
1 parent d5ab04b commit 4d59ace
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ChangeLog

## 0.36.3

- Ensure that `@importSourceIndex` is set (rather than the erroneous `@sourceIndex` name).
- Update README to identify that `this.SourceIndex` will always be available to allow any JavaScript used for defining the note's name to use this information.

## 0.36.2

- Ensure that when accessing folders in the vault we always uses "/" as the directory separator, rather than `path.sep` which is the underlying O/S's preferred slash.
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ Various top-level variables can be accessed to get information about the convers
- `@importSettings.forceArray`: (boolean) "Each subfield is a separate note"
- `@importSettings.multipleJSON`: (boolean) "Data contains multiple JSON objects"

#### Legacy variables
#### Additional fields for JavaScript used in creating a note name dynamically.

The following variables will be removed in a future version, since they are accessible from the new `@import...` variables.
The following variables are available inside the javascript which

- `SourceFilename`: The name of the file which is supplying the data. _This has been superceded by `@importSourceFile.name`_
- `SourceIndex`: If the source data is an array (which is always the case for CSV files) this will be the index into the array, otherwise it will be the name of the field within the 'Field containing the data' object which is being used to create the current note. _This has been superceded by `@importSourceIndex`._
- `this.SourceIndex`: If the source data is an array (which is always the case for CSV files) this will be the index into the array, otherwise it will be the name of the field within the 'Field containing the data' object which is being used to create the current note. _This has been superceded by `@importSourceIndex`._
- `this.dataRoot` : contains the entire object defined by the JSON file selected for import.
- `this.SourceFilename` : references the filename from which the JSON data was read.

### Additional Handlebar Functions

Expand Down
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export default class JsonImport extends Plugin {
console.info(`Ignoring element ${index} which is not an object: ${JSON.stringify(row)}`)
continue;
}
hboptions.data.sourceIndex = index;
hboptions.data.importSourceIndex = index;
// Add our own fields to the ROW
row.SourceIndex = index;
row.dataRoot = objdata;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-import-json",
"name": "JSON/CSV Importer",
"version": "0.36.2",
"version": "0.36.3",
"minAppVersion": "1.1.15",
"description": "This plugin imports a JSON/CSV file (or text block) and creates notes from a Handlebars template file",
"author": "farling42",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-import-json",
"version": "0.36.2",
"version": "0.36.3",
"description": "This plugin imports a JSON/CSV file (or text block) and creates notes from a Handlebars template file",
"main": "main.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"0.36.3": "1.1.15",
"0.36.2": "1.1.15",
"0.36.1": "1.1.15",
"0.35.0": "1.1.15",
Expand Down

0 comments on commit 4d59ace

Please sign in to comment.