Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Tilt feed component
import { renderMarkdown, useCollection, useFiles, usePage, useSite, xml } from "../packages/tilt/index.js";
export default function Feed(props, children) {
const site = useSite()
const posts = useCollection('posts')
const buildDate = (new Date()).toUTCString()
return xml`<?xml version="1.0" encoding="UTF-8"?>
xmlns:atom="" version="2.0">
<atom:link href="${site.url}/feed.xml" rel="self" type="application/rss+xml"/>
${posts.slice(0, 5).map(post => xml`
${Item({, author:, category: getCategory(post) })}
function Item({ title, description, permalink, category, date, author }, children) {
date = date instanceof Date ? date.toUTCString() : date
return xml`
<guid isPermaLink="true">${permalink}</guid>
const getCategory = (post) =>
(post.categories[0] || []).map(c =>'/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment