add support for pre-publication posts

Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-05-05 14:58:23 +00:00
parent a257536b58
commit cd1ce7785a
3 changed files with 19 additions and 4 deletions

View File

@ -1,5 +1,6 @@
use crate::{post::Post, signalboost::Person};
use color_eyre::eyre::Result;
use chrono::prelude::*;
use serde::Deserialize;
use std::{
fs,
@ -91,8 +92,13 @@ pub async fn init(cfg: PathBuf) -> Result<State> {
everything.sort();
everything.reverse();
let everything: Vec<Post> = everything.into_iter().take(5).collect();
let today = Utc::today();
let everything: Vec<Post> = everything
.into_iter()
.filter(|p| today.num_days_from_ce() >= p.date.num_days_from_ce())
.take(5)
.collect();
let mut jfb = jsonfeed::Feed::builder()
.title("Xe's Blog")
.description("My blog posts and rants about various technology things.")

View File

@ -1,5 +1,6 @@
@use crate::post::Post;
@use super::{header_html, footer_html};
@use chrono::prelude::*;
@(posts: Vec<Post>)
@ -13,8 +14,8 @@
<p>
<ul>
@for post in posts {
<li>@post.date.format("%Y-%m-%d") - <a href="/@post.link">@post.front_matter.title</a></li>
@for post in posts.iter().filter(|p| Utc::today().num_days_from_ce() >= p.date.num_days_from_ce()) {
<li>@post.detri() - <a href="/@post.link">@post.front_matter.title</a></li>
}
</ul>
</p>

View File

@ -1,5 +1,6 @@
@use super::{header_html, footer_html};
@use crate::post::Post;
@use chrono::prelude::*;
@(post: Post, body: impl ToHtml)
@ -62,6 +63,13 @@
<h1>@post.front_matter.title</h1>
@if Utc::today().num_days_from_ce() < post.date.num_days_from_ce() {
<div class="warning">
<xeblog-conv name="Mara" mood="hacker">Hey, this post is set to go live to the public on @post.detri(). Right now you are reading a pre-publication version of this post. Please do not share this on social media. This post will automatically go live for everyone on the intended publication date. If you want access to these posts, please join the <a href="https://patreon.com/cadey">Patreon</a>. It helps me afford the copyeditor that I contract for the technical content I write.
</xeblog-conv>
</div>
}
<small>A @post.read_time_estimate_minutes minute read.</small>
@body