overhaul a lot of stuff
- added lref feature which links to files in the knowledge base without having to add ten million "../../../" - instructions changed so that now you can link to "/templates/template.typ" without having to add ten million "../../../" to the path
This commit is contained in:
parent
7853f1e5db
commit
99fd8e3788
26
README.md
26
README.md
@ -15,14 +15,36 @@ docs/
|
|||||||
└── ...
|
└── ...
|
||||||
```
|
```
|
||||||
|
|
||||||
Personally, I set up templates as a git submodule, and docs as another git repo.
|
## Installation
|
||||||
|
|
||||||
|
Set up `docs/` as a git repo.
|
||||||
|
|
||||||
|
mkdir docs
|
||||||
|
cd docs
|
||||||
|
git init
|
||||||
|
|
||||||
|
Add `templates/` as a submodule.
|
||||||
|
|
||||||
|
git submodule add https://github.com/dogeystamp/typst-templates templates
|
||||||
|
|
||||||
|
Set the environment variable `TYPST_ROOT` to `docs/` in `.bashrc`, `.profile` or equivalent.
|
||||||
|
Otherwise, templates won't be able to render due to security policy.
|
||||||
|
|
||||||
|
.profile
|
||||||
|
--------
|
||||||
|
|
||||||
|
export TYPST_ROOT="$HOME/docs"
|
||||||
|
|
||||||
|
Create a settings file in `docs/`:
|
||||||
|
|
||||||
|
templates/gensettings.sh settings.yml
|
||||||
|
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
Example usage (this is test.typ in the above tree:)
|
Example usage (this is test.typ in the above tree:)
|
||||||
|
|
||||||
```typ
|
```typ
|
||||||
#import "../templates/problems.typ": template, source_code, status
|
#import "/templates/problems.typ": template, source_code, status
|
||||||
#show: template.with(
|
#show: template.with(
|
||||||
title: "CCC '22 J1 - Cupcake Party",
|
title: "CCC '22 J1 - Cupcake Party",
|
||||||
problem_url: "https://dmoj.ca/problem/cc22j1",
|
problem_url: "https://dmoj.ca/problem/cc22j1",
|
||||||
|
2
algs.typ
2
algs.typ
@ -1,6 +1,6 @@
|
|||||||
// templates for compsci notes
|
// templates for compsci notes
|
||||||
|
|
||||||
#import "main.typ": gen_title, gen_authors, doc_template, mono_font
|
#import "main.typ": gen_title, gen_authors, doc_template, mono_font, lref
|
||||||
#import "compsci.typ": source_code
|
#import "compsci.typ": source_code
|
||||||
|
|
||||||
#let template(
|
#let template(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// general document
|
// general document
|
||||||
|
|
||||||
#import "main.typ": gen_title, gen_authors, doc_template
|
#import "main.typ": gen_title, gen_authors, doc_template, lref
|
||||||
|
|
||||||
#let template(
|
#let template(
|
||||||
title: none,
|
title: none,
|
||||||
|
13
gensettings.sh
Executable file
13
gensettings.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PROGNAME=$(basename "$0")
|
||||||
|
|
||||||
|
if [ -z "$TYPST_ROOT" ]; then
|
||||||
|
echo "$PROGNAME: "'Please set $TYPST_ROOT.'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF > $1
|
||||||
|
prefix: "$TYPST_ROOT"
|
||||||
|
me: "$USER"
|
||||||
|
EOF
|
16
main.typ
16
main.typ
@ -6,12 +6,22 @@
|
|||||||
#let normal-size = 12pt
|
#let normal-size = 12pt
|
||||||
#let large-size = 12pt
|
#let large-size = 12pt
|
||||||
|
|
||||||
#let me = "dogeystamp"
|
|
||||||
|
|
||||||
#let font = "IBM Plex Sans"
|
#let font = "IBM Plex Sans"
|
||||||
#let heading_font = "IBM Plex Sans"
|
#let heading_font = "IBM Plex Sans"
|
||||||
#let mono_font = "DejaVu Sans Mono"
|
#let mono_font = "DejaVu Sans Mono"
|
||||||
|
|
||||||
|
#let settings = yaml("/settings.yml")
|
||||||
|
|
||||||
|
// reference based on TYPST_ROOT
|
||||||
|
// use paths like "/problems/problem.pdf"
|
||||||
|
// which will translate to "/home/user/docs/problems/problem.pdf"
|
||||||
|
#let lref(
|
||||||
|
url,
|
||||||
|
text
|
||||||
|
) = {
|
||||||
|
return link(settings.prefix + url, text)
|
||||||
|
}
|
||||||
|
|
||||||
#let gen_title(
|
#let gen_title(
|
||||||
title: none,
|
title: none,
|
||||||
) = {
|
) = {
|
||||||
@ -28,7 +38,7 @@
|
|||||||
if authors == none {
|
if authors == none {
|
||||||
authors = (
|
authors = (
|
||||||
(
|
(
|
||||||
name: me,
|
name: settings.me,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// templates for compsci problem documents outside of contests
|
// templates for compsci problem documents outside of contests
|
||||||
|
|
||||||
#import "main.typ": gen_title, gen_authors, doc_template, mono_font
|
#import "main.typ": gen_title, gen_authors, doc_template, mono_font, lref
|
||||||
#import "compsci.typ": source_code, status
|
#import "compsci.typ": source_code, status
|
||||||
|
|
||||||
#let template(
|
#let template(
|
||||||
|
2
sfd.typ
2
sfd.typ
@ -1,6 +1,6 @@
|
|||||||
// templates for online lecture notes
|
// templates for online lecture notes
|
||||||
|
|
||||||
#import "main.typ": gen_title, gen_authors, doc_template, mono_font
|
#import "main.typ": gen_title, gen_authors, doc_template, mono_font, lref
|
||||||
|
|
||||||
#let template(
|
#let template(
|
||||||
title: none,
|
title: none,
|
||||||
|
Loading…
Reference in New Issue
Block a user