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?
Okay, I’m not a premium subscriber, so I don’t get archived copies of my bookmarks. 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.
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.
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.
The Bookmarks Shortcode plug-in (BETA) is a thing now, @JohnPhilpin. 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.
{
"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. 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 }}
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”.