Skip to content

Commit 19e094d

Browse files
committed
ci: build readme for universe
1 parent 983969d commit 19e094d

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,17 @@ jobs:
5252
uses: hustcer/setup-nu@v3
5353

5454
- name: Install tools
55-
uses: taiki-e/install-action@just
55+
uses: taiki-e/install-action@v2
56+
with:
57+
tool: just,typlite
5658

5759
- name: Setup typst
5860
uses: typst-community/setup-typst@v3
5961

6062
- name: Build package
61-
run: just package
63+
run: |
64+
just readme-build-universe
65+
just package
6266
6367
- name: Upload artifacts
6468
uses: actions/upload-artifact@v4

README.typ

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "src/lib.typ" as oc: *
1+
#import "/src/lib.typ" as oc: *
22
#import oc.themes: *
33

44
#let is-html-target = dictionary(std).keys().contains("html")
@@ -72,7 +72,8 @@ _Create chat interfaces in Typst with ease_
7272

7373
Ourchat is a #link("https://typst.app/")[Typst] package for building chat UI mockups. It helps you document software features, create presentations, or prototype chat interfaces with themes for popular platforms like WeChat, Discord, and QQ.
7474

75-
#if sys.inputs.at("target-universe", default: false) != "true" {
75+
#let is-universe-target = false // FIXME - use `sys.input` when typlite works properly
76+
#if not is-universe-target {
7677
preview(
7778
reversed: true,
7879
````typst

scripts/package.nu

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,47 @@ def main [target_dir: string = "out"] {
1414
}
1515

1616
# List of files and directories to copy
17-
let items = ["typst.toml", "LICENSE", "README.md", "src", "assets"]
17+
let items = ["typst.toml", "LICENSE", "src"]
1818

1919
# Copy each item in the array
2020
for item in $items {
2121
try { cp -r -u $item $target_dir } catch { print $"No `($item)` to copy" }
2222
}
2323

24+
print "Building README for universe..."
25+
26+
build_readme $target_dir
27+
2428
print $"Packaging complete. Files copied to ($target_dir)/"
2529
print "Package contents:"
2630
ls $target_dir
2731
}
32+
33+
def build_readme [target_dir: string] {
34+
cd $target_dir
35+
36+
# Copy README.typ to modify `is-universe-target`
37+
let readme_typ = "README.typ"
38+
open ../README.typ
39+
| str replace "#let is-universe-target = false" "#let is-universe-target = true"
40+
| save $readme_typ -f
41+
42+
let readme_tmp = "README.tmp.md"
43+
let readme = "README.md"
44+
typlite README.typ $readme_tmp --assets-path assets --root (".." | path expand)
45+
# Fix image slash in the README
46+
open $readme_tmp
47+
| lines
48+
| each { |line|
49+
if ($line | str starts-with '![typst-frame](') {
50+
$line | str replace -a '\' '/'
51+
} else {
52+
$line
53+
}
54+
}
55+
| str join "\n"
56+
| $in + "\n"
57+
| save $readme -f
58+
rm $readme_tmp
59+
rm $readme_typ
60+
}

0 commit comments

Comments
 (0)