Initial structure for rendering a blog post stream.

This commit is contained in:
Tom Alexander 2023-12-17 15:23:40 -05:00
parent 60555999db
commit e8ed4a4f4a
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 61 additions and 0 deletions

View File

@ -89,6 +89,19 @@ impl SiteRenderer {
Ok(())
}
pub(crate) async fn render_blog_stream(&self, config: &Config) -> Result<(), CustomError> {
// TODO: Actually render a blog stream to index.html
// Steps: sort blog posts by date, newest first
//
// Steps: group blog posts based on # of posts per page
//
// Steps: for each group, create a RenderBlogStream
//
// Steps: pass each RenderBlogStream to dust as the context to render index.html and any additional stream pages.
Ok(())
}
pub(crate) async fn render_stylesheets(&self) -> Result<(), CustomError> {
let stylesheet_output_directory = self.output_directory.join("stylesheet");
if !stylesheet_output_directory.exists() {

View File

@ -23,6 +23,7 @@ pub(crate) async fn build_site(args: BuildArgs) -> Result<(), CustomError> {
stylesheets,
);
renderer.render_blog_posts(&config).await?;
renderer.render_blog_stream(&config).await?;
renderer.render_stylesheets().await?;
Ok(())

View File

@ -0,0 +1,46 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::context::RenderDocumentElement;
use crate::context::RenderRealFootnoteDefinition;
use crate::error::CustomError;
use crate::intermediate::BlogPost;
use super::GlobalSettings;
use super::PageHeader;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "blog_stream")]
pub(crate) struct RenderBlogStream {
global_settings: GlobalSettings,
page_header: Option<PageHeader>,
children: Vec<RenderBlogStreamEntry>,
older_link: Option<String>,
newer_link: Option<String>,
}
impl RenderBlogStream {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &Vec<BlogPost>,
) -> Result<RenderBlogStream, CustomError> {
todo!()
}
}
#[derive(Debug, Serialize)]
pub(crate) struct RenderBlogStreamEntry {
/// The title that will be shown visibly on the page.
title: Option<String>,
self_link: Option<String>,
children: Vec<RenderDocumentElement>,
footnotes: Vec<RenderRealFootnoteDefinition>,
}

View File

@ -2,6 +2,7 @@ mod angle_link;
mod ast_node;
mod babel_call;
mod blog_post_page;
mod blog_stream;
mod bold;
mod center_block;
mod citation;