From 4598a12887ed6c21cc0007f8b13cdac843a5e4bf Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Fri, 17 Nov 2023 18:49:54 +0100 Subject: [PATCH] Tags, rss, sitemap and robots.txt --- assets/css/list.css | 18 +++++++++++++++++ assets/css/partials/breadcrumb.css | 4 ++++ content/blog/another-post/index.md | 1 + content/blog/test-blog/index.md | 1 + hugo.toml | 15 ++++++++++++++- layouts/_default/baseof.html | 7 ++++++- layouts/_default/list.html | 31 ++++++++++++++++++++++++++---- layouts/index.html | 4 ++-- layouts/partials/breadcrumb.html | 20 +++++++++++++++---- layouts/partials/footer.html | 2 +- layouts/partials/header.html | 4 ++-- 11 files changed, 92 insertions(+), 15 deletions(-) diff --git a/assets/css/list.css b/assets/css/list.css index f6e8745..4c9c414 100644 --- a/assets/css/list.css +++ b/assets/css/list.css @@ -7,6 +7,24 @@ main h2 { margin-bottom: 1rem; } +main #tags { + display: flex; + align-items: center; + column-gap: 1rem; +} + +main #tags a { + border-radius: 0.5625rem; + background-color: #5A5A5A; + color: var(--white); + padding: 0.5rem 1rem; + text-decoration: none; +} + +main #tags .selected { + background-color: var(--crimson); +} + @media only screen and (max-width: 1024px) { main h2 { font-size: 1.75rem; diff --git a/assets/css/partials/breadcrumb.css b/assets/css/partials/breadcrumb.css index 8bbb13d..83903ca 100644 --- a/assets/css/partials/breadcrumb.css +++ b/assets/css/partials/breadcrumb.css @@ -18,3 +18,7 @@ .breadcrumb a { text-transform: capitalize; } + +.breadcrumb .tag { + text-transform: lowercase; +} diff --git a/content/blog/another-post/index.md b/content/blog/another-post/index.md index f2bc862..7b2a5b8 100644 --- a/content/blog/another-post/index.md +++ b/content/blog/another-post/index.md @@ -2,6 +2,7 @@ title: "Another blog post" description: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book." date: 2023-10-18 +tags: ['testing'] --- ## Hi diff --git a/content/blog/test-blog/index.md b/content/blog/test-blog/index.md index 0836438..100e79e 100644 --- a/content/blog/test-blog/index.md +++ b/content/blog/test-blog/index.md @@ -2,6 +2,7 @@ title: "Test blog" description: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book." date: 2023-10-18 +tags: ['test'] --- ## Hi diff --git a/hugo.toml b/hugo.toml index f171260..6e503e7 100644 --- a/hugo.toml +++ b/hugo.toml @@ -1,11 +1,24 @@ languageCode = 'en-us' title = 'Hazem Krimi' -paginate = 1 +paginate = 5 +enableRobotsTXT = true +[outputs] + home = ['html', 'rss'] + section = ['html', 'rss'] + taxonomy = ['html'] + term = ['html'] +[sitemap] + changeFreq = '' + filename = 'sitemap.xml' + priority = -1 [taxonomies] tag = 'tags' [params] formSpreeURL = 'https://formspree.io/f/xoqpgyge' dateFormat = '02 January 2006' + [params.author] + email = 'me@hazemkrimi.tech' + name = 'Hazem Krimi' [module] [menu] [[menu.main]] diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 6b81fe0..f9c3495 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -7,12 +7,17 @@ {{ $favIcon16 := resources.Get "favicon-16x16.png" }} {{ $favIcon := resources.Get "favicon.ico" }} - + + + {{ with .OutputFormats.Get "rss" -}} + {{ printf `` .Rel .MediaType.Type .Permalink site.Title | safeHTML }} + {{ end }} + diff --git a/layouts/_default/list.html b/layouts/_default/list.html index a641fa4..a667171 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -9,11 +9,34 @@ {{ .Content }} -
- {{ range .Paginator.Pages }} - {{ partial "card.html" . }} + {{ if or (.InSection ($.Site.GetPage "blog")) (findRESubmatch "tags" .RelPermalink) }} + {{ $currentTitle := .Page.Title }} + + {{ if (findRESubmatch "tags" .RelPermalink) }} +

Blog

+

These are articles about things I learned about software engineering.

{{ end }} -
+ +
+ {{ range .Site.Taxonomies.tags }} + + {{ .Page.Title }} + + {{ end }} +
+ {{ end }} + + {{ if gt .Paginator.TotalPages 0 }} +
+ {{ range .Paginator.Pages }} + {{ partial "card.html" . }} + {{ end }} +
+ {{ else }} +

Nothing for now

+ {{ end }} {{ partial "pagination.html" . }} {{ end }} diff --git a/layouts/index.html b/layouts/index.html index fe91b56..3d0cb95 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -33,7 +33,7 @@

These are all the projects I worked on personally and professionally.

{{ range (where .Site.Pages "Section" "projects") }} - {{ range .Pages }} + {{ range first 2 .Pages }} {{ partial "card.html" . }} {{ end }} {{ end }} @@ -48,7 +48,7 @@

These are articles about things I learned about software engineering.

{{ range (where .Site.Pages "Section" "blog") }} - {{ range .Pages }} + {{ range first 2 .Pages }} {{ partial "card.html" . }} {{ end }} {{ end }} diff --git a/layouts/partials/breadcrumb.html b/layouts/partials/breadcrumb.html index 6b50b7f..961a5a5 100644 --- a/layouts/partials/breadcrumb.html +++ b/layouts/partials/breadcrumb.html @@ -5,12 +5,24 @@ diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index c4887e8..80c0cf9 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -20,7 +20,7 @@ {{ readFile "assets/icons/github.svg" | safeHTML }} - + {{ readFile "assets/icons/rss.svg" | safeHTML }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index b5e5cfe..ff57b4a 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -21,7 +21,7 @@ {{ readFile "assets/icons/linkedin.svg" | safeHTML }} {{ readFile "assets/icons/twitter.svg" | safeHTML }} {{ readFile "assets/icons/github.svg" | safeHTML }} - {{ readFile "assets/icons/rss.svg" | safeHTML }} + {{ readFile "assets/icons/rss.svg" | safeHTML }} {{ readFile "assets/icons/mail.svg" | safeHTML }} {{ readFile "assets/icons/cv.svg" | safeHTML }}
@@ -56,7 +56,7 @@ {{ readFile "assets/icons/cv.svg" | safeHTML }} {{ readFile "assets/icons/mail.svg" | safeHTML }} - {{ readFile "assets/icons/rss.svg" | safeHTML }} + {{ readFile "assets/icons/rss.svg" | safeHTML }} {{ readFile "assets/icons/github.svg" | safeHTML }} {{ readFile "assets/icons/twitter.svg" | safeHTML }} {{ readFile "assets/icons/linkedin.svg" | safeHTML }}