Compare commits
No commits in common. "2b7a19a1d4a310dfc819ddff2d0c110793d8772d" and "3cfcae25a9150d6c99b1ebe168a7a1ff3e934f36" have entirely different histories.
2b7a19a1d4
...
3cfcae25a9
@ -4,8 +4,8 @@ use std::path::PathBuf;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::RenderBlogPostPage;
|
||||
use crate::types::GlobalSettings;
|
||||
use crate::types::RenderBlogPostPage;
|
||||
|
||||
use super::BlogPost;
|
||||
use super::BlogPostPage;
|
||||
@ -39,12 +39,7 @@ pub(crate) fn convert_blog_post_page_to_render_context<D: AsRef<Path>, F: AsRef<
|
||||
output_file.strip_prefix(output_directory)?,
|
||||
)?;
|
||||
|
||||
let ret = RenderBlogPostPage::new(
|
||||
global_settings,
|
||||
page.title.clone(),
|
||||
Some(link_to_blog_post),
|
||||
Vec::new(),
|
||||
);
|
||||
let ret = RenderBlogPostPage::new(global_settings, page.title.clone(), Some(link_to_blog_post));
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,11 @@ use walkdir::WalkDir;
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::BlogPostPage;
|
||||
use super::DocumentElement;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct BlogPost {
|
||||
pub(crate) id: String,
|
||||
pub(crate) pages: Vec<BlogPostPage>,
|
||||
pub(crate) children: Vec<DocumentElement>,
|
||||
}
|
||||
|
||||
impl BlogPost {
|
||||
@ -59,7 +57,6 @@ impl BlogPost {
|
||||
Ok(BlogPost {
|
||||
id: post_id.to_string_lossy().into_owned(),
|
||||
pages,
|
||||
children: Vec::new(),
|
||||
})
|
||||
}
|
||||
inner(root_dir.as_ref(), post_dir.as_ref()).await
|
||||
|
@ -1,8 +0,0 @@
|
||||
use super::Heading;
|
||||
use super::Section;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum DocumentElement {
|
||||
Heading(Heading),
|
||||
Section(Section),
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum Element {}
|
@ -1,10 +0,0 @@
|
||||
use crate::error::CustomError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Heading {}
|
||||
|
||||
impl Heading {
|
||||
pub(crate) fn new(heading: &organic::types::Heading<'_>) -> Result<Heading, CustomError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
@ -1,16 +1,6 @@
|
||||
mod convert;
|
||||
mod definition;
|
||||
mod document_element;
|
||||
mod element;
|
||||
mod heading;
|
||||
mod object;
|
||||
mod page;
|
||||
mod section;
|
||||
pub(crate) use convert::convert_blog_post_page_to_render_context;
|
||||
pub(crate) use definition::BlogPost;
|
||||
pub(crate) use document_element::DocumentElement;
|
||||
pub(crate) use element::Element;
|
||||
pub(crate) use heading::Heading;
|
||||
pub(crate) use object::Object;
|
||||
pub(crate) use page::BlogPostPage;
|
||||
pub(crate) use section::Section;
|
||||
|
@ -1,2 +0,0 @@
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum Object {}
|
@ -2,18 +2,12 @@ use std::path::PathBuf;
|
||||
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::DocumentElement;
|
||||
use super::Heading;
|
||||
use super::Section;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct BlogPostPage {
|
||||
/// Relative path from the root of the blog post.
|
||||
pub(crate) path: PathBuf,
|
||||
|
||||
pub(crate) title: Option<String>,
|
||||
|
||||
pub(crate) children: Vec<DocumentElement>,
|
||||
}
|
||||
|
||||
impl BlogPostPage {
|
||||
@ -22,18 +16,9 @@ impl BlogPostPage {
|
||||
document: organic::types::Document<'_>,
|
||||
) -> Result<BlogPostPage, CustomError> {
|
||||
let path = path.into();
|
||||
let mut children = Vec::new();
|
||||
if let Some(section) = document.zeroth_section.as_ref() {
|
||||
children.push(DocumentElement::Section(Section::new(section)?));
|
||||
}
|
||||
for heading in document.children.iter() {
|
||||
children.push(DocumentElement::Heading(Heading::new(heading)?));
|
||||
}
|
||||
|
||||
Ok(BlogPostPage {
|
||||
path,
|
||||
title: get_title(&document),
|
||||
children,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
use crate::error::CustomError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Section {}
|
||||
|
||||
impl Section {
|
||||
pub(crate) fn new(section: &organic::types::Section<'_>) -> Result<Section, CustomError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
use serde::Serialize;
|
||||
|
||||
use super::RenderHeading;
|
||||
use super::RenderSection;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum RenderDocumentElement {
|
||||
Heading(RenderHeading),
|
||||
Section(RenderSection),
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum RenderElement {}
|
@ -1,10 +0,0 @@
|
||||
use serde::Serialize;
|
||||
|
||||
use super::RenderObject;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "heading")]
|
||||
pub(crate) struct RenderHeading {
|
||||
title: Vec<RenderObject>,
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
mod blog_post_page;
|
||||
mod document_element;
|
||||
mod element;
|
||||
mod global_settings;
|
||||
mod heading;
|
||||
mod object;
|
||||
mod section;
|
||||
|
||||
pub(crate) use blog_post_page::RenderBlogPostPage;
|
||||
pub(crate) use document_element::RenderDocumentElement;
|
||||
pub(crate) use element::RenderElement;
|
||||
pub(crate) use global_settings::GlobalSettings;
|
||||
pub(crate) use heading::RenderHeading;
|
||||
pub(crate) use object::RenderObject;
|
||||
pub(crate) use section::RenderSection;
|
@ -1,5 +0,0 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum RenderObject {}
|
@ -1,23 +0,0 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::blog_post::Section;
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "section")]
|
||||
pub(crate) struct RenderSection {}
|
||||
|
||||
impl RenderSection {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
section: &Section,
|
||||
) -> Result<RenderSection, CustomError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ mod command;
|
||||
mod config;
|
||||
mod error;
|
||||
mod render;
|
||||
mod context;
|
||||
mod types;
|
||||
|
||||
fn main() -> Result<ExitCode, CustomError> {
|
||||
let rt = tokio::runtime::Runtime::new()?;
|
||||
|
@ -1,7 +1,6 @@
|
||||
use serde::Serialize;
|
||||
|
||||
use super::GlobalSettings;
|
||||
use super::RenderDocumentElement;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
@ -13,8 +12,6 @@ pub(crate) struct RenderBlogPostPage {
|
||||
title: Option<String>,
|
||||
|
||||
self_link: Option<String>,
|
||||
|
||||
children: Vec<RenderDocumentElement>,
|
||||
}
|
||||
|
||||
impl RenderBlogPostPage {
|
||||
@ -22,13 +19,11 @@ impl RenderBlogPostPage {
|
||||
global_settings: GlobalSettings,
|
||||
title: Option<String>,
|
||||
self_link: Option<String>,
|
||||
children: Vec<RenderDocumentElement>,
|
||||
) -> RenderBlogPostPage {
|
||||
RenderBlogPostPage {
|
||||
global_settings,
|
||||
title,
|
||||
self_link,
|
||||
children,
|
||||
}
|
||||
}
|
||||
}
|
5
src/types/mod.rs
Normal file
5
src/types/mod.rs
Normal file
@ -0,0 +1,5 @@
|
||||
mod blog_post_page;
|
||||
mod global_settings;
|
||||
|
||||
pub(crate) use blog_post_page::RenderBlogPostPage;
|
||||
pub(crate) use global_settings::GlobalSettings;
|
Loading…
x
Reference in New Issue
Block a user