Merge pull request #15 from ayoayco/feat/add-library-link-on-address-bar
feat: add library link on to address bar
This commit is contained in:
commit
edaec363c8
3 changed files with 19 additions and 8 deletions
|
@ -27,9 +27,15 @@ const form = new FormGroup([
|
|||
value: "Get cozy!",
|
||||
}}
|
||||
/>
|
||||
<a class="repo-link" href="https://github.com/ayoayco/cozy"
|
||||
>Star on GitHub</a
|
||||
<nav>
|
||||
<a href="/"
|
||||
>📚 Library</a
|
||||
>
|
||||
•
|
||||
<a target="_blank" href="https://github.com/ayoayco/cozy"
|
||||
>⭐️ GitHub</a
|
||||
>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<style is:inline>
|
||||
|
@ -56,8 +62,10 @@ const form = new FormGroup([
|
|||
color: white;
|
||||
font-weight: bolder;
|
||||
}
|
||||
a.repo-link {
|
||||
font-size: small;
|
||||
nav {
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
nav a {
|
||||
color: brown;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -18,7 +18,6 @@ const { title } = Astro.props;
|
|||
<body>
|
||||
<slot />
|
||||
<div id="main-content">
|
||||
<a href="/">Home</a>
|
||||
<div id="post-wrapper">
|
||||
<slot name="post" />
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,7 @@ import Library from "../components/Library.astro";
|
|||
|
||||
const params = Astro.url.searchParams;
|
||||
const url = params.get('url') || '';
|
||||
let article: ArticleData;
|
||||
let article: ArticleData | null;
|
||||
let skipSave;
|
||||
|
||||
const error = {
|
||||
|
@ -16,7 +16,11 @@ const error = {
|
|||
}
|
||||
|
||||
try {
|
||||
article = await extract(url) || error;
|
||||
article = await extract(url);
|
||||
if (!article ) {
|
||||
article = error;
|
||||
skipSave = true;
|
||||
}
|
||||
} catch {
|
||||
article = error;
|
||||
skipSave = true;
|
||||
|
@ -34,5 +38,5 @@ if (url === '') {
|
|||
<Layout title={url !== "" ? article?.title : "Your modern-day reading assistant"}>
|
||||
<AddressBar url={url} />
|
||||
<Post slot="post" article={article} />
|
||||
<Library skipSave={!article || skipSave} slot="library" postDivSelector="#post" />
|
||||
<Library skipSave={skipSave} slot="library" postDivSelector="#post" />
|
||||
</Layout>
|
||||
|
|
Loading…
Reference in a new issue