-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
470252f
commit f15f0d8
Showing
4 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
import BaseLayout from "$layouts/BaseLayout.astro" | ||
import ArticlePreview from "$components/ArticlePreview.astro" | ||
import { postProcessArticle } from "$data/articles" | ||
export async function getStaticPaths({ paginate }) { | ||
let articles = await Astro.fetchContent("../../../../content/articles/**/*.md") | ||
articles = articles | ||
.map((article) => postProcessArticle(article)) | ||
.sort((a, b) => { | ||
return b.date.getTime() - a.date.getTime() | ||
}) | ||
const tagList = new Array() | ||
articles.forEach((article) => { | ||
tagList.push(...article.tags) | ||
}) | ||
return tagList.map((tag) => { | ||
const filteredArticles = articles.filter((article) => article.tags.includes(tag)) | ||
return paginate(filteredArticles, { params: { tag }, pageSize: 5 }) | ||
}) | ||
} | ||
const { page } = Astro.props | ||
--- | ||
|
||
<BaseLayout title="Articles"> | ||
<article class="w-articleList mx-auto flex flex-col md:flex-row"> | ||
<div class="sm:w-[80%]"> | ||
<h2>Articles</h2> | ||
{page.data.map((item) => <ArticlePreview article={item} />)} | ||
</div> | ||
|
||
<aside class="sm:w-[20%]"> | ||
<section> | ||
<h2>Tags</h2> | ||
<ul></ul> | ||
</section> | ||
<section> | ||
<h2>Year</h2> | ||
</section> | ||
</aside> | ||
</article> | ||
</BaseLayout> |