tokenshift / obsidian-page-gallery

Generates a gallery based on selected page contents.
MIT License
68 stars 2 forks source link

Rendering as Markdown #34

Closed Bluemoondragon07 closed 1 year ago

Bluemoondragon07 commented 1 year ago

Thank you so much for your hard work maintaining this awesome plug-in! Just something I noticed after recent updates to add views: certain fields and groupBy headings don't render as markdown anymore. I noticed that link headings just render as raw text with double brackets and oddly, single tags are also raw text, but a list of tags is displayed correctly. This isn't at all an urgent bug, just something I noticed from the updates.

Also, I recommend putting a code block example of a page gallery with views on the README file. I can't figure out how the views field works. But again, not anything urgent. That can totally wait as well.

Again, thanks for your work on this plug-in. I've been trying to learn typescript by looking at all your code changes 🙂.

tokenshift commented 1 year ago

Here's a quick views example to get you started (I'll add something more comprehensive to the README when I get a chance):

title: Testing Multiple Views
fields: [file.name, file etags]
size: contain
views:
  - name: Test View 1
    from: '"Test Gallery"'
  - name: Test View 2
    from: '"Stuff"'
    orientation: landscape
    columns: 3

Can you add some examples of field values that should be rendered as markdown rather than raw values? I'm still trying to figure out a way to automatically determine what values are actually "things that should be rendered" or not, since just rendering everything causes other problems.

Bluemoondragon07 commented 1 year ago

Thanks for the example!

So, here's a page gallery block that's supposed to group by mother-location, which is always a link to another "location" file. One of the fields it is supposed to display is location-type, which is always a tag.

Page-block

This is how it is rendered:

page-gallery

You may also have noticed that both tiles in the picture should actually be under the same group, as they are linked to the same file. Both the tags and the links are plain text.

And down here, you can see that when it is a single tag, it just renders the text. But when it is more than one tag, it renders the tags.

tags

Although, the links inside the tiles render perfectly fine.


As for rendering...Maybe if a heading or tile field contains a, like a link or a tag, the heading can render as markdown. Otherwise, render as plain text.

Or, maybe it doesn't work like that. Maybe the plug-in would have to scan for double brackets and #s. But then you'd have to be careful about #s followed by a space, because that would render a heading. Yeah, I can see now how things like this could get complicated easily.

tokenshift commented 1 year ago

I think I've fixed the rendering and the group-by comparison issue in v0.5.4, at least for certain value types (tested with links, single tags, and multiple tags). I've got a appearsRenderable function now that will look at a value and return whether or not page-gallery should treat it as something that should be rendered, which will hopefully make it easier to add additional things that should be rendered in the future (and fix the inevitable edge cases that I'm sure are going to pop up). Let me know if you still see any issues, and thanks for the bug report.

Bluemoondragon07 commented 1 year ago

Thanks for the fix--that was fast, too! Everything works perfectly now!