Generate newer and older links.

This commit is contained in:
Tom Alexander 2023-12-17 17:16:26 -05:00
parent c3482cf1e4
commit 2ba4a5e3d7
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 39 additions and 4 deletions

View File

@ -7,6 +7,7 @@ use include_dir::Dir;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::convert_blog_post_page_to_render_context;
use crate::intermediate::get_web_path;
use crate::intermediate::BlogPost;
use crate::render::DusterRenderer;
use crate::render::RendererIntegration;
@ -122,8 +123,41 @@ impl SiteRenderer {
// For each group, create a RenderBlogStream.
let num_stream_pages = stream_chunks.len();
for chunk in stream_chunks {
// foo
for (page_num, chunk) in stream_chunks.into_iter().enumerate() {
let output_file = if page_num == 0 {
self.output_directory.join("index.html")
} else {
self.output_directory
.join("stream")
.join(format!("{}.html", page_num))
};
let newer_link = if page_num == 0 {
None
} else if page_num == 1 {
Some(get_web_path(
config,
&self.output_directory,
&output_file,
"index.html",
)?)
} else {
Some(get_web_path(
config,
&self.output_directory,
&output_file,
format!("stream/{}.html", page_num - 1),
)?)
};
let older_link = if page_num == (num_stream_pages - 1) {
None
} else {
Some(get_web_path(
config,
&self.output_directory,
&output_file,
format!("stream/{}.html", page_num + 1),
)?)
};
}
Ok(())
}

View File

@ -27,7 +27,7 @@ impl RenderBlogStream {
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &Vec<BlogPost>,
original: &[&BlogPost],
) -> Result<RenderBlogStream, CustomError> {
todo!()
}

View File

@ -90,7 +90,7 @@ pub(crate) fn convert_blog_post_page_to_render_context<D: AsRef<Path>, F: AsRef<
Ok(ret)
}
fn get_web_path<D: AsRef<Path>, F: AsRef<Path>, P: AsRef<Path>>(
pub(crate) fn get_web_path<D: AsRef<Path>, F: AsRef<Path>, P: AsRef<Path>>(
config: &Config,
output_directory: D,
containing_file: F,

View File

@ -77,6 +77,7 @@ pub(crate) use code::ICode;
pub(crate) use comment::IComment;
pub(crate) use comment_block::ICommentBlock;
pub(crate) use convert::convert_blog_post_page_to_render_context;
pub(crate) use convert::get_web_path;
pub(crate) use diary_sexp::IDiarySexp;
pub(crate) use document_element::IDocumentElement;
pub(crate) use drawer::IDrawer;