
- global app config via serializer/deserializer - home link becomes router link if js enabled
39 lines
No EOL
1 KiB
Text
39 lines
No EOL
1 KiB
Text
---
|
|
import Serialize from "@ayco/astro-resume";
|
|
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";
|
|
import Footer from "../components/Footer.astro";
|
|
|
|
const appConfig = {
|
|
routerOutlet: 'router-outlet',
|
|
};
|
|
export type AppConfig = typeof appConfig;
|
|
|
|
let url = Astro.url.searchParams.get('url');
|
|
let article: ArticleData | null = {url: '/'};
|
|
|
|
while (url?.startsWith(Astro.url.origin)) {
|
|
url = new URL(url).searchParams.get('url');
|
|
}
|
|
|
|
if (url)
|
|
try {
|
|
article = await extract(url);
|
|
} catch {
|
|
article = null;
|
|
}
|
|
|
|
---
|
|
<Layout article={article}>
|
|
<AddressBar url={url} />
|
|
<div slot="post" id={appConfig.routerOutlet}>
|
|
<Post article={article} />
|
|
</div>
|
|
<Library slot="library" skipSave={article === null} />
|
|
<Footer slot="footer" />
|
|
</Layout>
|
|
|
|
<Serialize id="app-config" data={appConfig} /> |