Skip to content

Commit

Permalink
fix featured post with latest post
Browse files Browse the repository at this point in the history
  • Loading branch information
zemuldo committed Aug 9, 2024
1 parent 5a08b83 commit bd44509
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion components/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ export const darkTheme = createMuiTheme({
});


export default { darkTheme, lightTheme };
export const theme = { darkTheme, lightTheme };

export default theme;
4 changes: 3 additions & 1 deletion components/tools/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const postUrl = (post_id, title) => `/blog/${title.toLowerCase().split(' ').join('-')}-${post_id}`;

export default { postUrl };
export const tools = { postUrl };

export default tools;
4 changes: 3 additions & 1 deletion db/services/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ module.exports = {

return post;
}
return null;

const post = await Post.findOne({}).sort([['createdAt', -1]]);
return post;
},
setFeatured: async (id) => {
const d = new Date();
Expand Down
3 changes: 1 addition & 2 deletions pages/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class Blog extends React.Component {
const data = await responseToJson(res);
const res_featured = await fetch(`${api_url}/post/featured`);
const data_featured = await responseToJson(res_featured);
console.log(data)
return {
featuredPost: data_featured,
authorization,
Expand Down Expand Up @@ -118,7 +117,7 @@ class Blog extends React.Component {
</Container>
<Container>
<ShouldRender if={!!featuredPost && !this.state.currentTag}>
{/* <FeaturedPost featuredPost={featuredPost} /> */}
<FeaturedPost featuredPost={featuredPost} />
</ShouldRender>
</Container>
<Container maxWidth="md">
Expand Down

0 comments on commit bd44509

Please sign in to comment.