|
import streamlit as st |
|
|
|
|
|
def read_readme(): |
|
with open("README.md", "r") as f: |
|
readme_content = f.read() |
|
|
|
|
|
start_marker = "---\n" |
|
end_marker = "\n---" |
|
start_index = readme_content.find(start_marker) |
|
end_index = readme_content.find(end_marker) + len(end_marker) |
|
|
|
|
|
if start_index != -1 and end_index != -1: |
|
readme_content = readme_content[:start_index] + readme_content[end_index:] |
|
|
|
|
|
sections = readme_content.split("\n# ") |
|
|
|
|
|
sections = sections[1:] |
|
|
|
return sections |
|
|
|
|
|
def main(): |
|
st.title("Welcome to My Blog") |
|
st.write("This is my blog where I share various topics.") |
|
|
|
sections = read_readme() |
|
|
|
|
|
st.subheader("Blog Sections:") |
|
for section in sections: |
|
section_title, *section_content = section.split("\n") |
|
section_content = "\n".join(section_content) |
|
|
|
|
|
st.markdown(f"- [{section_title.strip('#').strip()}](#{section_title.strip('#').strip().lower().replace(' ', '-')})") |
|
|
|
|
|
st.write(f"## {section_title}") |
|
st.markdown(section_content, unsafe_allow_html=True) |
|
st.write("---") |
|
|
|
|
|
if __name__ == "__main__": |
|
main() |
|
|