def generate_archive(posts): print("Generating archive...") _ensure_dir(ARCHIVE_DIR_PATH) contents = populate_template(ARCHIVE_TEMPLATE_NAME, data={ "page_title": "Archive", "posts": posts }) write_file(ARCHIVE_PATH, contents=contents)
def generate_playlist_page(playlist_id): print("Generating playlist page...") _ensure_dir(PLAYLIST_DIR_PATH) contents = populate_template( PLAYLIST_TEMPLATE_NAME, data={ "page_title": "Playlist", "playlist_id": playlist_id, }, ) write_file(PLAYLIST_PATH, contents=contents)
def generate_pages(posts): print("Generating pages...") for post in posts: print(f"Generating page: post {post['date']}...") post_dir_path = ARCHIVE_DIR_PATH / post["date"] _ensure_dir(post_dir_path) post_page_path = post_dir_path / "index.html" contents = populate_template( PAGE_TEMPLATE_NAME, data={ "page_title": f"Archive: {post['date']}", "post": post }, ) write_file(post_page_path, contents=contents)
def generate_404(): print("Generating 404...") contents = populate_template(ERROR_404_TEMPLATE_NAME) write_file(ERROR_404_PATH, contents=contents)
def generate_homepage(posts): print("Generating homepage...") contents = populate_template(HOMEPAGE_TEMPLATE_NAME, data={"posts": posts[:HOMEPAGE_DATES]}) write_file(HOMEPAGE_PATH, contents=contents)