Browse Source

play with metas and color theme html

elegant-fp-app-archi
parent
commit
370e0a6ee7
Signed by: yogsototh GPG Key ID: 7B19A4C650D59646
  1. 5
      Makefile
  2. 22
      engine/metas.lua
  3. 6
      engine/mk-html.sh
  4. 2
      src/posts/0019-utopia-tv-show/index.org
  5. 3
      templates/index.html
  6. 5
      templates/post.html

5
Makefile

@ -48,9 +48,10 @@ DST_PANDOC_FILES ?= $(patsubst %$(EXT),%.html, \
PANDOC_TEMPLATE ?= templates/post.html
PANDOC_LUA_FILTER ?= engine/links-to-html.lua
PANDOC_LUA_FILTER_IMG ?= engine/img-to-webp.lua
PANDOC_LUA_METAS ?= engine/metas.lua
MK_HTML := engine/mk-html.sh
PANDOC := $(MK_HTML) $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(PANDOC_LUA_FILTER_IMG)
$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(PANDOC_LUA_FILTER_IMG) $(MK_HTML) $(ENV_VARS)
PANDOC := $(MK_HTML) $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(PANDOC_LUA_FILTER_IMG) $(PANDOC_LUA_METAS)
$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(PANDOC_LUA_FILTER_IMG) $(PANDOC_LUA_METAS) $(MK_HTML) $(ENV_VARS)
@mkdir -p "$(dir $@)"
$(PANDOC) "$<" "$@.tmp"
minify --mime text/html "$@.tmp" > "$@"

22
engine/metas.lua

@ -0,0 +1,22 @@
-- intermediate store for variables and their values
local variables = {}
--- Function called for each raw block element.
function RawBlock (raw)
-- Don't do anything unless the block contains *org* markup.
if raw.format ~= 'org' then return nil end
-- extract variable name and value
local name, value = raw.text:match '#%+(%w+):%s*(.+)$'
if name and value then
variables[name] = value
end
end
-- Add the extracted variables to the document's metadata.
function Meta (meta)
for name, value in pairs(variables) do
meta[name] = value
end
return meta
end

6
engine/mk-html.sh

@ -5,8 +5,9 @@ cd "$(git rev-parse --show-toplevel)" || exit 1
template="$1"
luafilter="$2"
luafilterimg="$3"
orgfile="$4"
htmlfile="$5"
luametas="$4"
orgfile="$5"
htmlfile="$6"
tocoption=""
if grep -ie '^#+options:' "$orgfile" | grep 'toc:t'>/dev/null; then
@ -18,6 +19,7 @@ pandoc $tocoption \
--template="$template" \
--lua-filter="$luafilter" \
--lua-filter="$luafilterimg" \
--lua-filter="$luametas" \
--mathml \
--from org \
--to html5 \

2
src/posts/0019-utopia-tv-show/index.org

@ -14,6 +14,8 @@
#+lang: en
#+options: auto-id:t
#+startup: showeverything
#+lightbk: #ff0
#+darkbk: #880
#+html_head_extra: <style>
#+html_head_extra: :root { --bg: #ff0; --fg: #000; }
#+html_head_extra: img,svg {filter: contrast(0.5)sepia(100%)hue-rotate(20deg)saturate(15); }

3
templates/index.html

@ -7,10 +7,11 @@
<meta name="author" content="$author$">
<meta name="description" content="$description$">
<meta name="keywords" content="$keywords$">
<meta name="theme-color" content="#d84100">
<link rel="stylesheet" href="/css/y.css"/>
<link rel="alternate" type="application/rss+xml" href="/rss.xml" />
<link rel="icon" href="/favicon.ico">
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#d84100">
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#2E3440">
$header-includes$
</head>
<body>

5
templates/post.html

@ -7,10 +7,13 @@
<meta name="author" content="$author$">
<meta name="description" content="$description$">
<meta name="keywords" content="$keywords$">
<meta name="theme-color" content="#d84100">
<link rel="stylesheet" href="/css/y.css"/>
<link rel="alternate" type="application/rss+xml" href="/rss.xml" />
<link rel="icon" href="/favicon.ico">
<meta name="theme-color" media="(prefers-color-scheme: light)"
content=$if(lightbk)$"$lightbk$"$else$"#d84100"$endif$>
<meta name="theme-color" media="(prefers-color-scheme: dark)"
content=$if(darkbk)$"$darkbk$"$else$"#2E3440"$endif$>
$header-includes$
</head>
<body>

Loading…
Cancel
Save