Skip to content

Commit 3608179

Browse files
Merge pull request #226 from Web-Dev-Path/fix/empty-blog-category
Fix Empty blog category
2 parents 7260e16 + ebc3ae7 commit 3608179

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
138138
- Fixed styling issue on nav links
139139
- Fixed contact form message position
140140
- Fixed blog images not loading due to dev.to changing image host (sub)domain
141+
- Fixed empty blog category by using per_page parameter

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ This is how to get started locally:
3636

3737
<br />
3838

39+
## Developer Note
40+
41+
- 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).
42+
43+
<br />
44+
3945
## License
4046

4147
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.

pages/blog/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export default function Blog({ posts }) {
4848
}
4949

5050
export async function getStaticProps() {
51-
const res = await fetch('https://dev.to/api/articles?username=wdp');
51+
const PER_PAGE = 1000
52+
const res = await fetch(`https://dev.to/api/articles?username=wdp&per_page=${PER_PAGE}`);
5253
const posts = await res.json();
5354

5455
return {

0 commit comments

Comments
 (0)