42 lines
1,005 B
Text
42 lines
1,005 B
Text
---
|
|
import { ArticleData, extract } from "@extractus/article-extractor";
|
|
import AddressBar from "../components/AddressBar.astro";
|
|
import Post from "../components/Post.astro";
|
|
import Layout from "../layouts/Layout.astro";
|
|
import Library from "../components/Library.astro";
|
|
|
|
const params = Astro.url.searchParams;
|
|
const url = params.get('url') || '';
|
|
let article: ArticleData | null;
|
|
let skipSave;
|
|
|
|
const error = {
|
|
title: "Something is not right",
|
|
content: "<p>The article extractor did not get any result.</p>",
|
|
}
|
|
|
|
try {
|
|
article = await extract(url);
|
|
if (!article ) {
|
|
article = error;
|
|
skipSave = true;
|
|
}
|
|
} catch {
|
|
article = error;
|
|
skipSave = true;
|
|
}
|
|
|
|
if (url === '') {
|
|
article = {
|
|
title: "Welcome to Cozy 🧸",
|
|
content: "<p>Enter a URL above to get started.</p>",
|
|
url: '/'
|
|
};
|
|
}
|
|
|
|
---
|
|
<Layout meta={article}>
|
|
<AddressBar url={url} />
|
|
<Post slot="post" article={article} />
|
|
<Library skipSave={skipSave} slot="library" postDivSelector="#post"/>
|
|
</Layout>
|