retypeapp / retype

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.
https://retype.com
Other
1.01k stars 201 forks source link

Blog style card for latest blog post highlighted on a different page (e.g. the main index.md for the site) #685

Open kcowgill opened 4 months ago

kcowgill commented 4 months ago

I spent some time trying to dig into what was available via templating to see if I could come up with a way to duplicate what the /blog endpoint does - produce a title/summary card for files in the /blog directory - but if I could grab the information/card for only the latest one to put into my main index.md (so it would be updated automatically on site regeneration)... something like this:

# Main page

Welcome to our page!

:::latest_blog
:icon-megaphone: <strong>{{ blog_title }}</strong> <i>{{ blog_date }}</i>: {{ blog_excerpt }}
:::

More main page content, etc

I even resorted to some ugly bash-fu to do that but ran into styling issues because I'm terrible with CSS. I'm able to update the frontmatter to include this data: chunk:

---
icon: home
label: Site Overview
templating: true
data:
   blog_title: Exercitation Ullamco
   blog_file: blog/lorem.md
   blog_date: 2024-03-01
   blog_excerpt: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud ...
 ---

But then in thinking about it - the blog layout must have SOME way of generating /blog/index.html to contain those summary cards, is there some other way to get at that information?