You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My use case is to add a prefix to a list of values, for example I want to extract Genres from a Goodreads page, and turn that into a list of Wikilink like this: ["genres/Nonfiction", "genres/Fitness"]. I thought that it is possible to do this with map and template filters but it turned out they only work with object-based items, not strings.
Describe the solution you'd like
There are 2 ways transforming list of strings like above can be done:
Allowing map to convert a string to an object then use template e.g. map:item => {str: item}|template:"genres/${str}"
A keyword such as _item to refer to the original item e.g. template:"genres/${_item}
The text was updated successfully, but these errors were encountered:
9diov
changed the title
Allowing map filter to work with string literal
Allowing map or template filter to work with string literal
Oct 7, 2024
Hi, I am trying to do something similar.
On a Medium.com Article page I find the tags which I than |map and want to prepend "Medium/" to the tags.
Expected output:
tags:
- Medium
- Medium/Cooking
- Medium/Healthy-Lifestyle
I tried a few things and believe this should be close: Medium, {{selector:a[href*='/tag/']|map:item => item|template:'Medium/${item}'|replace:' ':'-'|join:', '}}
but that gives me Medium, Medium/Medium/Medium/Medium/Medium/
Please help.
btw the Clipper is a Godsend, I was trying to get my Medium articles in Obsidian with the unofficial Medium API on RapidAPI but Clipper is gonna be so much cooler!
EDIT: looking better at the OP example I came up with: Medium, {{selector:a[href*='/tag/']|map:item => {str: item}|template:"Medium/${str}, "|replace:' ':'-'|join}}
It gives me the desired output. Is this correct? Instead of delimiting the comma with |join do it in the |template?
My use case is to add a prefix to a list of values, for example I want to extract Genres from a Goodreads page, and turn that into a list of Wikilink like this: ["genres/Nonfiction", "genres/Fitness"]. I thought that it is possible to do this with
map
andtemplate
filters but it turned out they only work with object-based items, not strings.Describe the solution you'd like
There are 2 ways transforming list of strings like above can be done:
map
to convert a string to an object then usetemplate
e.g.map:item => {str: item}|template:"genres/${str}"
_item
to refer to the original item e.g.template:"genres/${_item}
The text was updated successfully, but these errors were encountered: