nextjs-blog-starter
nextjs-blog-starter copied to clipboard
Search, categories and featured articles on the home page
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like A clear and concise description of what you want to happen. First of all congratz and thx for this awesome starter :) I am new in react/next js, basically just started learning and i am struggling to add the below features:
- [ ] a nav bar search for site wide articles;
- [ ] a category feature when creating a post, display the category on the post page, filter posts by a category and adding the categories on the nav bar;
- [ ] set a post as featured and display it on the home page, maybe as a entire screen slider.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
Hey @faierbol thanks for reaching out, happy to hear you like the starter!
There are a few ways that you could go about setting that up, but my first thought would be to add the tags or category to the front matter of each post.
Then how you interact with the tags/data is up to you. One way might be to write a script that runs on build (or in development even), and creates a list of all the post slugs and tags they contain. Then you could use that list data for the search functionality you want to add. You can see how the front matter is pulled in from each post in the lib/api.js file, using gray-matter.
Other options might be to read from the disk, or to store the post slug and tags in state, however those would both be less performant than generating a list of post slugs and tags on build, as that would be a much smaller data set that you could automatically hard code on each build with the script.
How do you feel about getting something like that set up? Let me know if you have questions or get stuck.