add support for pre-publication posts
Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
parent
a257536b58
commit
cd1ce7785a
|
@ -1,5 +1,6 @@
|
||||||
use crate::{post::Post, signalboost::Person};
|
use crate::{post::Post, signalboost::Person};
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
|
use chrono::prelude::*;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs,
|
||||||
|
@ -91,8 +92,13 @@ pub async fn init(cfg: PathBuf) -> Result<State> {
|
||||||
everything.sort();
|
everything.sort();
|
||||||
everything.reverse();
|
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()
|
let mut jfb = jsonfeed::Feed::builder()
|
||||||
.title("Xe's Blog")
|
.title("Xe's Blog")
|
||||||
.description("My blog posts and rants about various technology things.")
|
.description("My blog posts and rants about various technology things.")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
@use crate::post::Post;
|
@use crate::post::Post;
|
||||||
@use super::{header_html, footer_html};
|
@use super::{header_html, footer_html};
|
||||||
|
@use chrono::prelude::*;
|
||||||
|
|
||||||
@(posts: Vec<Post>)
|
@(posts: Vec<Post>)
|
||||||
|
|
||||||
|
@ -13,8 +14,8 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<ul>
|
<ul>
|
||||||
@for post in posts {
|
@for post in posts.iter().filter(|p| Utc::today().num_days_from_ce() >= p.date.num_days_from_ce()) {
|
||||||
<li>@post.date.format("%Y-%m-%d") - <a href="/@post.link">@post.front_matter.title</a></li>
|
<li>@post.detri() - <a href="/@post.link">@post.front_matter.title</a></li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
@use super::{header_html, footer_html};
|
@use super::{header_html, footer_html};
|
||||||
@use crate::post::Post;
|
@use crate::post::Post;
|
||||||
|
@use chrono::prelude::*;
|
||||||
|
|
||||||
@(post: Post, body: impl ToHtml)
|
@(post: Post, body: impl ToHtml)
|
||||||
|
|
||||||
|
@ -62,6 +63,13 @@
|
||||||
|
|
||||||
<h1>@post.front_matter.title</h1>
|
<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>
|
<small>A @post.read_time_estimate_minutes minute read.</small>
|
||||||
|
|
||||||
@body
|
@body
|
||||||
|
|
Loading…
Reference in New Issue