feat: article component for extracted content

This commit is contained in:
Ayo 2023-05-11 16:42:15 +02:00
parent 3026b3631e
commit e9fc737ce3
2 changed files with 18 additions and 3 deletions

View file

@ -0,0 +1,14 @@
---
import { ArticleData } from "@extractus/article-extractor";
const article = Astro.props.article;
export interface Props {
article: ArticleData;
}
---
<h2>{article.title}</h2>
<p>by <em>{article.author}</em></p>
<span set:html={article.content} />

View file

@ -1,12 +1,13 @@
--- ---
import Form, { FormGroup } from "@astro-reactive/form"; import Form, { FormGroup } from "@astro-reactive/form";
import { Validators } from "@astro-reactive/validator"; import { Validators } from "@astro-reactive/validator";
import { extract } from "@extractus/article-extractor";
import getParams from "../utils/get-params"; import getParams from "../utils/get-params";
import { extract } from "@extractus/article-extractor";
import Article from "../components/article.astro";
const params = getParams(Astro.url); const params = getParams(Astro.url);
const url = params?.url; const url = params?.url;
const article = extract(url); const article = await extract(url);
const form = new FormGroup([ const form = new FormGroup([
{ {
@ -29,4 +30,4 @@ const form = new FormGroup([
}} }}
/> />
{article ? <p>{JSON.stringify(article)}</p> : "<hr />"} <Article article={article} />