feat: blog

This commit is contained in:
LordMZTE 2024-08-16 23:06:55 +02:00
parent 3fcb554200
commit 20a9f81a18
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
13 changed files with 1311 additions and 36 deletions

2
.config/bat/config Normal file
View file

@ -0,0 +1,2 @@
--theme=catppuccin
--style plain

View file

@ -0,0 +1,959 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Catppuccin</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#cdd6f4</string>
<key>background</key>
<string>#1e1e2e</string>
<key>caret</key>
<string>#bac2de</string>
<key>invisibles</key>
<string>#a6adc8</string>
<key>gutterForeground</key>
<string>#9399b2</string>
<key>gutterForegroundHighlight</key>
<string>#a6e3a1</string>
<key>lineHighlight</key>
<string>#585b70</string>
<key>selection</key>
<string>#6c7086</string>
<key>selectionBorder</key>
<string>#1e1e2e</string>
<key>activeGuide</key>
<string>#fab387</string>
<key>findHighlightForeground</key>
<string>#181825</string>
<key>findHighlight</key>
<string>#f9e2af</string>
<key>bracketsForeground</key>
<string>#9399b2</string>
<key>bracketContentsForeground</key>
<string>#9399b2</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment</string>
<key>scope</key>
<string>comment</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#6c7086</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>String</string>
<key>scope</key>
<string>string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#a6e3a1</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>String regex</string>
<key>scope</key>
<string>string.regexp</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#fab387</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Number</string>
<key>scope</key>
<string>constant.numeric</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#fab387</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Boolean</string>
<key>scope</key>
<string>constant.language.boolean</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#fab387</string>
<key>fontStyle</key>
<string>bold italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Built-in constant</string>
<key>scope</key>
<string>constant.language</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#b4befe</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Built-in function</string>
<key>scope</key>
<string>support.function.builtin</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#fab387</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>User-defined constant</string>
<key>scope</key>
<string>variable.other.constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#fab387</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variable</string>
<key>scope</key>
<string>variable</string>
<key>settings</key>
<dict></dict>
</dict>
<dict>
<key>name</key>
<string>Keyword</string>
<key>scope</key>
<string>keyword</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Conditional/loop</string>
<key>scope</key>
<string>keyword.control.loop, keyword.control.conditional, keyword.control.c++</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#cba6f7</string>
<key>fontStyle</key>
<string>bold</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Return</string>
<key>scope</key>
<string>keyword.control.return, keyword.control.flow.return</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f5c2e7</string>
<key>fontStyle</key>
<string>bold</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Exception</string>
<key>scope</key>
<string>support.type.exception</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#fab387</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Operator</string>
<key>scope</key>
<string>keyword.operator, punctuation.accessor</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89dceb</string>
<key>fontStyle</key>
<string>bold</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Punctuation separator</string>
<key>scope</key>
<string>punctuation.separator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#94e2d5</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Punctuation terminator</string>
<key>scope</key>
<string>punctuation.terminator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#94e2d5</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Punctuation bracket</string>
<key>scope</key>
<string>punctuation.section</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#9399b2</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Include</string>
<key>scope</key>
<string>keyword.control.import.include</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#94e2d5</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>storage</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage type</string>
<key>scope</key>
<string>storage.type</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f9e2af</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage modifier</string>
<key>scope</key>
<string>storage.modifier</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage type namespace</string>
<key>scope</key>
<string>entity.name.namespace, meta.path</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f5e0dc</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage type class</string>
<key>scope</key>
<string>storage.type.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f5e0dc</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Label</string>
<key>scope</key>
<string>entity.name.label</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89b4fa</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keyword class</string>
<key>scope</key>
<string>keyword.declaration.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Class name</string>
<key>scope</key>
<string>entity.name.class, meta.toc-list.full-identifier</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89dceb</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Inherited class</string>
<key>scope</key>
<string>entity.other.inherited-class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89dceb</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Function name</string>
<key>scope</key>
<string>entity.name.function, variable.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89b4fa</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Function macro</string>
<key>scope</key>
<string>entity.name.function.preprocessor</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Macro directive - ifdef</string>
<key>scope</key>
<string>keyword.control.import</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Constructor</string>
<key>scope</key>
<string>entity.name.function.constructor, entity.name.function.destructor</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#b4befe</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Function argument</string>
<key>scope</key>
<string>variable.parameter.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f5e0dc</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Function declaration</string>
<key>scope</key>
<string>keyword.declaration.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#eba0ac</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Library function</string>
<key>scope</key>
<string>support.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89dceb</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Library constant</string>
<key>scope</key>
<string>support.constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89b4fa</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Library class/type</string>
<key>scope</key>
<string>support.type, support.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89b4fa</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Library variable</string>
<key>scope</key>
<string>support.other.variable</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variable function</string>
<key>scope</key>
<string>variable.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89b4fa</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variable parameter</string>
<key>scope</key>
<string>variable.parameter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f5e0dc</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variable other</string>
<key>scope</key>
<string>variable.other</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#cdd6f4</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variable field</string>
<key>scope</key>
<string>variable.other.member</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f5e0dc</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variable language</string>
<key>scope</key>
<string>variable.language</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#94e2d5</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tag name</string>
<key>scope</key>
<string>entity.name.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#fab387</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tag attribute</string>
<key>scope</key>
<string>entity.other.attribute-name</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#cba6f7</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tag delimiter</string>
<key>scope</key>
<string>punctuation.definition.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#eba0ac</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown URL</string>
<key>scope</key>
<string>markup.underline.link.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f5e0dc</string>
<key>fontStyle</key>
<string>italic underline</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown reference</string>
<key>scope</key>
<string>meta.link.inline.description</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#b4befe</string>
<key>fontStyle</key>
<string>bold</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown literal</string>
<key>scope</key>
<string>comment.block.markdown, meta.code-fence, markup.raw.code-fence, markup.raw.inline</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#94e2d5</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown title</string>
<key>scope</key>
<string>punctuation.definition.heading, entity.name.section</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#89b4fa</string>
<key>fontStyle</key>
<string>bold</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown emphasis</string>
<key>scope</key>
<string>markup.italic</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#eba0ac</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown strong</string>
<key>scope</key>
<string>markup.bold</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#eba0ac</string>
<key>fontStyle</key>
<string>bold</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Escape</string>
<key>scope</key>
<string>constant.character.escape</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f5c2e7</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bash built-in function</string>
<key>scope</key>
<string>source.shell.bash meta.function.shell meta.compound.shell meta.function-call.identifier.shell</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f5c2e7</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bash parameter</string>
<key>scope</key>
<string>variable.language.shell</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Lua field</string>
<key>scope</key>
<string>source.lua meta.function.lua meta.block.lua meta.mapping.value.lua meta.mapping.key.lua string.unquoted.key.lua</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#b4befe</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Lua constructor</string>
<key>scope</key>
<string>source.lua meta.function.lua meta.block.lua meta.mapping.key.lua string.unquoted.key.lua</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f2cdcd</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Java constant</string>
<key>scope</key>
<string>entity.name.constant.java</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#94e2d5</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>CSS property</string>
<key>scope</key>
<string>support.type.property-name.css</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f2cdcd</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>CSS constant</string>
<key>scope</key>
<string>support.constant.property-value.css</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#cdd6f4</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>CSS suffix</string>
<key>scope</key>
<string>constant.numeric.suffix.css, keyword.other.unit.css</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#94e2d5</string>
<key>fontStyle</key>
<string>italic</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>CSS variable property</string>
<key>scope</key>
<string>variable.other.custom-property.name.css, support.type.custom-property.name.css, punctuation.definition.custom-property.css</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#94e2d5</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>SCSS tag</string>
<key>scope</key>
<string>entity.name.tag.css</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#b4befe</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>SASS variable</string>
<key>scope</key>
<string>variable.other.sass</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#94e2d5</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Invalid</string>
<key>scope</key>
<string>invalid</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#cdd6f4</string>
<key>background</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Invalid deprecated</string>
<key>scope</key>
<string>invalid.deprecated</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#cdd6f4</string>
<key>background</key>
<string>#cba6f7</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Diff header</string>
<key>scope</key>
<string>meta.diff, meta.diff.header</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#6c7086</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Diff deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Diff inserted</string>
<key>scope</key>
<string>markup.inserted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#a6e3a1</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Diff changed</string>
<key>scope</key>
<string>markup.changed</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f9e2af</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Message error</string>
<key>scope</key>
<string>message.error</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#f38ba8</string>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>4d0379b5-ef82-467b-b8b8-365889420646</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>semanticClass</key>
<string>theme.dark.Catppuccin</string>
<key>author</key>
<string>BrunDerSchwarzmagier</string>
</dict>
</plist>

