Skip to content

Commit

Permalink
add "how to blog" blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
alifeee committed Jan 17, 2025
1 parent c896317 commit d481759
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
8 changes: 8 additions & 0 deletions feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
<summary>What did people make and what did I learn?</summary>
</entry>

<entry>
<title>How to create a blog (gist)</title>
<link href='https://blog.alifeee.co.uk/https://gist.github.com/alifeee/c857bfb45bfd260a9b9dd9c45e4f7478' />
<id>https://blog.alifeee.co.uk//https://gist.github.com/alifeee/c857bfb45bfd260a9b9dd9c45e4f7478</id>
<updated>2024-01-17T00:00:00+00:00</updated>
<summary>How to create a blog (gist)</summary>
</entry>

<entry>
<title>Making my own Font - BogFace</title>
<link href='https://blog.alifeee.co.uk/making-bogface' />
Expand Down
Binary file added images/hat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,28 @@ <h2 class="title">I ran a computer font-making workshop!</h2>
</hgroup>
</a>
</li>
<li class="post">
<a
href="https://gist.github.com/alifeee/c857bfb45bfd260a9b9dd9c45e4f7478"
class="link"
>
<div class="preview-image">
<img
src="./images/hat.png"
alt="picture of a hat"
height="450"
width="450"
/>
</div>
<hgroup class="info">
<h2 class="title">How to create a blog (gist)</h2>
<p class="date">
<time datetime="2024-01-17">2024-01-17</time>
</p>
<ul class="categories"></ul>
</hgroup>
</a>
</li>
<li class="post">
<a href="./making-bogface" class="link">
<div class="preview-image">
Expand Down
18 changes: 9 additions & 9 deletions utilities.py/post_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ def get_all_posts() -> List[Post]:
date = date.replace(tzinfo=ZoneInfo("Etc/UTC"))

index_path = f"{relative_url}/index.html"
with open(index_path, "r", encoding="utf-8") as file:
post_soup = BeautifulSoup(file, "html.parser")
title = post_soup.find("meta", property="og:title")["content"]
description = post_soup.find("meta", property="og:description")["content"]
if os.path.exists(index_path):
with open(index_path, "r", encoding="utf-8") as file:
post_soup = BeautifulSoup(file, "html.parser")
title = post_soup.find("meta", property="og:title")["content"]
description = post_soup.find("meta", property="og:description")["content"]
else:
title = post.find("h2").get_text()
description = title

posts.append(
Post(
Expand All @@ -85,13 +89,9 @@ def get_all_posts() -> List[Post]:

# make sure all relative_url's exist
for post in posts:
assert os.path.exists(
assert post.relative_url.startswith("https") or os.path.exists(
post.relative_url
), f"post {post.relative_url} does not exist"
# make sure all md_url's exist
for post in posts:
if not os.path.exists(post.md_url):
print(f"warning: post {post.md_url} does not exist")

posts.sort(key=lambda x: x.date, reverse=True)
return posts
Expand Down

0 comments on commit d481759

Please sign in to comment.