2024-08-11 Sunday
今日のhugoさん
本日の作業
- 月別アーカイブ表示できるようにした。手順は以下の通り。基本ググって写経…。
あとでまとめるかも。 -
hugo.toml taxnomy に archives 追加
[taxonomies] tag = "tags" category = "categories" archive = "archives"
-
easy-hugo の new post のfront matter に '#+archives: 2024/08' が入るように設定
(leaf easy-hugo :ensure t :init (setq easy-hugo-basedir "~/blog/") (setq easy-hugo-url "https://xxxxxx.netlify.app") (setq easy-hugo-sshdomain "xxxxxt.org") (setq easy-hugo-root "/") (setq easy-hugo-previewtime "300") (setq easy-hugo-postdir "content/posts") (setq easy-hugo-org-header t) (setq easy-hugo-default-ext ".org") ;; Sort-publishday on startup (setq easy-hugo--sort-publishday-flg 1) (setq easy-hugo--sort-char-flg nil) (setq easy-hugo--sort-time-flg nil) (defun my/easy-hugo-newpost (post-file) "easy-hugo-newpost customized version." (interactive (list (read-from-minibuffer "Filename: " `(,easy-hugo-default-ext . 1) nil nil nil))) (let* ((slug (format-time-string "%Y%m%d%H%M")) (new-post-file (concat slug "." post-file))) (easy-hugo-with-env (let ((filename (expand-file-name new-post-file easy-hugo-postdir))) (when (file-exists-p (file-truename filename)) (error "%s already exists!" filename)) (find-file filename) (insert (my/easy-hugo--org-headers (file-name-base post-file) slug)) (goto-char (point-max)) (save-buffer))))) (advice-add 'easy-hugo-newpost :override 'my/easy-hugo-newpost) (defun my/easy-hugo--org-headers (file slug) "Return a draft org mode header string for a new article as FILE." (let ((datetimezone (concat (format-time-string "%Y-%m-%dT%T") (easy-hugo--orgtime-format (format-time-string "%z")))) (year_month (format-time-string "%Y/%m")) ) (concat "#+title: " file "\n#+subtitle: hogemoge diary" "\n#+date: " datetimezone "\n#+publishdate: " datetimezone "\n#+lastmod: " "\n#+slug: " slug "\n#+categories[]: journal" "\n#+tags[]: memo" "\n#+archives: " year_month "\n#+author: @tsut" "\n#+draft: nil" ;; "\n#+toc: false" "\n\n"))) (advice-add 'easy-hugo--org-headers :override 'my/easy-hugo--org-headers) )
- 今までのコンテンツに '#+archives: 2024/08' とかを差し込む
-
サイドバーにアーカイブ表示用のhtmlを作成。~/blog/layouts/partials/widgets/archives
{{- $archives := .Site.Taxonomies.archives }} {{- if gt (len $archives) 0 }} <div class="widget-archives widget"> <!-- <h4 class="widget__title">{{ T "archives_title" }}</h4> --> <h4 class="widget__title">Archives</h4> <div class="widget__content"> <ul class="widget__list"> {{ range $items := .Site.Taxonomies.archives.Alphabetical.Reverse }} <li class="widget__item"> <a class="widget__link" href="{{ $.Site.BaseURL }}archives/{{ .Name | urlize | lower }}">{{ .Name }} ({{ .Count }})</a> </li> {{ end }} </ul> </div> {{- end }}
今後の作業
- Archive 表示用ページの作成
- サイドバーの表示が冗長、なんとかしたい
今日のごはん
- 朝: 目玉焼きご飯 高菜
- 昼: とろ玉うどん (丸亀製麺)
- 晩: アスパラ 海老のサラダ 手羽焼 鴨 さざえ パン
今日もとりあえず飲まない
故あってしばらく飲まない…(つもり)
154日目