Panic comments
This commit is contained in:
parent
3ea0b6290d
commit
f49105ef7f
@ -10,7 +10,7 @@ Configuration
|
||||
|
||||
### example: `config.yaml`
|
||||
```yaml
|
||||
output_dir: public/
|
||||
output_dir: public
|
||||
links:
|
||||
source: data/links/links.yaml
|
||||
template: templates/links/links.html
|
||||
@ -58,4 +58,4 @@ This is optional, but everything inside will be copied directly next to the `ind
|
||||
Debating on manually needing to specify a list of files in `config:` but not sold on that yet.
|
||||
|
||||
|
||||
## Blog - Coming Soon
|
||||
## Blog - Coming Soon
|
||||
|
@ -111,4 +111,4 @@ links:
|
||||
links:
|
||||
- text: Fork this project!
|
||||
icon: fa-solid fa-code-fork
|
||||
href: https://gitea.tyrel.dev/tyrel/rustylinks
|
||||
href: https://gitea.tyrel.dev/tyrel/rust-ssg
|
||||
|
@ -19,6 +19,9 @@ pub fn copy_recursively(source: impl AsRef<Path>, destination: impl AsRef<Path>)
|
||||
pub fn write_file(html: String) {
|
||||
// copy all files in static to public
|
||||
if Path::new("./public/links").exists() {
|
||||
// TODO: Move me into links wtf am i in here for
|
||||
// TODO: Handle Panic
|
||||
// thread 'main' panicked at 'Could not copy static directory: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/file_utils/mod.rs:22:56
|
||||
copy_recursively("./static", "./public/links").expect("Could not copy static directory");
|
||||
}
|
||||
fs::write("./public/links/index.html", html).expect("Could not write to index.html");
|
||||
|
@ -8,6 +8,8 @@ use std::path::PathBuf;
|
||||
use crate::file_utils::{write_file, copy_recursively};
|
||||
|
||||
fn load_links(config: &LinksConfig) -> RustyLinks {
|
||||
// TODO: Handle Panic
|
||||
// thread 'main' panicked at 'Could not find data/links/links.yaml: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/links/mod.rs:11:58
|
||||
let links_yaml = std::fs::File::open(&config.source).expect(&format!("Could not find {}", config.source));
|
||||
|
||||
let mut rusty_links: RustyLinks = serde_yaml::from_reader(links_yaml).expect("Could not read values");
|
||||
@ -21,6 +23,8 @@ fn load_links(config: &LinksConfig) -> RustyLinks {
|
||||
}
|
||||
|
||||
fn render_links(rusty_links: RustyLinks, config: &LinksConfig) -> String {
|
||||
// TODO: Handle Panic
|
||||
// thread 'main' panicked at 'Could not find templates/links/links.html: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/links/mod.rs:24:58
|
||||
let main = std::fs::read_to_string(&config.template).expect(&format!("Could not find {}", config.template));
|
||||
|
||||
let mut env = Environment::new();
|
||||
|
@ -44,6 +44,8 @@ fn main() {
|
||||
let blog_str = "blog";
|
||||
// let blog_dir = PathBuf::from(blog_str);
|
||||
|
||||
// TODO: Handle Panic:
|
||||
// thread 'main' panicked at 'Could not find config.yaml file: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:19:53
|
||||
let config: Config = load_config("./config.yaml");
|
||||
let output_dir = PathBuf::from(&config.output_dir);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user