34 lines
849 B
Text
34 lines
849 B
Text
---
|
|
import Form, { FormGroup } from "@astro-reactive/form";
|
|
import { Validators } from "@astro-reactive/validator";
|
|
import { extract } from "@extractus/article-extractor";
|
|
import Article from "../components/article.astro";
|
|
import { getParams, isURL } from "../utils";
|
|
|
|
const params = getParams(Astro.url);
|
|
const url: string = params?.url;
|
|
const article = isURL(url) && (await extract(url));
|
|
|
|
const form = new FormGroup([
|
|
{
|
|
type: "text",
|
|
name: "url",
|
|
value: url || "",
|
|
placeholder: "Put the URL here",
|
|
validators: [Validators.required, Validators.minLength(11)],
|
|
},
|
|
]);
|
|
---
|
|
|
|
<Form
|
|
formGroups={form}
|
|
showValidationHints
|
|
submitControl={{
|
|
type: "submit",
|
|
name: "submit",
|
|
value: "Get cozy!",
|
|
}}
|
|
/>
|
|
<a href="https://github.com/ayoayco/cozy-reader" target="_blank">Source code</a>
|
|
|
|
<Article article={article} />
|