CollectionBuilder / collectionbuilder-sheets

A framework for creating digital exhibits by loading collection metadata directly from a CSV (such as a published Google Sheet!). See the readme for instructions!
https://collectionbuilder.github.io/collectionbuilder-sheets/
MIT License
9 stars 6 forks source link

internal link to items #17

Closed sjgknight closed 1 year ago

sjgknight commented 1 year ago

Hi folks

Is there a way to create internal markdown links to item anchors in the browse view/item pages in the item view? I can see I can link to these using the objectid, but it seems I need to create them as external links (which also means some other functionality doesnt work).

Thanks Simon

evanwill commented 1 year ago

@sjgknight you mean like you want the links inside some descriptive text in a metadata field? With CB-Sheets it isn't easy to add rendering markdown inside a metadata field (but you can do it on CB-GH easily). However, you can use any normal HTML in your metadata values.

So for example, you might have a "description" field value of something like: This item is super interesting and is related to <a href='/item.html?id=test005'>Test 05</a> which is also in this collection.

Note in CB-Sheets the metadata is entirely handled by JS after the site is built, so none of the tools of Jekyll are available, so you can't render markdown or use Liquid.

sjgknight commented 1 year ago

@evanwill hm, I mean e.g. I'd want to refer to an item in a regular page/post. I'd hoped that because the identifiers are stable (and, at least some of them known prior to build). So that's not quite the same as your example insofar as that would be (I assume) in a yaml header somewhere, or in my sheetsdata (interesting idea though). Background context, I was having a play at combining the collectionbuilder and a digital garden template.

So I guess the issue is that for Liquid the links actually have to be 'there', they can't just be links to objects that'll be rendered post-build. That's useful, I can have a think about alternatives, I guess a template that interprets some href links specially.

evanwill commented 1 year ago

Sorry, I am still not sure I understand-- The content pages of the site (About pages, etc) are rendered by Jekyll, so can use Liquid and Markdown. You can create links to things that don't exist yet!

If you mean you want to link to an individual item page, e.g. https://collectionbuilder.github.io/collectionbuilder-gh/item.html?id=demo_001 from any Markdown page in your site, you can use Liquid like this: [link to an item]({{ '/item.html?id=demo_001' | relative_url }})

The Liquid relative_url figures out the link for you based on the "baseurl" and "url" values in your "_config.yml" which is helpful for development and if your site might move hosting locations. You can also just manually create the relative link, just keep in mind the baseurl where your site is hosted, e.g. a link from the About page of the demo CB-GH site above would be: [example](/collectionbuilder-gh/item.html?id=demo_001)

If you want to link to a subset on the Browse page, you can add a hash # at the end, like [items about farms]({{ '/browse.html#farms' | relative_url }})

Let me know what you are thinking!

sjgknight commented 1 year ago

Thanks for the examples and clarification! I think this is a 'me problem', so happy to look elsewhere to fix it up. I think something I've added beyond collectionbuilder isn't treating these links as internal links (so e.g. they open in a new tab), so I know I need to find where that issue's arising. Thanks again