Skip to content

Commit f1c29ea

Browse files
fix(ssg): 🐛 fix formatting
1 parent e8e98ed commit f1c29ea

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

examples/multilingual_example.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//! This example demonstrates how to generate a multilingual static site
77
//! with a language selector at the root of the `public` directory.
88
9-
use anyhow::Result;
109
use anyhow::Context;
10+
use anyhow::Result;
1111
use http_handle::Server;
1212
use staticdatagen::compiler::service::compile;
1313
use std::fs::{self, write};
@@ -46,30 +46,41 @@ fn main() -> Result<()> {
4646
generate_language_selector(&public_root, &languages)?;
4747

4848
// Serve the root public directory
49-
let server = Server::new("127.0.0.1:3000", public_root.to_str().unwrap());
49+
let server =
50+
Server::new("127.0.0.1:3000", public_root.to_str().unwrap());
5051
println!("Serving site at http://127.0.0.1:3000");
5152
let _ = server.start();
5253

5354
Ok(())
5455
}
5556

5657
/// Generates a root `index.html` file using the `templates/selector.html` template
57-
fn generate_language_selector(public_root: &Path, languages: &[&str]) -> Result<()> {
58+
fn generate_language_selector(
59+
public_root: &Path,
60+
languages: &[&str],
61+
) -> Result<()> {
5862
// Read the selector.html template
5963
let template_path = Path::new("./examples/templates/selector.html");
60-
let template = fs::read_to_string(&template_path).context("Failed to read selector.html template")?;
64+
let template = fs::read_to_string(&template_path)
65+
.context("Failed to read selector.html template")?;
6166

6267
// Replace the placeholder with the language links
6368
let mut language_links = String::new();
6469
for lang in languages {
65-
let link = format!("<li><a href=\"./{}/\">{}</a></li>\n", lang, lang.to_uppercase());
70+
let link = format!(
71+
"<li><a href=\"./{}/\">{}</a></li>\n",
72+
lang,
73+
lang.to_uppercase()
74+
);
6675
language_links.push_str(&link);
6776
}
68-
let output_html = template.replace("{{LANGUAGE_LINKS}}", &language_links);
77+
let output_html =
78+
template.replace("{{LANGUAGE_LINKS}}", &language_links);
6979

7080
// Write the generated HTML to `public/index.html`
7181
let index_path = public_root.join("index.html");
72-
write(index_path, output_html).context("Failed to write language selector index.html")?;
82+
write(index_path, output_html)
83+
.context("Failed to write language selector index.html")?;
7384
println!(" ✅ Generated language selector at root index.html using template");
7485

7586
Ok(())

examples/quickstart_example.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ impl SiteGenerator {
6363
let content_dir = fs::canonicalize(content_dir)?;
6464
let output_dir = fs::canonicalize(output_dir)?;
6565
let template_dir = fs::canonicalize(template_dir)?;
66-
let site_dir = fs::canonicalize(site_dir.clone()).unwrap_or(site_dir);
66+
let site_dir =
67+
fs::canonicalize(site_dir.clone()).unwrap_or(site_dir);
6768

6869
// Create configuration
6970
let config = ShokuninConfig::builder()

0 commit comments

Comments
 (0)