Simplify review paths – just the slug, not the year
authorAlex Chan <alex@alexwlchan.net>
Sun, 2 Feb 2020 22:45:35 +0000 (22:45 +0000)
committerAlex Chan <alex@alexwlchan.net>
Sun, 2 Feb 2020 22:45:35 +0000 (22:45 +0000)
before: /reviews/2020/name-of-book
after:  /reviews/name-of-book

scripts/render_html.py

index d1d05b1..14bbd53 100755 (executable)
@@ -47,7 +47,8 @@ class ReviewEntry:
     review = attr.ib()
 
     def out_path(self):
-        return self.path.relative_to("src").with_suffix("")
+        name = self.path.with_suffix("").name
+        return pathlib.Path(f"reviews/{name}")
 
 
 def get_review_entry_from_path(path):
@@ -70,9 +71,6 @@ class CurrentlyReadingEntry:
     book = attr.ib()
     reading = attr.ib()
 
-    def out_path(self):
-        return self.path.relative_to("src").with_suffix("")
-
 
 def get_reading_entry_from_path(path):
     post = frontmatter.load(path)
@@ -94,9 +92,6 @@ class PlanEntry:
     book = attr.ib()
     plan = attr.ib()
 
-    def out_path(self):
-        return self.path.relative_to("src").with_suffix("")
-
 
 def get_plan_entry_from_path(path):
     post = frontmatter.load(path)