Displaying Bookmarks Publicly

Is there a way to display bookmarks publicly like there is with bookshelves?

For example, I can use the following to display Books I’m reading:

{{ range .Site.Data.bookshelves.currentlyreading }}
    <p class="bookshelf_book">
        <a href="https://micro.blog/books/{{ .isbn }}">
            <img src="{{ .cover_url }}"> <span class="bookshelf_title">{{ .title }}</span>
            <br>
            <span class="bookshelf_author">by {{ .author }}</span>
        </a>
    </p>
{{ end }}

Is there a way to do something similar with bookmarks I’ve saved?

I’ve considered using something like FeedRoll to display the provided Bookmarks JSON feed, but it automatically duplicates every single entry.

Yes, you can do something like this:

{{ $bookmarks := getJSON "https://micro.blog/feeds/yourname/bookmarks/decc3dfad46628dc2cac.json" }}

{{ range $bookmarks.items }}
  <div class="h-entry">
    <a class="u-bookmark-of h-cite" href="{{ .url }}">
      <p>{{ .content_html | plainify | truncate 140 }}</p>
    </a>
  </div>
{{ end }}

The example above prints a short summary for every bookmark and links to it. But there’s more data in the feed you can choose to expose if you want to.

Ah, I should’ve known you would have the answer! Thank you! Having not tested it yet, does it deal with the duplicate item issue or does it list every bookmark twice?

It lists whatever you have in your JSON feed. I don’t have duplicate entries in my feed, but maybe something is up with yours?

For a little clarity, this is what I’m referencing. Maybe I’m missing something or in your brilliance you fixed yours somehow.

UPDATE: In that conversation, I’m saying RSS but I mean JSON.

Okay, I’m not a premium subscriber, so I don’t get archived copies of my bookmarks. :blush: As long as there’s a way to distinguish the original from the archived version, we could eliminate the duplicates.

We can hopefully figure something out if you’re willing to share an example. Do not share the URL to the feed; that’s private. Instead, copy and paste one original/archive pair of bookmarks.

If I understand your meaning, the only differences in the feed items seems to be that the archived version has a title set whereas the standard one doesn’t…and the id has a link prefix.

    {
      "id": "link470113",
      "title": "Title of Page",
      "content_html": "<p>Content here</p>",
      "url": "amazonarchivedurlgoeshere.net",
      "date_published": "2022-12-03T20:15:10+00:00",
      "author": {
        "name": "John Smith",
        "url": "https://url.net",
        "avatar": "avatar.jpg",
        "_microblog": {
          "username": "name"
        }
      }
    },
    {
      "id": "14630634",
      "content_html": "<p>Content here</p>",
      "url": "https://url.net/",
      "date_published": "2022-12-02T21:48:59+00:00",
      "author": {
        "name": "John Smith",
        "url": "https://url.net",
        "avatar": "avatar.jpg",
        "_microblog": {
          "username": "name"
        }
      }
    }

Just to make it simpler, I obviously replaced the info with filler.

That may not be it. For example, I see title in my feed for bookmarks with a title. And I see the link prefix as well. But could we tell them apart by the URL? Is there a common prefix or other patterns for the archived versions?

Update: I might have confused myself. This may be the solution after all. Can you try the following snippet, @Mtt?

{{ $bookmarks := getJSON "https://micro.blog/feeds/yourname/bookmarks/decc3dfad46628dc2cac.json" }}

{{ range $bookmarks.items }}
  {{ if not .title }}
    <div class="h-entry">
      <a class="u-bookmark-of h-cite" href="{{ .url }}">
        <p>{{ .content_html | plainify | truncate 140 }}</p>
      </a>
    </div>
  {{ end }}
{{ end }}

Interesting thread here - this might allow me to repurpose my bookmarks for something else I have been thinking about … BUT … I am clearly doing it wrong - how do you add any of this code to the site? It isn’t on the page itself I assume?

You’re right; these snippets can’t go into a page or post. They have to be included in a custom template. Or one could construct a shortcode for easy inclusion anywhere.

I might get around to releasing this as a plug-in in the future, if no one beats me to it. :blush:

I thought the same too. Check out the thread linked in @jsonbecker’s response.

1 Like

This does work and might be as close as possible to achieving what I’m going for; however, the content.html part automatically includes added “footer” text. The only solution I can come up with is to limit the truncation further so that gets chopped off. But by doing that, defeats the goal of what I want to do.