View file

@ -1,4 +1,45 @@
local lfs = require "lfs"
local cmark = require "cmark"
cg.addPath("src", ".")
cg.addPath("resources", ".")
cg.doTemplateFile "lib.cgt"
cg.opt.doctype = "<!DOCTYPE html>"
cg.opt.renderMarkdown = function(src)
local doc = cmark.parse_document(src, string.len(src), cmark.OPT_UNSAFE)
for cur, entering, node_type in cmark.walk(doc) do
if node_type == cmark.NODE_CODE_BLOCK then
local lang = cmark.node_get_fence_info(cur)
if #lang > 0 then
local tmpfp = os.tmpname()
local proc = io.popen(
"bat --color always --style plain --language " .. lang .. " | aha --no-header >" .. tmpfp,
"w"
)
proc:write(cmark.node_get_literal(cur))
proc:close()
local tmpf = io.open(tmpfp, "r")
local new = cmark.node_new(cmark.NODE_HTML_BLOCK)
cmark.node_set_literal(new, [[<pre class="codeblock"><code>]] .. tmpf:read "*a" .. [[</code></pre>]])
cmark.node_replace(cur, new)
tmpf:close()
os.remove(tmpfp)
end
end
end
return cmark.render_html(doc, cmark.OPT_UNSAFE)
end
cg.opt.articles = {}
for fpath in lfs.dir "meta" do
if fpath ~= "." and fpath ~= ".." then
local meta = loadfile("meta/" .. fpath)()
table.insert(cg.opt.articles, meta)
end
end

