feat: Home link
This commit is contained in:
parent
4c07beca9a
commit
fc1818b915
3 changed files with 3 additions and 9 deletions
|
@ -62,13 +62,7 @@ const {postDivSelector, skipSave = false} = Astro.props;
|
||||||
html.innerHTML = responseText;
|
html.innerHTML = responseText;
|
||||||
const newPost = html.querySelector('body')?.querySelector('#post');
|
const newPost = html.querySelector('body')?.querySelector('#post');
|
||||||
if (postDiv && newPost?.innerHTML) {
|
if (postDiv && newPost?.innerHTML) {
|
||||||
const homeLink = document.createElement('a');
|
postDiv.innerHTML = newPost.innerHTML
|
||||||
homeLink.href = '/';
|
|
||||||
homeLink.innerText = 'Home';
|
|
||||||
postDiv.innerHTML = (newPost.innerHTML)
|
|
||||||
const homeLinkWrapper = document.createElement('div');
|
|
||||||
homeLinkWrapper.append(homeLink)
|
|
||||||
postDiv.insertBefore(homeLinkWrapper, postDiv.firstChild);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const item = document.createElement('li');
|
const item = document.createElement('li');
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
import { ArticleData } from "@extractus/article-extractor";
|
import { ArticleData } from "@extractus/article-extractor";
|
||||||
export interface Props {
|
export interface Props {
|
||||||
article: ArticleData;
|
article: ArticleData;
|
||||||
isHome?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { article, isHome = false } = Astro.props;
|
const { article } = Astro.props;
|
||||||
const datePublished =
|
const datePublished =
|
||||||
article?.published && new Date(article.published).toDateString();
|
article?.published && new Date(article.published).toDateString();
|
||||||
---
|
---
|
||||||
|
|
|
@ -18,6 +18,7 @@ const { title } = Astro.props;
|
||||||
<body>
|
<body>
|
||||||
<slot />
|
<slot />
|
||||||
<div id="main-content">
|
<div id="main-content">
|
||||||
|
<a href="/">Home</a>
|
||||||
<div id="post-wrapper">
|
<div id="post-wrapper">
|
||||||
<slot name="post" />
|
<slot name="post" />
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue