cozy/src/pages/index.astro

23 lines
638 B
Text

---
import { extract } from "@extractus/article-extractor";
import AddressBar from "../components/address-bar.astro";
import Post from "../components/post.astro";
import Layout from "../layouts/layout.astro";
const params = Astro.url.searchParams;
const url = params.get('url') || '';
let article;
try {
article = await extract(url);
} catch {
article = {
title: "Something is not right",
content: "<p>The article extractor did not get any result.</p>",
};
}
---
<Layout title={url !== "" ? article?.title : "Your modern-day reading assistant"}>
<AddressBar url={url} />
{url && <Post article={article} />}
</Layout>