import { Hono } from "npm:hono";
import Parser from "npm:rss-parser";
const app = new Hono();
app.get("/", (c) => {
return c.json({
type: "list",
list: {
items: [
{
title: "Search Front Page",
actions: [
{
type: "push",
push: {
page: "/frontpage",
},
},
],
},
],
},
});
});
app.get("/frontpage", async (c) => {
const feed = await new Parser().parseURL(
`https://hnrss.org/frontpage?description=0&count=25`,
);
return c.json({
type: "list",
list: {
items: feed.items?.map((item) => ({
title: item.title || "",
actions: [
{
type: "open",
open: {
url: item.link || "",
},
},
{
type: "copy",
copy: {
text: item.link || "",
},
},
],
})),
},
});
});
export default app.fetch;