Add Blog page

This commit is contained in:
Foster Hangdaan 2023-08-05 14:46:03 -04:00
parent e53f775325
commit 4e3f05d0df
Signed by: foster
GPG key ID: E48D7F49A852F112
3 changed files with 91 additions and 0 deletions

View file

@ -0,0 +1,51 @@
.post-list {
list-style: none;
padding-left: 0;
> li {
margin-bottom: 2rem;
&:last-child {
margin-bottom: 0;
}
}
.post-list-description {
margin: 0;
}
.post-list-title {
display: inline-block;
font-weight: bold;
text-decoration: none;
font-size: 1.5rem;
&:hover {
text-decoration: underline;
}
}
.post-list-date {
display: block;
}
.tag-list {
display: flex;
align-items: center;
gap: 0.5rem;
list-style: none;
padding-left: 0;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
> li {
margin: 0;
}
}
}
.no-posts {
text-align: center;
margin: 4rem 0;
h2 {
margin: 0;
color: var(--color-blue);
}
img.icon {
width: 3rem;
height: 3rem;
filter: var(--filter-blue);
}
}

39
blog/index.tsx Normal file
View file

@ -0,0 +1,39 @@
export const title = "Blog";
export const description = "Hello, my friend. Stay a while and listen.";
export const nav_icon = "https://static.fosterhangdaan.com/icons/tabler-icons/latest/svg/news.svg";
export default function({ nav }) {
const sortPosts = (a,b) => {
if (a.data.date < b.data.date) {
return 1;
} else if (a.data.date > b.data.date) {
return -1;
} else {
return 0;
}
};
if (!nav.menu("/blog/posts")) {
return (
<div className="no-posts">
<img src="https://static.fosterhangdaan.com/icons/tabler-icons/latest/svg/square-0-filled.svg" className="icon"/>
<h2>No posts yet.<br/>Check back later.</h2>
</div>
);
}
return (
<ul className="post-list">
{nav.menu("/blog/posts").children.sort(sortPosts).map(post => (
<li className="post-list-item">
<a href={post.data.url} className="post-list-title">{post.data.title}</a>
<time className="post-list-date">{Intl.DateTimeFormat("en-CA", { dateStyle: "long" }).format(post.data.date)}</time>
<ul className="tag-list">
{post.data.tags.map(tag => <li className="tag">{tag}</li>)}
</ul>
<p className="post-list-description">{post.data.description}</p>
</li>
))}
</ul>
);
}

View file

@ -7,6 +7,7 @@
// Pages // Pages
@import "styles/pages/resume"; @import "styles/pages/resume";
@import "styles/pages/blog";
// Components // Components
@import "styles/components/navbar"; @import "styles/components/navbar";