more dynamic structure
This commit is contained in:
parent
71c636bba3
commit
9fbd4ac9eb
14
checksum.gup
Normal file
14
checksum.gup
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
gup --always
|
||||||
|
base=${2:t}
|
||||||
|
base=${base#"."}
|
||||||
|
base=${base%".chksum"}
|
||||||
|
base=${2:h}/${base}
|
||||||
|
while IFS= read -d $'\0' file; do
|
||||||
|
if [[ -f "${file}" ]]; then
|
||||||
|
b2sum "${file}"
|
||||||
|
else
|
||||||
|
echo "${file}"
|
||||||
|
fi
|
||||||
|
done > >(gup --contents) < <(find "${base}" -print0)
|
||||||
7
content/markdown.md
Normal file
7
content/markdown.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
title: Seite unterstützt Markdown
|
||||||
|
tags: meta
|
||||||
|
sort: 0
|
||||||
|
---
|
||||||
|
Text kann auch in allen Pandoc-unterstützten Formaten angegeben werden, statt nur in HTML.
|
||||||
|
Hier: Markdown
|
||||||
8
content/tags.md
Normal file
8
content/tags.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
title: Tags sind echte Tags
|
||||||
|
tags:
|
||||||
|
- meta
|
||||||
|
- example
|
||||||
|
sort: 100
|
||||||
|
---
|
||||||
|
Beliebig viele Tags pro Item.
|
||||||
@ -1,3 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: Seite befindet sich im Aufbau
|
||||||
|
tags:
|
||||||
|
- index
|
||||||
|
- meta
|
||||||
|
sort: -9001
|
||||||
|
---
|
||||||
|
```{=html}
|
||||||
<div class="px-4 py-5 my-5 text-center">
|
<div class="px-4 py-5 my-5 text-center">
|
||||||
<h1 class="display-5 fw-bold text-body-emphasis">UniWorX Systems</h1>
|
<h1 class="display-5 fw-bold text-body-emphasis">UniWorX Systems</h1>
|
||||||
<div class="col-lg-6 mx-auto">
|
<div class="col-lg-6 mx-auto">
|
||||||
@ -7,3 +15,4 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
```
|
||||||
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
gup --always
|
gup -u node_modules webpack.config.js postcss.config.js
|
||||||
gup -u node_modules
|
gup -u .src.chksum
|
||||||
rm -rf dist
|
rm -rf dist
|
||||||
yarn run build
|
yarn run build
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
gup --always
|
gup -u package.json yarn.lock
|
||||||
yarn install
|
yarn install
|
||||||
touch node_modules
|
touch node_modules
|
||||||
|
|||||||
@ -6,9 +6,8 @@ default-extensions:
|
|||||||
- NoImplicitPrelude
|
- NoImplicitPrelude
|
||||||
- ViewPatterns
|
- ViewPatterns
|
||||||
- DerivingStrategies
|
- DerivingStrategies
|
||||||
- DeriveGeneric
|
- MultiWayIf
|
||||||
- GeneralizedNewtypeDeriving
|
language: GHC2021
|
||||||
- TypeApplications
|
|
||||||
|
|
||||||
executables:
|
executables:
|
||||||
site:
|
site:
|
||||||
|
|||||||
71
src/Main.hs
71
src/Main.hs
@ -4,15 +4,15 @@ import Prelude
|
|||||||
|
|
||||||
import Hakyll
|
import Hakyll
|
||||||
|
|
||||||
import qualified Data.List as List
|
import Data.List qualified as List
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import qualified System.FilePath.Glob as Glob
|
import System.FilePath.Glob qualified as Glob
|
||||||
|
|
||||||
import qualified Data.Yaml as Yaml
|
import Data.Yaml qualified as Yaml
|
||||||
|
|
||||||
import Data.Map (Map)
|
import Data.Map (Map)
|
||||||
import qualified Data.Map as Map
|
import Data.Map qualified as Map
|
||||||
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
|
||||||
@ -32,15 +32,9 @@ main = hakyllWith config $ do
|
|||||||
frontendManifest <-
|
frontendManifest <-
|
||||||
preprocess $
|
preprocess $
|
||||||
Yaml.decodeFileThrow @_ @(Map String [FilePath]) "frontend/dist/.manifest.yaml"
|
Yaml.decodeFileThrow @_ @(Map String [FilePath]) "frontend/dist/.manifest.yaml"
|
||||||
|
let
|
||||||
match "content/index.html" $ do
|
frontendContext = jsContext <> cssContext
|
||||||
route $ stripPathPrefix "content"
|
where
|
||||||
|
|
||||||
let context =
|
|
||||||
defaultContext
|
|
||||||
<> jsContext
|
|
||||||
<> cssContext
|
|
||||||
|
|
||||||
cssContext = listField "css" innerContext genCSSItems
|
cssContext = listField "css" innerContext genCSSItems
|
||||||
where
|
where
|
||||||
innerContext = urlField "url"
|
innerContext = urlField "url"
|
||||||
@ -56,9 +50,56 @@ main = hakyllWith config $ do
|
|||||||
resources = filter (Glob.match p) $ frontendManifest Map.! entryPoint
|
resources = filter (Glob.match p) $ frontendManifest Map.! entryPoint
|
||||||
forM resources $ load . fromFilePath . ("frontend/dist" </>) . dropDrive
|
forM resources $ load . fromFilePath . ("frontend/dist" </>) . dropDrive
|
||||||
|
|
||||||
|
tags <- buildTags "content/**" $ fromCapture "*.html"
|
||||||
|
|
||||||
|
match "content/**" $ do
|
||||||
compile $ do
|
compile $ do
|
||||||
getResourceBody
|
pandocCompiler
|
||||||
>>= loadAndApplyTemplate "templates/site-layout.html" context
|
>>= relativizeUrls
|
||||||
|
|
||||||
|
tagsRules tags $ \_tag posts -> do
|
||||||
|
route idRoute
|
||||||
|
compile $ do
|
||||||
|
let
|
||||||
|
ctx =
|
||||||
|
mconcat
|
||||||
|
[ listField "tags-nav" defaultContext (mapM (uncurry renderTagNav) $ tagsMap tags)
|
||||||
|
, listField "posts" postContext (postsSort =<< loadAll posts)
|
||||||
|
, frontendContext
|
||||||
|
, defaultContext
|
||||||
|
]
|
||||||
|
|
||||||
|
renderTagNav tag ids = do
|
||||||
|
let
|
||||||
|
navRoute
|
||||||
|
| tag == "index" = "/"
|
||||||
|
| otherwise = "/" <> tag <> ".html"
|
||||||
|
|
||||||
|
tagNavCtx =
|
||||||
|
mconcat
|
||||||
|
[ constField "tag" tag
|
||||||
|
, constField "route" navRoute
|
||||||
|
, listField "posts" (constField "tag" tag <> constField "route" navRoute <> postContext) (postsSort =<< mapM load ids)
|
||||||
|
]
|
||||||
|
makeItem (mempty :: String)
|
||||||
|
>>= loadAndApplyTemplate "templates/tag-nav.html" tagNavCtx
|
||||||
|
>>= relativizeUrls
|
||||||
|
|
||||||
|
postContext =
|
||||||
|
mconcat
|
||||||
|
[ field "identifier" (return . takeBaseName . toFilePath . itemIdentifier)
|
||||||
|
, defaultContext
|
||||||
|
]
|
||||||
|
|
||||||
|
postsSort :: [Item w] -> Compiler [Item w]
|
||||||
|
postsSort = sortOnM $ \Item{itemIdentifier} -> getMetadataField itemIdentifier "sort"
|
||||||
|
where
|
||||||
|
sortOnM :: forall m a b. (Monad m, Ord b) => (a -> m b) -> [a] -> m [a]
|
||||||
|
sortOnM f = fmap (map snd . List.sortOn fst) . mapM (\x -> (,x) <$> f x)
|
||||||
|
|
||||||
|
makeItem (mempty :: String)
|
||||||
|
>>= loadAndApplyTemplate "templates/tag.html" ctx
|
||||||
|
>>= loadAndApplyTemplate "templates/site-layout.html" ctx
|
||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
|
|
||||||
match "frontend/dist/wp-*/**" $ do
|
match "frontend/dist/wp-*/**" $ do
|
||||||
|
|||||||
11
templates/tag-nav.html
Normal file
11
templates/tag-nav.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<li>
|
||||||
|
<a href="$route$">$tag$</a>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
$for(posts)$
|
||||||
|
<li>
|
||||||
|
<a href="$route$#$identifier$">$title$</a>
|
||||||
|
</li>
|
||||||
|
$endfor$
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
12
templates/tag.html
Normal file
12
templates/tag.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
$for(tags-nav)$
|
||||||
|
$body$
|
||||||
|
$endfor$
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
$for(posts)$
|
||||||
|
<article id="$identifier$">
|
||||||
|
$body$
|
||||||
|
</article>
|
||||||
|
$endfor$
|
||||||
Loading…
Reference in New Issue
Block a user