working import task
wip: not complete, got to fix some of markdown options
This commit is contained in:
@ -63,18 +63,20 @@ async fn import_posts(
|
||||
println!("Importing new file: {}", file_name_str);
|
||||
|
||||
// Process file contents
|
||||
let file_md_contents = process_read_file(&file_path, &options)?;
|
||||
let file_md_contents = process_read_file(&file_path)?;
|
||||
// println!("{:?}", file_md_contents);
|
||||
let content = markdown::to_html(&file_md_contents);
|
||||
// println!("{:?}", content);
|
||||
|
||||
// Extract metadata
|
||||
let metadata = crate::utils::front_matter::YamlFrontMatter::parse::<MarkdownMetadata>(
|
||||
let document = crate::utils::front_matter::YamlFrontMatter::parse::<MarkdownMetadata>(
|
||||
&file_md_contents,
|
||||
)?;
|
||||
// println!("{:?}", metadata);
|
||||
let title = metadata.metadata.title;
|
||||
let content_final = metadata.content;
|
||||
|
||||
let content =
|
||||
markdown::to_html_with_options(&document.content, &markdown::Options::default());
|
||||
println!("{:?}", content);
|
||||
|
||||
// println!("{:?}", document);
|
||||
let title = document.metadata.title;
|
||||
let content_final = content.unwrap();
|
||||
// println!("{:?}", title);
|
||||
|
||||
// Insert into database
|
||||
@ -101,10 +103,7 @@ async fn import_posts(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn process_read_file(
|
||||
file_path: &std::path::Path,
|
||||
options: &MarkdownOptions,
|
||||
) -> Result<String, std::io::Error> {
|
||||
fn process_read_file(file_path: &std::path::Path) -> Result<String, std::io::Error> {
|
||||
let mut file = std::fs::read_to_string(file_path)?;
|
||||
|
||||
Ok(file)
|
||||
|
Reference in New Issue
Block a user