Skip to content

Commit

Permalink
Fixed importer issue when some values don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Erallie committed Oct 13, 2024
1 parent cdbb19e commit ae307a4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/import-journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,13 @@ function formatContent(array: any, moment: moment.Moment, mapViewProperty: strin
if (array.rating) {
frontmatter += `\n${plugin.settings.ratingProp}: ${array.rating}/5`;
}
if (array.tags.length != 0) {
if (array.tags && array.tags.length != 0) {
frontmatter += `\ntags:`;
for (let i in array.tags) {
frontmatter += `\n - ${array.tags[i]}`;
}
}
if (array.people.length != 0) {
if (array.people && array.people.length != 0) {
frontmatter += `\npeople:`;
for (let i in array.people) {
frontmatter += `\n - ${array.people[i]}`;
Expand All @@ -589,7 +589,7 @@ function formatContent(array: any, moment: moment.Moment, mapViewProperty: strin
if (array.lunar && array.lunar != '') {
frontmatter += `\nlunar phase: ${array.lunar}`
}
if (array.tracker.length != 0) {
if (array.tracker && array.tracker.length != 0) {
for (let string of array.tracker) {
const markdownString = htmlToMarkdown(string);
const key = markdownString.slice(0, markdownString.lastIndexOf(':'));
Expand All @@ -600,7 +600,7 @@ function formatContent(array: any, moment: moment.Moment, mapViewProperty: strin
frontmatter += '\n---';

let body = '';
if (array.heading != '') {
if (array.heading && array.heading != '') {
body += `# ${htmlToMarkdown(array.heading)}\n`;
}
if (array.html && array.html != '') {
Expand All @@ -612,13 +612,13 @@ function formatContent(array: any, moment: moment.Moment, mapViewProperty: strin
frontmatterObj[mapViewProperty] = array.location.toString();
if (array.rating)
frontmatterObj[plugin.settings.ratingProp] = `${array.rating}/5`;
if (array.tags.length != 0) {
if (array.tags && array.tags.length != 0) {
frontmatterObj['tags'] = [];
for (let i in array.tags) {
frontmatterObj['tags'][i] = array.tags[i];
}
}
if (array.people.length != 0) {
if (array.people && array.people.length != 0) {
frontmatterObj['people'] = [];
for (let i in array.people) {
frontmatterObj['people'][i] = array.people[i];
Expand All @@ -633,7 +633,7 @@ function formatContent(array: any, moment: moment.Moment, mapViewProperty: strin
}
if (array.lunar && array.lunar != '')
frontmatterObj['lunar phase'] = array.lunar;
if (array.tracker.length != 0)
if (array.tracker && array.tracker.length != 0)
for (let string of array.tracker) {
const markdownString = htmlToMarkdown(string);
const key = markdownString.slice(0, markdownString.lastIndexOf(':'));
Expand Down

0 comments on commit ae307a4

Please sign in to comment.