Skip to content

Commit 415fac6

Browse files
committed
Remove name disambiguator from post urls
1 parent 039e3a6 commit 415fac6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/posts.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@ pub struct Post {
3131
impl Post {
3232
pub(crate) fn open(path: &Path, manifest: &Manifest) -> eyre::Result<Self> {
3333
// yeah this might blow up, but it won't
34-
let filename = path.file_name().unwrap().to_str().unwrap().into();
34+
let filename = {
35+
let filename = path.file_name().unwrap().to_str().unwrap().to_string();
36+
// '@' is used as a disambiguator between file names that were
37+
// previously identical except for the date prefix (which was
38+
// removed). The URL doesn't need the disambiguator, because it has
39+
// the date in it. Also, we must remove it to preserve permalinks.
40+
match filename.split_once('@') {
41+
Some((pre, _)) => format!("{pre}.md"),
42+
None => filename,
43+
}
44+
};
3545

3646
let contents = std::fs::read_to_string(path)?;
3747

0 commit comments

Comments
 (0)