feat: article component for extracted content
This commit is contained in:
parent
3026b3631e
commit
e9fc737ce3
2 changed files with 18 additions and 3 deletions
14
src/components/article.astro
Normal file
14
src/components/article.astro
Normal 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} />
|
|
@ -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} />
|
||||||
|
|
Loading…
Reference in a new issue