You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm curious, do you accept feature request? If you do, I want to request search feature to make user easier when search for spesific content.
I saw this feature is already present in Herman's Bear Blog, which would be nice if you also add this feature to Hugo Bear Blog theme since it also based on Bear Blog. Thanks!
The text was updated successfully, but these errors were encountered:
I should mention that search functionality isn't part of the core Bear Blog platform, as it's intentionally JavaScript-free. Herman likely added search as a custom script to his blog. While I aim to keep hugo-bearblogJavaScript-free as well, you can add this functionality on your site yourself.
Here's how to implement a search feature:
Create a file at layout/partials/custom_body.html
Add this search implementation to the file:
<script>//// Credit: Adapted with minor modifications from Herman's blog (https://herman.bearblog.dev/blog/)//// Select the content container and the blog posts listconstmainContainer=document.querySelector('content');constblogPosts=document.querySelector('ul.blog-posts');if(blogPosts){constsearchInput=document.createElement('input');searchInput.type='text';searchInput.id='searchInput';searchInput.placeholder='Search...';searchInput.style.display='block';searchInput.style.marginTop='16px';mainContainer.insertBefore(searchInput,blogPosts);// Add event listener to filter posts based on inputsearchInput.addEventListener('input',function(){constsearchTerm=this.value.toLowerCase();constposts=document.querySelectorAll('.blog-posts li');posts.forEach(post=>{consttitle=post.textContent.toLowerCase();post.style.display=title.includes(searchTerm) ? '' : 'none';});});}</script>
Let me know if you need any clarification or run into any issues!
Best regards,
Jan
CC: @rokcso - This could be an interesting addition to hugo-bearblog-neo if it aligns with your vision! 💡
Hi, I'm curious, do you accept feature request? If you do, I want to request search feature to make user easier when search for spesific content.
I saw this feature is already present in Herman's Bear Blog, which would be nice if you also add this feature to Hugo Bear Blog theme since it also based on Bear Blog. Thanks!
The text was updated successfully, but these errors were encountered: