Bases "Tags: " + tags shows the tags as text rather than links

What I’m trying to do

I want my lists and my tags displayed in a single bases cell, where I combine a string ("lists: ") with the list of items. In the green box below, I want to add "Lists: " before the list is displayed, and then "Tags: " in front of the list of tags.

What I’ve Tried

But whenever I use "lists: " + lists, I get `lists: [[2016 They Shoot Pictures Don’t they]],

Current formula:

[
[if(lists.isEmpty(), "", lists)],
["   "],
[if(file.tags.isEmpty(), "", file.tags)]
]

When I add the titles I want, using this code:

[
[if(lists.isEmpty(), "", "Lists: " + lists)],
["   "],
[if(file.tags.isEmpty(), "", "Tags: " + file.tags)]
]

I’ve tried a few other things, like putting the ‘titles’ outside of the square brackets, but the bracets aren’t the issue. Even just displaying "keywords: " + keywords in a cell will display the list as strings.

Try this:

[[if(yourList, "list:"), yourList.map(value)].flat(), [if(file.tags, "tags:"), file.tags].flat()]

Replace yourList with your list.


Breakdown

This should retain the link formatting in your lists while prefixing with a label:

["list:", yourList.map(value)].flat()

You can add your conditionals.

For the tags, add its label and list to the same []-array if you want to return them in one line. Or use a list of lists (of, technically, lists) if you want them on two lines:

[["list:", yourList.map(value)].flat(), ["tags:", file.tags].flat()]

Hey dawni,

Thanks for the quick response.

using map(value) worked for those cases where there were multiple lists, but not for when there was just a single list.
image

I found two ways of fixing this that worked perfectly.

Avoid using map and treat the lists like the tags (in other words just straight flat without map_:

[[if(lists, "lists: "), lists].flat(), [if(file.tags, "tags: "), file.tags].flat()]

Or retain map, but add a mising `list(MyKey).map (where Mykey is the frontmatter key ‘lists’.

[["list:", list(lists).map(value)].flat(), ["tags:", file.tags].flat()]

and with my conditionals:

[[if(lists, "lists: "), list(lists).map(value)].flat(), [if(file.tags, "tags: "), file.tags].flat()]

So thanks so much for your suggestion. I learned a few things, which is always ‘the bingo’.

Now if I can only figure out how to join the lists while maintaining the links…


If anyone is interested, this is what the final table looks like:

[
[file.folder, ">", link(file.name)],
[runtime + " mins"],
[" "],
[
[if(lists, "lists: "), list(lists).map(value)].flat(), [if(file.tags, "tags: "), file.tags].flat()]
]

using map(value) worked for those cases where there were multiple lists, but not for when there was just a single list

It works on lists, even lists with only one item. It doesn’t work on strings. The best way to address that is to standardize your syntax.

A list-type property should be:

lists:
  - "[[link 1]]"

even when it has only one value. Not:

lists: "[[link 1]]"

The Linter community plugin or another text editor’s regex search-and-replace can get it done. Then you won’t need a workaround.

Now if I can only figure out how to join the lists while maintaining the links…

Where are you getting separate lists that you can’t “join”?

(The first response was to show how to display list items together while preserving their formatting. So I’m not clear on where you can’t apply it.)

If you just mean you want lists and tags on the same line, then put them all in the same array instead of two. I tried to make it clear that the second demo uses separate bracketed arrays for the purpose of making two lines, and it looks like you chose that one anyway.

Or do you mean somewhere else?