View file

@ -17,55 +17,50 @@
pkgs = import nixpkgs { inherit system; };
in
rec {
packages.lua-discount = pkgs.luajitPackages.callPackage
packages.cmark-lua = pkgs.luajitPackages.callPackage
(
{ buildLuarocksPackage
, fetchurl
, fetchFromGitHub
, ...
}: buildLuarocksPackage rec {
pname = "lua-discount";
version = "dev-1";
pname = "cmark-lua";
version = "0.31.1";
knownRockspec = (fetchurl {
url = "mirror://luarocks/cmark-0.31.1-1.rockspec";
hash = "sha256-lX+YKIV93Jhx7//9YoVILB9k1N2zKNEQcAfWN/pejQM=";
}).outPath;
src = fetchFromGitHub {
owner = "asb";
owner = "jgm";
repo = pname;
rev = "1.2.10.1";
hash = "sha256-UFleCaZkfTDnbjd6+2TwoMacc1hA3h89ghpwtgW51og=";
rev = version;
hash = "sha256-elI+BYPTlFezkoWLjJyPBsAt2Pq2DRe/+YPmtG27ABY=";
};
}
)
{ };
#packages.default = pkgs.stdenvNoCC.mkDerivation {
# name = "homepage";
# src = ./.;
# dontConfigure = true;
# dontFixup = true;
# buildPhase = ''
# runHook preBuild
# ${pkgs.zola}/bin/zola build
# runHook postBuild
# '';
# installPhase = ''
# runHook preInstall
# mv public "$out"
# runHook postInstall
# '';
#};
packages.default = pkgs.stdenvNoCC.mkDerivation {
name = "homepage";
src = ./.;
dontConfigure = true;
dontFixup = true;
nativeBuildInputs = [
nativeBuildInputs = with pkgs; [
confgen.packages.${system}.default
packages.lua-discount
packages.cmark-lua
luajitPackages.luafilesystem
aha
bat
];
buildPhase = ''
cd $src
export XDG_CONFIG_HOME=$src/.config
export XDG_CACHE_HOME=$TMPDIR
bat cache --build
confgen confgen.lua $out
'';
};
@ -74,7 +69,10 @@
buildInputs = with pkgs; [
luajit
confgen.packages.${system}.default
packages.lua-discount
luajitPackages.luafilesystem
packages.cmark-lua
aha
bat
httplz
(pkgs.writeShellScriptBin "serve" ''

20
lib.cgt Normal file
View file

@ -0,0 +1,20 @@
<! opt.mkArticle = function(meta) return function(inner) return tmpl:subtmpl(function(tmpl) !>
<% opt.doctype %>
<html>
<head>
<meta charset="UTF-8" />
<title><% meta.title %></title>
<link rel="stylesheet" href="/article.css" type="text/css" media="all" />
</head>
<body>
<p id="date"><% meta.date %></p>
<h1><% meta.title %></h1>
<p><% meta.summary %></p>
<hr />
<div id="content">
<% opt.renderMarkdown(inner) %>
</div>
</body>
</html>
<! end) end end !>

View file

@ -0,0 +1,7 @@
return {
id = "0001-a-blog-better-late-than-never",
title = "A Blog: better late than never",
summary = "I've got a blog now! One less place safe from my ramblings & infamous hot takes!",
date = "2024-08-16",
-- tags = {}, -- TODO
}

View file

@ -0,0 +1,131 @@
<!
-- vim: ft=markdown
local meta = opt.articles[1]
tmpl:setPostProcessor(opt.mkArticle(meta))
!>
## Hello readers!
Yes, yes, your friendly neighborhood madman now finally did something with his website. Truth be
told, I've long been looking for some place to dump my thoughts, but have always been held back by
a mix of laziness, and the fact that this website used to be generated with
[Zola](https://www.getzola.org/), a static generator that has generally been a pain to work with,
probably because it tried to force design pradigms onto me that I didn't necessarily agree with.
After half a day of coding, this whole website is now generated by
[Confgen](https://git.mzte.de/LordMZTE/confgen), my beloved template engine based on Lua, initially
built for config files (don't ask). If you're interested in how exactly this works, the website
is [open source](https://git.mzte.de/LordMZTE/homepage) as is my moral obligation, but I'll also
explain in a bit. My friend [Marcius](https://github.com/coding-agent), who had this idea first also
wrote a more in-depth article about this concept on his blog (currently doesn't seem to be up
anywhere, I'll add a link here once someone finds it).
## What you'll read here
I'm a programmer, have quite unconventional political views, and this is my *anything goes-zone*.
I'll tell you why X sucks, why Y is great and why society should stop doing Z already. Also, expect
extremely technical and perhaps lengthy articles on whatever comes to my mind and, of course, rants.
## The technicalities
As I've mentioned, this is built with my custom template engine, [Confgen](https://git.mzte.de/LordMZTE/confgen).
The core principles of Confgen are too much to go over here and are deserving of their own article
(If you're reading this, I either haven't written that yet, or forgot to put a link here, go bother me.).
Taking that knowledge not a single person in the world besides me posesses for granted, let's get to
some of the specialties I employed here:
### Markdown
Confgen does not natively support Markdown. This is by design, because if we start supporting every
little thing someone once came up with, we'll find ourselves with an unmaintainable dumpster fire in
no time. Instead, Confgen build on a mature ecosystem, offering *unparalleled* flexibility (for a
template engine, anyways). **All Lua code runs under Confgen!**
Utilizing that incredibly neat fact, I implemented Markdown rendering with the
[cmark-lua](https://github.com/jgm/cmark-lua) library, a set of Lua bindings for the CMark library.
CMark not only offers the full set of Markdown features (especially including the surprisingly
scarcely supported code blocks I'll get into soon), but unlike other libraries doesn't just spit out
the rendered HTML, but also offers access to an Abstract Syntax Tree (AST) of the markdown source,
that can be manipulated to one's will. This is what allowed me to have...
### Syntax Highlighting
...which is a gigantic pain, by the way.
Your average, run-of-the-mill webdev (eww) would've probably just thrown PrismJS or `insert JS
framework that is holding onto survival at the time of reading here` at it, but kind as
I am, I decided to offer you pre-highlighted code on here, so your browser doesn't have to do it!
Instead, I decided to go on a long and arduous journey for CLI tools (Lua libraries were a lost cause)
that can:
- highlight a large set of languages,
- support [Catppuccin](https://github.com/catppuccin/catppuccin),
- and produce HTML.
Surprise, surprise, that doesn't exist, especially because Zig support was a must.
My solution was to beat some tool not meant for this whatsoever into submission, as I like to do.
Today's victim was [Bat](https://github.com/sharkdp/bat), which ticks the first two boxes, but
disappointingly leaves the third unchecked, only outputting ANSI (=terminal)-formatted data.
Luckily, there exists a tool called [ANSI HTML Adapter](https://github.com/theZiz/aha) that can
convert Bat's output.
The only lacking step now was to integrate this into Confgen, which was easy enough.
```lua
-- Parse the Markdown source. UNSAFE signifies that we don't want to sanitize the input.
local doc = cmark.parse_document(src, string.len(src), cmark.OPT_UNSAFE)
-- Iterate over all nodes
for cur, entering, node_type in cmark.walk(doc) do
-- If we found a code block...
if node_type == cmark.NODE_CODE_BLOCK then
-- Get its language
local lang = cmark.node_get_fence_info(cur)
-- If the language is not unspecified
if #lang > 0 then
-- Invoke Bat and AHA, writing the HTML code to a temporary file.
local tmpfp = os.tmpname()
local proc = io.popen(
"bat --color always --style plain --language " .. lang .. " | aha --no-header >" .. tmpfp,
"w"
)
proc:write(cmark.node_get_literal(cur))
proc:close()
-- Replace the code block node with the generated HTML
local tmpf = io.open(tmpfp, "r")
local new = cmark.node_new(cmark.NODE_HTML_BLOCK)
cmark.node_set_literal(new, [[<pre class="codeblock"><code>]] .. tmpf:read "*a" .. [[</code></pre>]])
cmark.node_replace(cur, new)
tmpf:close()
os.remove(tmpfp)
end
end
end
return cmark.render_html(doc, cmark.OPT_UNSAFE)
```
Works a charm, doesn't it?
### API (or one generated JSON file to be precise)
The index of articles on mzte.de is not static gen'd, although that'd be easier, but instead produced
by some <del>Javashit</del> JavaScript code to facilitate a future tagging and filtering system I've
got planned. As a consequence of this, a JSON-based index of articles you may use at your leisure is
to be found [here](/articles.json). It looks somewhat like this, but this is subject to change
without warning:
```json
{
"tags": {}, // This will likely include name & color of future tags
"articles": [ // Oldest first
{
"id": "0001-a-blog-better-late-than-never",
"title": "A Blog: better late than never",
"summary": "I've got a blog now! One less place safe from my ramblings & infamous hot takes!",
"date": "2024-08-16"
}
]
}
```
That's pretty much all there is to it. I hope you've enjoyed this quick read and here's to many more!

33
src/article.css Normal file
View file

@ -0,0 +1,33 @@
html,
body {
background-color: #181825;
color: #cdd6f4;
font-family: Iosevka, monospace;
height: 100%;
}
a {
color: #cba6f7;
}
#date {
float: right;
}
#content {
margin: 12px;
padding: 4px;
background-color: #1e1e2e;
font-size: 12pt;
}
code, .codeblock {
background-color: #11111b;
color: #a6adc8;
}
.codeblock {
color: #cdd6f4;
margin: 12px;
padding: 4px;
}

5
src/articles.json.cgt Normal file
View file

@ -0,0 +1,5 @@
<! local val = {
tags = {},
articles = opt.articles,
} !>
<% cg.fmt.json.serialize(val) %>

View file

@ -1,18 +1,47 @@
body {
background-color: #1e1e2e;
color: #cdd6f4;
font-family: monospace;
background-color: #1e1e2e;
color: #cdd6f4;
font-family: Iosevka, monospace;
}
#header {
display: flex;
float: left;
display: flex;
float: left;
}
#links {
float: right;
float: right;
}
#articles {
height: 100%;
width: 100%;
overflow-y: auto;
}
.article {
background-color: #181825;
border: 2px solid;
border-color: #f38ba8;
margin: 8px;
padding: 4px;
}
.article_a {
color: inherit;
text-decoration: none;
}
.article .row {
display: flex;
flex-direction: row;
}
.article h2 {
flex-grow: 1;
text-decoration: underline;
}
a {
color: #cba6f7;
color: #cba6f7;
}

View file

@ -10,7 +10,7 @@
<head>
<link rel="stylesheet" href="index.css" type="text/css" media="all" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<script src="index.js"></script>
<title>LordMZTE</title>
</head>
@ -31,8 +31,8 @@
</div>
</div>
<div id=" content" width="100%">
<! tmpl:pushSubtmpl(function(tmpl) tmpl:setPostProcessor(require "discount") !>
<div id="content" width="100%">
<! tmpl:pushSubtmpl(function(tmpl) tmpl:setPostProcessor(opt.renderMarkdown) !>
# Hey! Welcome to my website!
I'm LordMZTE, a programmer from Thuringia, Germany. I like to code in Zig, sometimes Rust and rarely
also some Minecraft mods. If you're looking for my projects, you should visit [my git server](/git).
@ -46,6 +46,12 @@ If you want to chat, you can also reach me on matrix (`@lordmzte:mzte.de`).
[PGP key](/public.key)
<! end) !>
</div>
<h1>Articles</h1>
<hr />
<div id="articles">
</div>
<script>loadArticles();</script>
</body>
</html>

42
src/index.js Normal file
View file

@ -0,0 +1,42 @@
// TODO: rewrite in Haxe
function makeArticleElement(article) {
let aEl = document.createElement("a");
aEl.href = `/a/${article.id}/`;
aEl.classList.add("article_a");
let divEl = document.createElement("div");
divEl.classList.add("article");
{
let rowEl = document.createElement("div");
rowEl.classList.add("row");
{
let headerEl = document.createElement("h2");
headerEl.innerText = article.title;
rowEl.appendChild(headerEl);
let dateEl = document.createElement("p");
dateEl.classList.add("date");
dateEl.innerText = article.date;
rowEl.append(dateEl);
}
divEl.appendChild(rowEl);
let summaryEl = document.createElement("p");
summaryEl.innerText = article.summary;
divEl.appendChild(summaryEl);
}
aEl.appendChild(divEl);
return aEl;
}
function loadArticles() {
let artdiv = document.getElementById("articles");
fetch("articles.json")
.then((res) => res.json())
.then((json) => {
json.articles.reverse().forEach((article) => {
artdiv.appendChild(makeArticleElement(article));
});
});
}

2
stylua.toml Normal file
View file

@ -0,0 +1,2 @@
indent_type = "Spaces"
no_call_parentheses = true