lachholden / obsidian-recipe-view

View your Obsidian notes as interactive recipe cards while you cook.
https://obsidian-recipe-view.readthedocs.io/en/latest/
MIT License
105 stars 4 forks source link

Doesn't work well with metadata #16

Open c-sattler opened 12 months ago

c-sattler commented 12 months ago

I'm using the Recipe Grabber plugin on Obsidian to pull in recipes from the web. When I try to display them in Recipe View I get a blank view. If I delete the metadata section that Recipe Grabber puts at the front of each note it seems to work fine. Could you modify your plugin to ignore a section of metadata (anything between lines containing "---") at the top of the recipe note file?

lachholden commented 12 months ago

Could you please post an example of the properties that don't display properly? I do need to update the property-handling code for #15 too.

c-sattler commented 12 months ago

Below is a recipe note created by Recipe Grabber. Note that all of the keys of the key/value pairs have a single ":". I found that if I change these to "::" (Double colons) recipe view works fine. The key/value pairs are displayed properly beneath the recipe title and next to the picture. I'm not sure about #15, the key/value pairs (properties) seem to work consistently once I changed the colons to double colons. Recipe Grabber contains a template of the recipe note in its settings so I was able to change the colons in the temple to double colons and new recipes that are grabbed work with Recipe View. You can consider my issue as resolved.

Almond Cookies

tags: recipe, cookie, glutin free type: recipe created: 2023-08-31T16:58:29.607-04:00 author: url: https://www.bonappetit.com/recipe/almond-cookies

Almond Cookies

(https://www.bonappetit.com/recipe/almond-cookies)

Naturally gluten- and dairy-free, this easy recipe for flourless almond cookies has a hint of rose water. Make them for Passover, New Year’s Eve, or anytime.

Almond Cookies

Ingredients

Instructions


Notes

Merrit commented 10 months ago

Having the same issue. Here's my example of a recipe I just pulled in that displays blank:

---
tags: recipe 
url: https://forksandfoliage.com/easiest-toum-garlic-dip/ 
---

Creamy, fluffy, and super garlicky - toum is the flavor bomb missing in your kitchen. Pair it with grilled chicken, roasted veggies, and french fries. This recipe comes together in just a few minutes and you don't need a food processor - it's the absolute easiest!

![Easiest Toum Ever (Lebanese Garlic Dip)](https://forksandfoliage.com/wp-content/uploads/2022/04/Toum-Spread-in-Lebanese-Bowl-2-1.jpg)

## Ingredients

- 1 cup garlic cloves (peeled)
- 1 teaspoon kosher salt
- 1/4 cup lemon juice
- 2 cups neutral oil (such as avocado, canola, or grapeseed)

## Directions

- Peel the garlic cloves and place them in a wide mouth quart jar or similar sized container, then add the salt and lemon juice.
- Using an immersion blender, blend the mixture until it resembles a paste.
- Add all the oil on top of the mixture, then the place immersion blender at the very bottom. Start blending without raising it up. As the mixture emulsifies, gradually raise the blender until the whole mixture is white and fluffy.
- Place a lid on the jar and chill in the fridge, ideally overnight, for best flavor.

-----

## Notes
jane-t commented 10 months ago

A related problem. I normally use a template with some blank properties, if any are left blank the whole page disappears in recipe view, deleting the empty properties seems to fix the problem.

adsilcott commented 10 months ago

Definitely having this problem. Recipe Grabber seems to add an Author property, I've found that removing that, whether empty or not, lets the recipe render. Otherwise it's a blank page.

ClockDk commented 10 months ago

A related problem. I normally use a template with some blank properties, if any are left blank the whole page disappears in recipe view, deleting the empty properties seems to fix the problem.

I have the same problem, but it only occurs, when i have the "tags" properties added :)

deafmute1 commented 10 months ago

So I've been trying to find a workaround to this issue, and it seems to actually doesn't matter what the frontmatter contains, it will display a blank page on a freshly created recipe (in this case, generated by the Recipe Grabber plugin). However, simply editing the properties of the recipe after creation, even if you immediately reverse the change, seems to be a 100% reliable workaround. So i delete a single character from a property, click away, then add the character back and the recipe always displays fine from then on.

spikex commented 9 months ago

The problem is how Recipe Grabber creates the tags front matter. It creates:

tags: recipe

However, Obsidian wants tags to be an array:

tags:
  - recipe

If you edit any properties, Obsidian corrects the tags property when writing the new front matter, which is why any edit fixes it.

Change the Recipe Grabber template to:

---
tags: 
    - recipe 
created: {{datePublished}}
author: {{author.name}}
url: {{url}} 
---

and Recipe Grabber will work out of the box.

Technically, this isn't Recipe View's problem, but treating tags: recipe as if it were an array would prevent the crash.

Merrit commented 9 months ago

Tested just now on the same link that failed for me before, and it worked correctly. Seems promising - thanks @spikex!