Skip to content

Commit 86ec033

Browse files
committed
og_image: Move assets into template folder
This allows `typst compile template/og-image.typ --input 'data={"name":"foo","version":"1.0.0"}'` to work too.
1 parent 21cae1f commit 86ec033

File tree

10 files changed

+9
-9
lines changed

10 files changed

+9
-9
lines changed

crates/crates_io_og_image/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl OgImageGenerator {
134134
// Get the bytes either from the included asset or download from URL
135135
let bytes = if *avatar == "test-avatar" {
136136
// Copy directly from included bytes
137-
Bytes::from_static(include_bytes!("../assets/test-avatar.png"))
137+
Bytes::from_static(include_bytes!("../template/assets/test-avatar.png"))
138138
} else {
139139
// Download the avatar from the URL
140140
let response = client.get(*avatar).send().await.map_err(|err| {
@@ -204,28 +204,28 @@ impl OgImageGenerator {
204204
// Create assets directory and copy logo and icons
205205
let assets_dir = temp_dir.path().join("assets");
206206
fs::create_dir(&assets_dir).await?;
207-
let cargo_logo = include_bytes!("../assets/cargo.png");
207+
let cargo_logo = include_bytes!("../template/assets/cargo.png");
208208
fs::write(assets_dir.join("cargo.png"), cargo_logo).await?;
209-
let rust_logo_svg = include_bytes!("../assets/rust-logo.svg");
209+
let rust_logo_svg = include_bytes!("../template/assets/rust-logo.svg");
210210
fs::write(assets_dir.join("rust-logo.svg"), rust_logo_svg).await?;
211211

212212
// Copy SVG icons
213-
let code_branch_svg = include_bytes!("../assets/code-branch.svg");
213+
let code_branch_svg = include_bytes!("../template/assets/code-branch.svg");
214214
fs::write(assets_dir.join("code-branch.svg"), code_branch_svg).await?;
215-
let code_svg = include_bytes!("../assets/code.svg");
215+
let code_svg = include_bytes!("../template/assets/code.svg");
216216
fs::write(assets_dir.join("code.svg"), code_svg).await?;
217-
let scale_balanced_svg = include_bytes!("../assets/scale-balanced.svg");
217+
let scale_balanced_svg = include_bytes!("../template/assets/scale-balanced.svg");
218218
fs::write(assets_dir.join("scale-balanced.svg"), scale_balanced_svg).await?;
219-
let tag_svg = include_bytes!("../assets/tag.svg");
219+
let tag_svg = include_bytes!("../template/assets/tag.svg");
220220
fs::write(assets_dir.join("tag.svg"), tag_svg).await?;
221-
let weight_hanging_svg = include_bytes!("../assets/weight-hanging.svg");
221+
let weight_hanging_svg = include_bytes!("../template/assets/weight-hanging.svg");
222222
fs::write(assets_dir.join("weight-hanging.svg"), weight_hanging_svg).await?;
223223

224224
// Process avatars - download URLs and copy assets
225225
let avatar_map = self.process_avatars(&data, &assets_dir).await?;
226226

227227
// Copy the static Typst template file
228-
let template_content = include_str!("../templates/og-image.typ");
228+
let template_content = include_str!("../template/og-image.typ");
229229
let typ_file_path = temp_dir.path().join("og-image.typ");
230230
fs::write(&typ_file_path, template_content).await?;
231231

0 commit comments

Comments
 (0)