diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d8bc61d..4bab0008 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -138,3 +138,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed styling issue on nav links - Fixed contact form message position - Fixed blog images not loading due to dev.to changing image host (sub)domain +- Fixed empty blog category by using per_page parameter diff --git a/README.md b/README.md index 6a66d72b..2dbe5661 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ This is how to get started locally:
+## Developer Note + +- The Dev.to API has a 30 posts limit by default and we updated it to 1000. If we need to fetch more posts, we will need to update the getStaticProps on `/pages/blog`. For more details, refer to the [API documentation](https://developers.forem.com/api/v1#tag/articles/operation/getArticles). + +
+ ## License This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details. diff --git a/pages/blog/index.js b/pages/blog/index.js index 3870b323..3d03e1ea 100644 --- a/pages/blog/index.js +++ b/pages/blog/index.js @@ -48,7 +48,8 @@ export default function Blog({ posts }) { } export async function getStaticProps() { - const res = await fetch('https://dev.to/api/articles?username=wdp'); + const PER_PAGE = 1000 + const res = await fetch(`https://dev.to/api/articles?username=wdp&per_page=${PER_PAGE}`); const posts = await res.json(); return {