Created
April 4, 2023 00:24
-
-
Save cobanov/9268371472234013a49ce25379c23ff8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rich.console import Console | |
from rich.markdown import Markdown | |
import glob | |
import os | |
def read_md(path): | |
with open(path, "r") as file: | |
content = file.read() | |
return Markdown(content) | |
def get_blog_paths(): | |
list_of_blogs = glob.glob(os.path.join("blogs", "*.md")) | |
blog_instance = [] | |
for idx, blog in enumerate(list_of_blogs): | |
relative_path = os.path.split(blog)[-1] | |
file_name = os.path.splitext(relative_path)[0].replace("-", " ").title() | |
print(file_name) | |
blog_instance.append( | |
{"idx": idx, "relative_path": relative_path, "file_name": file_name} | |
) | |
return blog_instance | |
def main(): | |
console = Console(width=64) | |
blog_paths = get_blog_paths() | |
for idx, path in blog_paths: | |
console.print(idx, path, justify="left") | |
print(get_blog_paths()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment