diff --git a/src/law.rs b/src/law.rs
index 26e35b3..cc4e864 100644
--- a/src/law.rs
+++ b/src/law.rs
@@ -117,7 +117,7 @@ pub(crate) fn create_law_files() -> String {
let site = Parts::new().perform(site);
li_of_files.push_str(&format!(
- "
{lawname}"
+ "{lawname}"
));
fs::write(&format!("output/{law_name}.html"), &site).expect("Unable to write file");
}
diff --git a/templates/index.html b/templates/index.html
index 4027a86..ddff0ae 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -3,6 +3,13 @@
{{header}}
+
{{content}}
diff --git a/templates/static/app.js b/templates/static/app.js
index ece44d7..64d398f 100644
--- a/templates/static/app.js
+++ b/templates/static/app.js
@@ -2,8 +2,39 @@ document.addEventListener("DOMContentLoaded", function () {
changeTheme();
initcolorTheme();
apply_stickies();
+ initSearch();
});
+function initSearch() {
+ const input = document.querySelector('#filter-js');
+
+ if(input) {
+ filterElements(input.value);
+
+ input.addEventListener('input', () => {
+ filterElements(input.value);
+ });
+ }
+}
+
+function filterElements(input) {
+ const elements = document.querySelectorAll('[data-filterable="true"]');
+
+ Array.prototype.forEach.call(elements, (element) => {
+ // set both strings (input & dataset filter) to lowercase to not be case sensitive
+ let filterString = element.dataset.filter?.toLocaleLowerCase();
+
+ // bulk hide all elements
+ element.style.display = 'none';
+
+ // show if input matches
+ if(filterString?.includes(input.toLocaleLowerCase())) {
+ element.style.display = 'flex';
+ }
+ });
+}
+
+
function changeTheme() {
let toggleBtn = document.querySelector("#theme-toggle-js");