Fixed document vs fragment parsing
This commit is contained in:
parent
9a0038dacd
commit
f9b2e74b45
6 changed files with 113 additions and 14 deletions
|
|
@ -1,8 +1,8 @@
|
|||
use crate::helpers::read_doc_from_file;
|
||||
|
||||
use super::render::execute_lua;
|
||||
use super::render::expand_template;
|
||||
use anyhow::Result;
|
||||
use kuchikiki::traits::TendrilSink;
|
||||
use std::fs::read_to_string;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub fn serve_content(request_uri: &str) -> Result<String> {
|
||||
|
|
@ -13,9 +13,7 @@ pub fn serve_content(request_uri: &str) -> Result<String> {
|
|||
let safe_path = Path::new(request_uri).strip_prefix("/")?;
|
||||
let page_path = pages.join(safe_path);
|
||||
|
||||
let page_string = read_to_string(&page_path)?;
|
||||
|
||||
let doc = kuchikiki::parse_html().one(page_string);
|
||||
let doc = read_doc_from_file(page_path)?;
|
||||
|
||||
let full_doc = expand_template(doc, &components, None)?;
|
||||
let executed_doc = execute_lua(full_doc)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue