Havn
February 13, 2024, 10:58pm
1
How should I make a feed with just micro posts/posts without title - but no replies?
I’ve done this, at it kinda works:.
{{ define "main" }}
<div>
{{ range .Site.RegularPages }} {{ if not .Title }}
<div class="micro-post">
<a href="{{ .Permalink }}" class="post-date u-url"><time class="dt-published" datetime="{{ .Date.Format "2006-01-02 15:04:05 -0700" }}">{{ .Date.Format "Jan 2, 2006" }}</time> ∞</a>
<p>{{ .Content }}</p>
</div>
{{ end }} {{ end }}
</div>
{{ end }}
That includes every post without a title - but it also replies. How can I exclude them?
What’s the code behind the “Replies” custom page? If I knew how that was made, I could to the sysdiff thing mentioned here and remove them, perhaps?
Any advice?
Thanks!
{{ range where .Site.Pages "Type" "post"}}
Replies are a page type. Almost all themes if you check them out on Github specifically filter to “Type” “post” for this reason.
I encourage anyone messing with templates to start on Micro.blog’s Github repos where you can find all the themes and learn quite a bit about the structure of things.
1 Like
Havn
February 14, 2024, 9:05am
3
Yeah, I tried to poke around a bit to find it somewhere - but couldn’t find anything that helped.
BTW. using what you wrote, still gives me the replies as well in the feed. (Replies I’ve written, that is.)
I also tried to add the line before from the Tiny theme, so now it’s like this:
{{ define "main" }}
<div>
{{ $paginator := .Paginate (where .Site.Pages.ByDate.Reverse "Type" "post") }}
{{ range where .Site.Pages "Type" "post"}}
<div class="micro-post">
<a href="{{ .Permalink }}" class="post-date u-url"><time class="dt-published" datetime="{{ .Date.Format "2006-01-02 15:04:05 -0700" }}">{{ .Date.Format "Jan 2, 2006" }}</time> ∞</a>
<p>{{ .Content }}</p>
</div>
{{ end }} {{ end }}
</div>
{{ end }}
Edit: This worked!
{{ define "main" }}
<div>
{{ $paginator := .Paginate (where .Site.Pages.ByDate.Reverse "Type" "post") }}
{{ range where .Site.Pages "Type" "post" }}
{{ if not .Title }}
<div class="micro-post">
<a href="{{ .Permalink }}" class="post-date u-url"><time class="dt-published" datetime="{{ .Date.Format "2006-01-02 15:04:05 -0700" }}">{{ .Date.Format "Jan 2, 2006" }}</time> ∞</a>
<p>{{ .Content }}</p>
</div>
{{ end }}
{{ end }}
</div>
{{ end }}