I also tried automatically importing the JSON feed through the Micro.blog import tool (then I could run a filter to categorize it), but it won’t allow importing from M.b sources.

So I feel like every solution gets me 90% of the way there. Might be something to put on the back burner and see if things change on any part of it.

What do you mean by footer text? Can you provide an example?

content_html is the actual content from the page you’ve bookmarked. So it will vary greatly depending on which websites you’re bookmarking. It’s probably hard to come up with a general solution, unfortunately.

Sorry, I could’ve worded that better. Within the content, the text “Read: link.com” is appended at the end for every link.

Okay, it could probably be solved as long as it’s consistent. Can you provide an unaltered bookmark from your JSON feed? Something like this:

{
  "id": "14915304",
  "content_html": "Bookmark improvements in Micro.blog <a href=\"https://www.manton.org/2022/03/23/bookmark-improvements-in.html\">manton.org</a>",
  "url": "https://www.manton.org/2022/03/23/bookmark-improvements-in.html",
  "date_published": "2022-03-23T14:54:40+00:00",
  "author": {
    "name": "Manton.org",
    "url": "http://Manton.org/",
    "avatar": "https://micro.blog/photos/200/https%3A%2F%2Fmicro.blog%2Fmanton%2Ffavicon.png",
    "_microblog": {
      "username": "manton.org"
    }
  }
}

The Bookmarks Shortcode plug-in (BETA) is a thing now, @JohnPhilpin. :blush: Install, add your bookmarks JSON feed in the settings, and paste this snippet on any page: {{< bookmarks />}}. More detailed instructions can be found on the plug-in page.

1 Like

Here ya go:

    {
      "id": "14630634",
      "content_html": "<p>For today's <a href=\"https://dahlstrand.net/search-space/?q=%23FeedReaderFriday\">#FeedReaderFriday</a>, I made my RSS feed prettier. Before, the browser served a bunch of messy XML, but now you're greeted by <a href=\"https://dahlstrand.net/notes/feed.xml\">a friendly preview and instructions</a>. 🥳</p>\n\n<p>Based on <a href=\"https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl\">pretty-feed.xsl</a> by Matt Webb. You should add <a href=\"https://interconnected.org/home/\">Matt's blog</a> to your feed reader! 👀</p>\n\n<p><img src=\"https://cdn.micro.blog/photos/1000x/https%3A%2F%2Fdahlstrand.net%2Fimages%2Fpretty-rss.png\" alt=\"A split view of the same web feed: before and after. The before shows a plain text XML representation of content. Boring! The after shows a pretty-looking preview of the same.\" width=\"1224\" height=\"1224\" loading=\"lazy\"></p><p class=\"post_archived_links\">Read: <a href=\"https://micro.blog/bookmarks/470113\">dahlstrand.net</a> </p>",
      "url": "https://dahlstrand.net/1670017739/",
      "date_published": "2022-12-02T21:48:59+00:00",
      "author": {
        "name": "Sven Dahlstrand",
        "url": "https://dahlstrand.net",
        "avatar": "https://avatars.micro.blog/avatars/2022/38001.jpg",
        "_microblog": {
          "username": "sod"
        }
      }
    }

What a nice bookmark you got there. :wink: You could remove the offending HTML with Hugo’s replaceRE: replaceRE "<p class=\"post_archived_links\">.+</p>" "". Merged with the previous example:

{{ $bookmarks := getJSON "https://micro.blog/feeds/yourname/bookmarks/decc3dfad46628dc2cac.json" }}

{{ range $bookmarks.items }}
  {{ if not .title }}
    <div class="h-entry">
      <a class="u-bookmark-of h-cite" href="{{ .url }}">
        <p>{{ .content_html | replaceRE "<p class=\"post_archived_links\">.+</p>" "" | plainify | truncate 140 }}</p>
      </a>
    </div>
  {{ end }}
{{ end }}

well - look at that - of course you have … and of course I tried it … and of course it isn’t working for me :frowning:

I am pretty sure that I am using the wrong JSON

This is clearly not right

https://micro.blog/feeds/johnphilpin/bookmarks/decc3dfad46628dc2cac.json

but have tried this and various versions - to no avail - except on one occasion where it all appeared - I danced for joy and then it went away again.

No, that looks like my made-up example, slightly modified. You’ll want your personal (secret) URL found on this page. There’s a link at the bottom: “Saved bookmarks go in your unique read later feed”.