'crude' template

This commit is contained in:
Nox Sluijtman 2025-04-22 09:37:59 +02:00
parent fc54843031
commit 2e47030987
Signed by: Egg
SSH key fingerprint: SHA256:2sG9X3C7Xvq2svGumz1/k7cm8l4G9+qAtAeugqB4J9M
5 changed files with 221 additions and 0 deletions

1
crude/.envrc Normal file
View file

@ -0,0 +1 @@
use flake

2
crude/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
result
.direnv

31
crude/flake.nix Normal file
View file

@ -0,0 +1,31 @@
{
description = "Extremely basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages = {
default = throw "put derivation information here";
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
(throw "put packages here")
];
};
}
);
}

182
crude/template.typ Normal file
View file

@ -0,0 +1,182 @@
#let crude(
title: if sys.inputs.keys().contains("title") {
sys.inputs.title
} else {
none
},
author: if sys.inputs.keys().contains("author") {
sys.inputs.author
} else {
none
},
sigil: if sys.inputs.keys().contains("sigil") {
sys.inputs.sigil
} else {
"sigil.svg"
},
font: (
text: {
if sys.inputs.keys().contains("font") {
let argFont = sys.inputs.font
if argFont == "mono" {
"Fira Mono"
} else if argFont == "sans" {
"Fira Sans"
} else if argFont == "orb" {
"Orbitron"
} else {
argFont
}
} else {
"Fira Sans"
}
},
decoration: {
if sys.inputs.keys().contains("decoFont") {
let argFont = sys.inputs.decoFont
if argFont == "mono" {
"Fira Mono"
} else if argFont == "sans" {
"Fira Sans"
} else if argFont == "orb" {
"Orbitron"
} else {
argFont
}
} else {
"Orbitron"
}
}
),
colors: if sys.inputs.keys().contains("colorScheme") {
let cs = sys.inputs.colorScheme
if cs == "light" {
(
background: "ccccce",
foreground: "0d0d1b",
)
} else if cs == "pink" {
(
background: "0d0d1b",
foreground: "E60073"
)
} else {
(
background: "0d0d1b",
foreground: "ccccce",
)
}
} else {
(
background: "0d0d1b",
foreground: "ccccce",
)
},
nixPath: if sys.inputs.keys().contains("nixPath") {
sys.inputs.nixPath
} else {
"cd389898-51c9-53ee-8d27-4885055eed67"
},
titleHash: if sys.inputs.keys().contains("titleHash") {
sys.inputs.titleHash
} else {
"ad3ebf6b-7c3a-5986-a46e-89777e5c2554"
},
doc,
) = {
counter(page).update(0)
set document(
title: title,
author: author
)
show heading: head => {
set text(font: font.decoration, 1.2em)
head
v(0.8em)
}
show quote: q => {
set text(font: font.decoration)
q
}
set quote(
block: true,
quotes: true
)
set page(
numbering: "I",
paper: "a4",
fill: color.rgb(colors.background),
header: context {
if counter(page).get().first() > 0 [
#set text(font: font.decoration)
_#nixPath _
#h(1fr)
*#document.author.join()*
]
},
footer: context {
if counter(page).get().first() > 0 [
#set text(font: font.decoration)
*#(document.title, titleHash).join(" ")*
#h(1fr)
#counter(page).display("I")
]
}
)
set par(
justify: true
)
set text(
fill: color.rgb(colors.foreground),
font: (font.text, font.decoration),
lang: "en"
)
figure(
image(sigil, width: 100%),
)
align(center)[
#set text(font: font.decoration, 36pt, weight: "black")
#context { document.title }
]
align(center)[
#set text(font: font.decoration, 24pt)
#context { document.author.join() }
]
let prependHash(color) = {
if color.first() != "#" {
upper("#" + color)
} else {
upper(color)
}
}
v(1fr)
context {
set text(font: font.decoration, 13pt)
align(right, (
colors.values().map(x => prependHash(x)),
{ if font.text != font.decoration {
(font.text, font.decoration).zip(("Text", "Decoration")).map(x => x.join(" - "))
} else {
font.text
} },
).flatten().map(x => [#x]).join("\n") )
}
pagebreak()
doc
}

View file

@ -20,6 +20,11 @@
description = "A basic Haskell flake"; description = "A basic Haskell flake";
}; };
crude = {
path = ./crude;
description = "A somewhat 'crude' looking typst template";
};
}; };
defaultTemplate = self.templates.trivial; defaultTemplate = self.templates.trivial;
}; };