frontmatter meta stuff

This commit is contained in:
41666 2025-04-21 19:24:16 -07:00
parent 9aad36f910
commit c2861b8f18
7 changed files with 204 additions and 18 deletions

154
README.md
View file

@ -1,3 +1,157 @@
# Teapot
because doll. it uses [markdoll](https://codeberg.org/0x57e11a/markdoll).
## Usage
this is a nix package/flakey thing, the package outputs a normal directory/derivation so awawa
### step 1: make the nix package!
basically, make a package that do this (there's like 8 ways to do this please be careful)
```nix
brewTea {
name = "doll site";
src = ./.;
layoutSrc = ./layouts;
defaultLayout = ./layouts/default.html;
};
```
### step 2: make the default layout!
here's a good `layouts/default.html` to start with..
```html
<!DOCTYPE html public "awawawawa">
<html>
<head>
<meta charset="utf-8" />
<title>%%TITLE%%:doll</title>
%%HEAD%%
<style>
body {
background-color: #0a0103;
color: #c24444;
font-family: system-ui;
}
</style>
</head>
<body>
<main>%%CONTENT%%</main>
</body>
</html>
```
#### step 2a: what the %%%% do
the layout engine knows three keywords:
- `%%TITLE%%` which comes from either the filename (so `index.doll` -> `index`) or the frontmatter `title` key (what is a frontmatter? skip to **step 3a**)
- `%%HEAD%%` which is filled in by the following frontmatter keys:
- `description` becomes a meta:description tag
- `tags` becomes a meta:keywords tag
- `author` becomes a meta:author tag
- `%%CONTENT%%` becomes the markdoll content
### step 3: make MARKDOLL!!!!!
ok so lets just put something basic into `index.doll`
```
&hello everydolly!
awawawawawa
[img(https://codeberg.org/0x57e11a/markdoll/raw/branch/main/button.png)::
alt text goes here (88x31 button that says MADE WITH MARKDOLL)
]
```
### step 3a: make FRONTMATTER!!
(this is a weird word dw about it its actually some cool stuff)
so we can add some details aboput every markdoll file,, lets add everything we support!!
```
---
title: doll!!! points!
description: dolldolldolldolldolldolldolldoll
tags: no witches allowed, maybe if She brings tea tho
author: aki.41666
layout: default.html
---
&hello everydolly!
awawawawawa
[img(https://codeberg.org/0x57e11a/markdoll/raw/branch/main/button.png)::
alt text goes here (88x31 button that says MADE WITH MARKDOLL)
]
```
its the stuff between the --- and --- thing
is IS NOT YAML
do NOT yaml this. it is `key: value` and value is a string
no exceptions!!!!!!!!!
### step 3b: make another layout
so we can add more layouts to `layouts/` folder, maybe have one for the smart sysmate and one for the silly sysmate
and switch between them using `layout` in frontmatter
so together,
`layouts/aki.html`
```html
<!DOCTYPE html public "awawawawa">
<html>
<head>
<meta charset="utf-8" />
<title>%%TITLE%%:doll/aki</title>
%%HEAD%%
<style>
body {
background-color: #0a0103;
color: rgb(225, 0, 255);
font-family: system-ui;
}
</style>
</head>
<body>
<nav>aki!!!!!!!!!</nav>
<main>%%CONTENT%%</main>
</body>
</html>
```
and then a simple `aki.doll`
```
---
title: hi it is
layout: aki.html
---
&its aki!!!!!!!!!
awawa
```
this will produce a different output containing 100% more aki
### step 4: build it (n stuff)
the easiest way to _just output stuff_ is
```sh
nix build . # if using flakes
nix-build # if not
nix-shell -p python3 --command "python -m http.server -d result" # to look at it
```
and open http://localhost:8000

View file

@ -4,4 +4,7 @@
src = ./.;
layoutSrc = ./layouts;
# maybe don't do this but its possible to reference _any file_.
defaultLayout = ./layouts/default.html;
}

View file

@ -1,6 +1,8 @@
---
title: awawa!
layout: alt.html
description: this is teapot!!
tags: teapot, markdoll
---
this is markdoll!

View file

@ -1,12 +1,17 @@
<!DOCTYPE html public "alt layout">
<title>%%TITLE%% | alt layout</title>
<style>
body {
background-color: black;
color: white;
}
</style>
<body>
<nav>alt layout!!!</nav>
<main>%%CONTENT%%</main>
</body>
<html>
<head>
<title>%%TITLE%% | alt layout</title>
%%HEAD%%
<style>
body {
background-color: black;
color: white;
}
</style>
</head>
<body>
<nav>alt layout!!!</nav>
<main>%%CONTENT%%</main>
</body>
</html>

View file

@ -1,6 +1,11 @@
<!DOCTYPE html public "default layout">
<title>%%TITLE%% | default layout</title>
<body>
<nav>default layout!!!</nav>
<main>%%CONTENT%%</main>
</body>
<html>
<head>
<title>%%TITLE%% | default layout</title>
%%HEAD%%
</head>
<body>
<nav>default layout!!!</nav>
<main>%%CONTENT%%</main>
</body>
</html>

View file

@ -1,5 +1,6 @@
---
title: AWAWAWA
layout: default.html
---
&real awawa shit

View file

@ -35,7 +35,7 @@ in pkgs.stdenvNoCC.mkDerivation {
key=$1
file=$2
keyLine=$(grep -e "$key: " $file || echo "")
keyLine=$(grep -e "^$key: " $file || echo "")
sed "s/.*: //" <<<$keyLine | xargs
}
@ -66,9 +66,25 @@ in pkgs.stdenvNoCC.mkDerivation {
title=$(basename $file | sed -e 's/.doll$//')
fi
### Frontmatter: Meta Head Stuff
local head=""
local meta_description=$(get_frontmatter description $file)
if [ ! -z meta_description ]; then
head="$head<meta name='description' content='$meta_description'>"
fi
local meta_tags=$(get_frontmatter tags $file)
if [ ! -z meta_tags ]; then
head="$head<meta name='keywords' content='$meta_tags'>"
fi
local meta_author=$(get_frontmatter author $file)
if [ ! -z meta_author ]; then
head="$head<meta name='author' content='$meta_author'>"
fi
### Layout: Title + Content
layout_inject $layoutPath %%TITLE%% <<<"$title" > $outFile.tmp.1
layout_inject $outFile.tmp.1 %%CONTENT%% $content > $outFile.tmp.final
layout_inject $outFile.tmp.1 %%HEAD%% <<<"$head" > $outFile.tmp.2
layout_inject $outFile.tmp.2 %%CONTENT%% $content > $outFile.tmp.final
### Layout: Cleanup Tmpfiles
cp $outFile.tmp.final $outFile