From ec31242981420231d46b22ae5acb50bba1219412 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 23 Mar 2022 12:51:17 +0100 Subject: [PATCH] =?UTF-8?q?Rename=20=E6=88=90=E3=82=8A=E7=AB=8B=E3=81=A1?= =?UTF-8?q?=20to=20=E8=AA=9E=E6=BA=90,=20and=20fix=20index=20titles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{naritachi => gogen}/suru.md | 2 +- src/index.html | 4 ++-- src/templates/{naritachi.html => gogen.html} | 0 ssg/src/Formats/{Naritachi.hs => Gogen.hs} | 24 ++++++++------------ ssg/src/Main.hs | 12 +++++----- 5 files changed, 19 insertions(+), 23 deletions(-) rename src/{naritachi => gogen}/suru.md (74%) rename src/templates/{naritachi.html => gogen.html} (100%) rename ssg/src/Formats/{Naritachi.hs => Gogen.hs} (72%) diff --git a/src/naritachi/suru.md b/src/gogen/suru.md similarity index 74% rename from src/naritachi/suru.md rename to src/gogen/suru.md index 72b2eb8..eb2ada2 100644 --- a/src/naritachi/suru.md +++ b/src/gogen/suru.md @@ -1,6 +1,6 @@ --- desc: "I announce myself to the world" -keywords: "japanese, naritachi, grammar" +keywords: "japanese, gogen, grammar" lang: "en" updated: "2020-09-22T12:00:00Z" title: "[為](す)る" diff --git a/src/index.html b/src/index.html index 90feb0e..d0f4aba 100644 --- a/src/index.html +++ b/src/index.html @@ -31,9 +31,9 @@ title: "Nani"

語源

diff --git a/src/templates/naritachi.html b/src/templates/gogen.html similarity index 100% rename from src/templates/naritachi.html rename to src/templates/gogen.html diff --git a/ssg/src/Formats/Naritachi.hs b/ssg/src/Formats/Gogen.hs similarity index 72% rename from ssg/src/Formats/Naritachi.hs rename to ssg/src/Formats/Gogen.hs index 0d420e3..40dc2ec 100644 --- a/ssg/src/Formats/Naritachi.hs +++ b/ssg/src/Formats/Gogen.hs @@ -1,14 +1,15 @@ {-# LANGUAGE QuasiQuotes, FlexibleContexts #-} -module Formats.Naritachi ( +module Formats.Gogen ( convertFuriganaTitle, - convertFuriganaTitleHtml + convertFuriganaTitleHtml, + gogenCtx, ) where -import Hakyll (Item, Metadata, Compiler, itemIdentifier, getMetadata, lookupString) +import Hakyll import Debug.Trace (traceId) import Data.Maybe (fromMaybe) -import Text.Regex.PCRE.Heavy +import Text.Regex.PCRE.Heavy (gsub, re) -------------------------------------------------------------------------------- -- FURIGANA CONVERSION @@ -37,15 +38,10 @@ replaceFuriganaWithHtml :: FuriganaTemplate -> String replaceFuriganaWithHtml = between "" "" . gsub [re|\[(.*?)\]\((.*?)\)|] (\(kanji:kana:_) -> "" ++ kanji ++" ( " ++ kana ++ ")" :: String) where between x y s = x ++ s ++ y --- toHtml :: FuriganaTemplate -> String --- toHtml input = --- "" --- <> subRegex (mkRegex "[(.*?)]\\((.*?)\\)") input "\1 (\2)" --- <> "" --- --- --- --- --- +gogenCtx :: Context String +gogenCtx = + dateField "date" "%Y-%m-%d" + <> field "titleHtml" convertFuriganaTitleHtml + <> defaultContext diff --git a/ssg/src/Main.hs b/ssg/src/Main.hs index 29fde9d..27b2719 100644 --- a/ssg/src/Main.hs +++ b/ssg/src/Main.hs @@ -19,7 +19,7 @@ import Text.Pandoc.Highlighting (Style, breezeDark, styleToCss) -- --------- -import Formats.Naritachi +import Formats.Gogen import Util.Routes -------------------------------------------------------------------------------- @@ -73,14 +73,14 @@ main = hakyllWith config $ do match "posts/*" $ do let ctx = constField "type" "article" <> postCtx - route $ metadataRoute titleRoute `composeRoutes` (prefixRoute "posts/") + route $ metadataRoute titleRoute `composeRoutes` prefixRoute "posts/" compile $ pandocCompilerCustom >>= loadAndApplyTemplate "templates/post.html" ctx >>= saveSnapshot "content" >>= loadAndApplyTemplate "templates/default.html" ctx - match "naritachi/*" $ do + match "gogen/*" $ do let ctx = constField "type" "article" <> field "title" convertFuriganaTitle @@ -91,7 +91,7 @@ main = hakyllWith config $ do compile $ do pandocCompilerCustom - >>= loadAndApplyTemplate "templates/naritachi.html" ctx + >>= loadAndApplyTemplate "templates/gogen.html" ctx >>= saveSnapshot "content" >>= loadAndApplyTemplate "templates/default.html" ctx @@ -100,11 +100,11 @@ main = hakyllWith config $ do compile $ do -- posts :: Compiler posts <- recentFirst =<< loadAll "posts/*" - naritachi <- loadAll "naritachi/*" + gogen <- loadAll "gogen/*" let indexCtx = listField "posts" postCtx (return posts) - <> listField "naritachi" postCtx (return naritachi) + <> listField "gogen" gogenCtx (return gogen) <> constField "root" root <> constField "siteName" siteName <> defaultContext