From: Danilo M. Date: Sun, 5 Apr 2026 06:43:04 +0000 (+0200) Subject: feat: add filter functionality, archetypes, and sample content X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=880f1ce121434e641c09f63e43ab08a2beaa83d4;p=danix2-hugo-theme.git feat: add filter functionality, archetypes, and sample content - Create filters.js for post filtering by type (tech, life, quote, link, photo) - Add article.md and page.md archetypes with appropriate fields - Update default.md archetype with correct TOML syntax - Create sample content for home, articles, and about pages - Fix section.html template resource permalink syntax Co-Authored-By: Claude Haiku 4.5 --- diff --git a/archetypes/article.md b/archetypes/article.md new file mode 100644 index 0000000..477a18f --- /dev/null +++ b/archetypes/article.md @@ -0,0 +1,11 @@ ++++ +title = "{{ replace .File.ContentBaseName "-" " " | title }}" +date = {{ .Date }} +draft = true +type = "tech" # Options: tech, life, quote, link, photo +featured = false +image = "" # Optional: image path or URL +description = "Brief description of the article (2 lines max)" ++++ + +Write your article here... diff --git a/archetypes/default.md b/archetypes/default.md index 25b6752..502fd89 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -1,5 +1,7 @@ +++ -date = '{{ .Date }}' +title = "{{ replace .File.ContentBaseName "-" " " | title }}" +date = {{ .Date }} draft = true -title = '{{ replace .File.ContentBaseName "-" " " | title }}' +++ + +Content here... diff --git a/archetypes/page.md b/archetypes/page.md new file mode 100644 index 0000000..fe37a38 --- /dev/null +++ b/archetypes/page.md @@ -0,0 +1,8 @@ ++++ +title = "{{ replace .File.ContentBaseName "-" " " | title }}" +date = {{ .Date }} +draft = false +type = "page" ++++ + +Write your page content here... diff --git a/assets/js/filters.js b/assets/js/filters.js new file mode 100644 index 0000000..64d9c57 --- /dev/null +++ b/assets/js/filters.js @@ -0,0 +1,28 @@ +// filters.js +(function() { + const filterBtns = document.querySelectorAll('.filter-btn'); + const feedList = document.getElementById('articles-feed'); + const cards = feedList ? feedList.querySelectorAll('.post-card') : []; + + if (!filterBtns.length || !cards.length) return; + + filterBtns.forEach(btn => { + btn.addEventListener('click', function() { + const filter = this.dataset.filter; + + // Update active button + filterBtns.forEach(b => b.classList.remove('active')); + this.classList.add('active'); + + // Filter cards + cards.forEach(card => { + const cardType = card.querySelector('.post-type-badge')?.classList[1]; + const matches = filter === 'all' || cardType === filter; + card.style.display = matches ? '' : 'none'; + }); + + // Scroll to top + window.scrollTo({ top: 0, behavior: 'smooth' }); + }); + }); +})(); diff --git a/content/_index.md b/content/_index.md index 652623b..f04efe2 100644 --- a/content/_index.md +++ b/content/_index.md @@ -1,9 +1,6 @@ +++ -title = 'Home' -date = 2023-01-01T08:00:00-07:00 -draft = false +title = "Home" +date = 2026-01-01T00:00:00Z +++ -Laborum voluptate pariatur ex culpa magna nostrud est incididunt fugiat -pariatur do dolor ipsum enim. Consequat tempor do dolor eu. Non id id anim anim -excepteur excepteur pariatur nostrud qui irure ullamco. +This is the home page content. The landing page layout will use this, but typically you won't add much here — the hero and latest posts grid will be the main focus. diff --git a/content/articles/_index.md b/content/articles/_index.md new file mode 100644 index 0000000..3d43a65 --- /dev/null +++ b/content/articles/_index.md @@ -0,0 +1,6 @@ ++++ +title = "Articles" +date = 2026-01-01T00:00:00Z ++++ + +Browse all articles, organized by type. Use the filters to find what you're looking for. diff --git a/content/is/_index.md b/content/is/_index.md new file mode 100644 index 0000000..391d6d1 --- /dev/null +++ b/content/is/_index.md @@ -0,0 +1,8 @@ ++++ +title = "About" +date = 2026-01-01T00:00:00Z ++++ + +Hi, I'm Danilo. I write about tech, life, and the things that matter. + +This is your about page. Edit this to tell your story. diff --git a/layouts/section.html b/layouts/section.html index 4de7628..8b938f3 100644 --- a/layouts/section.html +++ b/layouts/section.html @@ -24,6 +24,7 @@ {{ if eq .Type "articles" }} - + {{ $filters := resources.Get "js/filters.js" | fingerprint }} + {{ end }} {{ end }}