Fix the links to the blog posts.

This commit is contained in:
Tom Alexander 2023-12-19 16:46:32 -05:00
parent add267d616
commit 261fe8a1a2
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
5 changed files with 14 additions and 7 deletions

View File

@ -1,6 +1,6 @@
<div class="blog_post">
<div class="blog_post_intro">
{?.title}{?.self_link}<a class="blog_post_title" href="{.link}">{.title}</a>{:else}<div class="blog_post_title">{.title}</div>{/.self_link}{/.title}
{?.title}{?.self_link}<a class="blog_post_title" href="{.self_link}">{.title}</a>{:else}<div class="blog_post_title">{.title}</div>{/.self_link}{/.title}
{! TODO: date? !}
</div>

View File

@ -2,7 +2,7 @@
{#.children}
<div class="blog_stream_post">
<div class="blog_post_intro">
{?.title}{?.self_link}<a class="blog_post_title" href="{.link}">{.title}</a>{:else}<div class="blog_post_title">{.title}</div>{/.self_link}{/.title}
{?.title}{?.self_link}<a class="blog_post_title" href="{.self_link}">{.title}</a>{:else}<div class="blog_post_title">{.title}</div>{/.self_link}{/.title}
{! TODO: date? !}
</div>

View File

@ -77,8 +77,7 @@ impl SiteRenderer {
for blog_post_page in &blog_post.pages {
let output_path = self
.output_directory
.join("posts")
.join(&blog_post.id)
.join(config.get_relative_path_to_post(&blog_post.id))
.join(blog_post_page.get_output_path());
let convert_input = RenderBlogPostPageInput::new(blog_post, blog_post_page);

View File

@ -57,6 +57,15 @@ impl Config {
self.get_root_directory().join("posts")
}
/// Get the relative path to the folder containing a blog post.
///
/// This could be appended to the output root directory to get the
/// blog post output folder or it could be used to generate a link
/// to the blog post.
pub(crate) fn get_relative_path_to_post<P: AsRef<Path>>(&self, post_id: P) -> PathBuf {
Path::new("posts").join(post_id)
}
pub(crate) fn get_output_directory(&self) -> PathBuf {
self.get_root_directory().join("output")
}

View File

@ -120,14 +120,13 @@ pub(crate) struct RenderBlogStreamEntry {
}
render!(RenderBlogStreamEntry, BlogPost, original, render_context, {
// TODO: This link is probably wrong.
let link_to_blog_post = get_web_path(
render_context.config,
render_context.output_directory,
render_context.output_file,
render_context
.output_file
.strip_prefix(render_context.output_directory)?,
.config
.get_relative_path_to_post(&original.id),
)?;
// TODO: Should I guess an index page instead of erroring out?