aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2021-04-18 10:17:04 -0400
committerChristine Dodrill <me@christine.website>2021-04-18 10:17:04 -0400
commit4dde8b26b8be9d9c11bb3920c942ecd6624e419e (patch)
tree69c6f4a99e5800577d9e6f0f164bfba5e1d572be /src
parent43b37834ddd93cfea97856a1769438beb0a62d97 (diff)
downloadxesite-4dde8b26b8be9d9c11bb3920c942ecd6624e419e.tar.xz
xesite-4dde8b26b8be9d9c11bb3920c942ecd6624e419e.zip
backpost a bunch of other articles, make linkposts work properly
Diffstat (limited to 'src')
-rw-r--r--src/post/mod.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/post/mod.rs b/src/post/mod.rs
index b5303a8..2b1b7e2 100644
--- a/src/post/mod.rs
+++ b/src/post/mod.rs
@@ -20,8 +20,8 @@ impl Into<jsonfeed::Item> for Post {
let mut result = jsonfeed::Item::builder()
.title(self.front_matter.title)
.content_html(self.body_html)
- .id(format!("https://christine.website/{}", self.link))
- .url(format!("https://christine.website/{}", self.link))
+ .id(self.link.clone())
+ .url(self.link)
.date_published(self.date.to_rfc3339())
.author(
jsonfeed::Author::new()
@@ -30,6 +30,10 @@ impl Into<jsonfeed::Item> for Post {
.avatar("https://christine.website/static/img/avatar.png"),
);
+ if let Some(url) = self.front_matter.redirect_to {
+ result = result.url(url);
+ }
+
let mut tags: Vec<String> = vec![];
if let Some(series) = self.front_matter.series {
@@ -79,7 +83,16 @@ async fn read_post(dir: &str, fname: PathBuf) -> Result<Post> {
let body = &body[content_offset..];
let date = NaiveDate::parse_from_str(&front_matter.clone().date, "%Y-%m-%d")
.map_err(|why| eyre!("error parsing date in {:?}: {}", fname, why))?;
- let link = format!("{}/{}", dir, fname.file_stem().unwrap().to_str().unwrap());
+
+ let link = match front_matter.redirect_to {
+ Some(ref url) => url.clone(),
+ None => format!(
+ "https://christine.website/{}/{}",
+ dir,
+ fname.file_stem().unwrap().to_str().unwrap()
+ ),
+ };
+
let body_html = crate::app::markdown::render(&body)
.wrap_err_with(|| format!("can't parse markdown for {:?}", fname))?;
let date: DateTime<FixedOffset> =