Skip to content

Commit e3735f9

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 c531b93 commit e3735f9

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
@@ -133,7 +133,7 @@ impl OgImageGenerator {
133133
// Get the bytes either from the included asset or download from URL
134134
let bytes = if *avatar == "test-avatar" {
135135
// Copy directly from included bytes
136-
Bytes::from_static(include_bytes!("../assets/test-avatar.png"))
136+
Bytes::from_static(include_bytes!("../template/assets/test-avatar.png"))
137137
} else {
138138
// Download the avatar from the URL
139139
let response = client.get(*avatar).send().await.map_err(|err| {
@@ -203,28 +203,28 @@ impl OgImageGenerator {
203203
// Create assets directory and copy logo and icons
204204
let assets_dir = temp_dir.path().join("assets");
205205
fs::create_dir(&assets_dir).await?;
206-
let cargo_logo = include_bytes!("../assets/cargo.png");
206+
let cargo_logo = include_bytes!("../template/assets/cargo.png");
207207
fs::write(assets_dir.join("cargo.png"), cargo_logo).await?;
208-
let rust_logo_svg = include_bytes!("../assets/rust-logo.svg");
208+
let rust_logo_svg = include_bytes!("../template/assets/rust-logo.svg");
209209
fs::write(assets_dir.join("rust-logo.svg"), rust_logo_svg).await?;
210210

211211
// Copy SVG icons
212-
let code_branch_svg = include_bytes!("../assets/code-branch.svg");
212+
let code_branch_svg = include_bytes!("../template/assets/code-branch.svg");
213213
fs::write(assets_dir.join("code-branch.svg"), code_branch_svg).await?;
214-
let code_svg = include_bytes!("../assets/code.svg");
214+
let code_svg = include_bytes!("../template/assets/code.svg");
215215
fs::write(assets_dir.join("code.svg"), code_svg).await?;
216-
let scale_balanced_svg = include_bytes!("../assets/scale-balanced.svg");
216+
let scale_balanced_svg = include_bytes!("../template/assets/scale-balanced.svg");
217217
fs::write(assets_dir.join("scale-balanced.svg"), scale_balanced_svg).await?;
218-
let tag_svg = include_bytes!("../assets/tag.svg");
218+
let tag_svg = include_bytes!("../template/assets/tag.svg");
219219
fs::write(assets_dir.join("tag.svg"), tag_svg).await?;
220-
let weight_hanging_svg = include_bytes!("../assets/weight-hanging.svg");
220+
let weight_hanging_svg = include_bytes!("../template/assets/weight-hanging.svg");
221221
fs::write(assets_dir.join("weight-hanging.svg"), weight_hanging_svg).await?;
222222

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

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

0 commit comments

Comments
 (0)