Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vkostyanetsky committed Apr 7, 2024
1 parent 07f5eef commit 43247e8
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Changelog

## 1.2.0 - ?
## 1.2.0 - 2024-04-07

### Added

* The code block now shows error is a product` property type is not number.
* Now it is possible to set product' aliases and use them in a code block.

### Changed

* Made products search case insensitive (for example, "apple" now matches with "Apple").

## 1.1.0 - 2024-03-30

### Added
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": "foodiary",
"name": "Foodiary",
"version": "1.1.0",
"version": "1.2.0",
"minAppVersion": "1.5.3",
"description": "Food tracker, macronutrient and calorie calculator.",
"author": "vkostyanetsky",
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": "foodiary",
"version": "1.1.0",
"version": "1.2.0",
"description": "Food tracker plugin for Obsidian.",
"main": "main.js",
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions src/codeblocks/foodiary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class FoodiaryCodeBlock {

tr = table.createEl("tr")

tr.createEl("td", {text: item.product.titles[0]})
tr.createEl("td", {text: item.product.title})
tr.createEl("td", {text: item.value.calories.toString()})
tr.createEl("td", {text: item.value.protein.toString()})
tr.createEl("td", {text: item.value.fat.toString()})
Expand Down Expand Up @@ -81,8 +81,10 @@ export default class FoodiaryCodeBlock {
if (! entry.title) {
continue
}

let product = products.find(el => el.titles.find(el => el == entry.title))

let titleToSearch = entry.title.toLowerCase()

let product = products.find(el => el.titles.find(el => el == titleToSearch))

if (product === undefined) {
result.unknownProducts.push(entry.title)
Expand Down
5 changes: 3 additions & 2 deletions src/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ export default class FoodiaryProducts {

if (productProperties != undefined) {

let titles = [file.basename]
let titles = [file.basename.toLowerCase()]

if (productProperties.aliases !== undefined) {
productProperties.aliases.forEach((element: string) => {
titles.push(element)
titles.push(element.toLowerCase())
});
}

let product = {
title: file.basename,
titles: titles,
value: {
calories: productProperties[plugin.settings.propertyCalories],
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface Product {
title: string;
titles: Array<string>;
value: NutritionalValue
}
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"1.0.0": "1.5.3",
"1.0.1": "1.5.3",
"1.1.0": "1.5.3"
"1.1.0": "1.5.3",
"1.2.0": "1.5.3"
}

0 comments on commit 43247e8

Please sign in to comment.