diff --git a/src/components/post.astro b/src/components/post.astro index e2529b3..bbf68e0 100644 --- a/src/components/post.astro +++ b/src/components/post.astro @@ -4,7 +4,7 @@ export interface Props { article: ArticleData; } -const article = Astro.props.article; +const { article } = Astro.props; const datePublished = article?.published && new Date(article.published).toDateString(); --- diff --git a/src/pages/index.astro b/src/pages/index.astro index c4cfb0f..73ab4fa 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,19 +1,22 @@ --- import { extract } from "@extractus/article-extractor"; -import { getParams, isURL } from "../utils"; +import { getParams } from "../utils"; import AddressBar from "../components/address-bar.astro"; import Post from "../components/post.astro"; import Layout from "../layouts/layout.astro"; +// temporary default content while we don't have any good thing to put yet :) +const defaultUrl = "https://github.com/ayoayco/cozy-reader"; const params = getParams(Astro.url); -const url = params?.url; +const url = params?.url || defaultUrl; let article; + try { - article = isURL(url) && (await extract(url)); + article = await extract(url); } catch { article = { title: "Something is not right", - content: "
The article extractor did not get any result
", + content: "The article extractor did not get any result.
", }; } --- diff --git a/src/utils/index.ts b/src/utils/index.ts index a213a7d..6a8c252 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,2 +1 @@ export * from "./get-params"; -export * from "./is-url"; diff --git a/src/utils/is-url.ts b/src/utils/is-url.ts deleted file mode 100644 index 32d69ff..0000000 --- a/src/utils/is-url.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function isURL(str: string): boolean { - // TODO: improve pls - if (!str) return false; - return str.includes("http://") || str.includes("https://"); -}