Make post component, style list
This commit is contained in:
@@ -12,11 +12,8 @@ import { SITE_TITLE } from "../config";
|
|||||||
</div>
|
</div>
|
||||||
<nav>
|
<nav>
|
||||||
<HeaderLink href="/">home</HeaderLink>
|
<HeaderLink href="/">home</HeaderLink>
|
||||||
<HeaderLink href="/blog">posts</HeaderLink>
|
<HeaderLink href="/posts">posts</HeaderLink>
|
||||||
<HeaderLink href="https://cassidoo.co" target="_blank">website</HeaderLink>
|
<HeaderLink href="https://cassidoo.co" target="_blank">website</HeaderLink>
|
||||||
<HeaderLink href="https://twitter.com/cassidoo" target="_blank"
|
|
||||||
>twitter
|
|
||||||
</HeaderLink>
|
|
||||||
<HeaderLink href="https://cassidoo.co/newsletter" target="_blank"
|
<HeaderLink href="https://cassidoo.co/newsletter" target="_blank"
|
||||||
>newsletter
|
>newsletter
|
||||||
</HeaderLink>
|
</HeaderLink>
|
||||||
|
|||||||
24
src/components/Post.astro
Normal file
24
src/components/Post.astro
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
// import Tag from './Tag.astro';
|
||||||
|
const { slug, title, tags, description, date } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href={`/${slug}/`} class="title">{title}</a>
|
||||||
|
<time datetime={date}>
|
||||||
|
{new Date(date).toLocaleDateString('en-us', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'short',
|
||||||
|
day: 'numeric',
|
||||||
|
})}
|
||||||
|
</time>
|
||||||
|
<br />
|
||||||
|
{description && <span class="excerpt">{description}</span>}
|
||||||
|
<ul>
|
||||||
|
{tags && tags.map(tag => (
|
||||||
|
<li class="tag">
|
||||||
|
<div>{tag}</div>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
@@ -28,7 +28,7 @@ body {
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
color: #444;
|
color: var(--black);
|
||||||
}
|
}
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2,
|
||||||
@@ -38,7 +38,7 @@ h5,
|
|||||||
h6,
|
h6,
|
||||||
strong,
|
strong,
|
||||||
b {
|
b {
|
||||||
color: #222;
|
color: var(--black);
|
||||||
}
|
}
|
||||||
a {
|
a {
|
||||||
color: var(--pink);
|
color: var(--pink);
|
||||||
@@ -82,8 +82,8 @@ pre > code {
|
|||||||
all: unset;
|
all: unset;
|
||||||
}
|
}
|
||||||
blockquote {
|
blockquote {
|
||||||
border: 1px solid #999;
|
border: 1px solid var(--gray);
|
||||||
color: #222;
|
color: var(--black);
|
||||||
padding: 2px 0px 2px 20px;
|
padding: 2px 0px 2px 20px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
@@ -114,3 +114,9 @@ h3 {
|
|||||||
.header-frame {
|
.header-frame {
|
||||||
max-width: 350px;
|
max-width: 350px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul li time {
|
||||||
|
flex: 0 0 130px;
|
||||||
|
font-style: italic;
|
||||||
|
color: var(--gray);
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
import BaseHead from '../components/BaseHead.astro';
|
import BaseHead from '../components/BaseHead.astro';
|
||||||
import Header from '../components/Header.astro';
|
import Header from '../components/Header.astro';
|
||||||
import Footer from '../components/Footer.astro';
|
import Footer from '../components/Footer.astro';
|
||||||
|
import Post from '../components/Post.astro';
|
||||||
|
|
||||||
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
|
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
|
||||||
|
|
||||||
// Use Astro.glob() to fetch all posts, and then sort them by date.
|
// Use Astro.glob() to fetch all posts, and then sort them by date.
|
||||||
const posts = (await Astro.glob('./blog/*.{md,mdx}')).sort(
|
const posts = (await Astro.glob('./post/*.{md,mdx}')).sort(
|
||||||
(a, b) => new Date(b.frontmatter.added).valueOf() - new Date(a.frontmatter.added).valueOf()
|
(a, b) => new Date(b.frontmatter.added).valueOf() - new Date(a.frontmatter.added).valueOf()
|
||||||
);
|
);
|
||||||
---
|
---
|
||||||
@@ -22,11 +24,6 @@ const posts = (await Astro.glob('./blog/*.{md,mdx}')).sort(
|
|||||||
ul li {
|
ul li {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
ul li time {
|
|
||||||
flex: 0 0 130px;
|
|
||||||
font-style: italic;
|
|
||||||
color: #888;
|
|
||||||
}
|
|
||||||
ul li a:visited {
|
ul li a:visited {
|
||||||
color: #8e32dc;
|
color: #8e32dc;
|
||||||
}
|
}
|
||||||
@@ -50,6 +47,13 @@ const posts = (await Astro.glob('./blog/*.{md,mdx}')).sort(
|
|||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{posts.map(
|
||||||
|
({url, frontmatter: { description, slug, title, tags, added: date }}) => (
|
||||||
|
<Post {url} {description} {date} {slug} {title} {tags} />
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
</content>
|
</content>
|
||||||
<Footer />
|
<Footer />
|
||||||
</main>
|
</main>
|
||||||
Reference in New Issue
Block a user