;;; Copyright (C) 2024 Geir Okkenhaug Jerstad <geir@geokkjer.eu>
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
;;; published by the Free Software Foundation; either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program.  If not, see
;;; <http://www.gnu.org/licenses/>.
;; Some piece of code come from David Thompson blog (GPLv3+).
;;   https://git.dthompson.us/blog.git and Pierre-Antoine Rouby
;; https://framagit.org/prouby/blog

(use-modules (haunt asset)
	     (haunt builder blog)
	     (haunt builder atom)
	     (haunt builder assets)
	     ;;(haunt builder flat-pages)
	     (haunt reader commonmark)
	     (haunt reader skribe)
	     (haunt site)
	     (haunt page)
	     (haunt utils))

(define (nav-link label url)
  `((a (@ (class "navlink")
          (href ,url)) ,label)))

(define %cc-by-sa-link
  '(a (@ (href "https://creativecommons.org/licenses/by-sa/4.0/"))
      "Creative Commons Attribution Share-Alike 4.0 International"))

(define %cc-by-sa-button
  '(a (@ (class "cc-button")
         (href "https://creativecommons.org/licenses/by-sa/4.0/"))
      (img (@ (src "https://licensebuttons.net/l/by-sa/4.0/80x15.png")
              (alt "cc-by-sa button")))))

;;;
;;; Theme
;;; 
(define main-theme
  (theme
   #:name "main"
   #:layout
   (lambda (site title body)
     `((doctype "html")
       (head
	(meta (@ (charset "utf-8")))
	(title ,(string-append title " --- " (site-title site)))
	(link (@ (rel "stylesheet")
		 (href ,(string-append "assets/pico/css/pico.jade.min.css")))))
       (body
	(header
	 (div (@ (class "nav"))
	      (ul (ul ,(nav-link "Home  " "/")
		      ,(nav-link "About" "about.html")))))
	(hr)
	(div (@ (class "content"))
	     ,body)
	(hr)
	(footer
	 (p "© 2024 Geir Okkenhaug Jerstad "
	    ,%cc-by-sa-button)))))))  

(site #:title "geokkjer's home on the web, built with Guile and Haunt"
      #:domain "blog.geokkjer.eu"
      #:default-metadata
      '((author . "Geir Okkenhaug Jerstad")
	(email . "geir@geokkjer.eu"))
      #:readers (list commonmark-reader skribe-reader)
      #:builders (list (blog #:theme main-theme)
		       ;;;(page "pages"
		       ;;;     #:template (theme-layout main-theme)
		       (static-directory "assets")
		       (atom-feed)
		       (atom-feeds-by-tag)
		       (static-directory "images"))) 
	     
