mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-17 17:25:01 +00:00
fix subfolder generation
This commit is contained in:
parent
03443ec328
commit
c7f8ba6ded
5 changed files with 8 additions and 4 deletions
1
examples/static-site-gen/.gitignore
vendored
1
examples/static-site-gen/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
/output/*.html
|
/output/*.html
|
||||||
|
/output/subFolder
|
||||||
/static-site
|
/static-site
|
||||||
/bin
|
/bin
|
||||||
|
|
|
@ -61,4 +61,5 @@ Herculei undae calcata inmeriti quercus ignes parabant iam.
|
||||||
|
|
||||||
```roc
|
```roc
|
||||||
codeExample.roc
|
codeExample.roc
|
||||||
```
|
```
|
||||||
|
|
|
@ -226,7 +226,7 @@ fn process_file(input_dir: &Path, output_dir: &Path, input_file: &Path) -> Resul
|
||||||
}
|
}
|
||||||
pulldown_cmark::Event::End(pulldown_cmark::Tag::CodeBlock(_)) => {
|
pulldown_cmark::Event::End(pulldown_cmark::Tag::CodeBlock(_)) => {
|
||||||
if in_code_block {
|
if in_code_block {
|
||||||
match replace_code_with_static_file(&code_to_highlight, input_dir) {
|
match replace_code_with_static_file(&code_to_highlight, input_file) {
|
||||||
None => {}
|
None => {}
|
||||||
// Check if the code block is actually just a relative
|
// Check if the code block is actually just a relative
|
||||||
// path to a static file, if so replace the code with
|
// path to a static file, if so replace the code with
|
||||||
|
@ -327,10 +327,12 @@ fn is_roc_code_block(cbk: &pulldown_cmark::CodeBlockKind) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn replace_code_with_static_file(code: &str, input_dir: &Path) -> Option<String> {
|
fn replace_code_with_static_file(code: &str, input_file: &Path) -> Option<String> {
|
||||||
|
let input_dir = input_file.parent()?;
|
||||||
let trimmed_code = code.trim();
|
let trimmed_code = code.trim();
|
||||||
if trimmed_code.len() <= 255 && trimmed_code.contains(".") {
|
if trimmed_code.len() <= 255 && trimmed_code.contains(".") {
|
||||||
let file_path = input_dir.join(trimmed_code);
|
let file_path = input_dir.join(trimmed_code);
|
||||||
|
|
||||||
let vec_u8 = fs::read(file_path).ok()?;
|
let vec_u8 = fs::read(file_path).ok()?;
|
||||||
|
|
||||||
String::from_utf8(vec_u8).ok()
|
String::from_utf8(vec_u8).ok()
|
||||||
|
|
|
@ -14,7 +14,7 @@ NavLink : {
|
||||||
|
|
||||||
navLinks : List NavLink
|
navLinks : List NavLink
|
||||||
navLinks = [
|
navLinks = [
|
||||||
{ url: "apple.html", title: "Exempli Gratia Pagina Pomi", text: "Apple" },
|
{ url: "subFolder/apple.html", title: "Exempli Gratia Pagina Pomi", text: "Apple" },
|
||||||
{ url: "banana.html", title: "Exempli Gratia Pagina Musa", text: "Banana" },
|
{ url: "banana.html", title: "Exempli Gratia Pagina Musa", text: "Banana" },
|
||||||
{ url: "cherry.html", title: "Exempli Pagina Cerasus", text: "Cherry" },
|
{ url: "cherry.html", title: "Exempli Pagina Cerasus", text: "Cherry" },
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue