File size: 1,257 Bytes
327a70d
 
 
 
 
287969e
 
 
 
 
 
 
 
 
 
 
327a70d
 
287969e
 
 
 
 
327a70d
 
 
287969e
 
 
 
 
 
 
 
 
 
 
 
 
 
327a70d
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import streamlit as st

def read_readme():
    with open("README.md", "r") as f:
        readme_content = f.read()
    
    # Find the start and end of the block to remove
    start_marker = "---\n"
    end_marker = "\n---"
    start_index = readme_content.find(start_marker)
    end_index = readme_content.find(end_marker) + len(end_marker)
    
    # Remove the block if found
    if start_index != -1 and end_index != -1:
        readme_content = readme_content[:start_index] + readme_content[end_index:]
    
    return readme_content

def create_pages(content):
    pages = content.split("# ")
    # Remove the first element as it contains the intro
    intro = pages.pop(0)
    return intro, pages

def main():
    readme_content = read_readme()
    intro, pages = create_pages(readme_content)

    st.title("Welcome to My Blog")
    st.markdown(intro)

    st.sidebar.title("Sections")
    for index, page in enumerate(pages):
        page_title = page.split("\n", 1)[0]
        st.sidebar.markdown(f"[{page_title}](#{index})")

    for index, page in enumerate(pages):
        st.markdown(f"## {page}")
        st.markdown(page, unsafe_allow_html=True)
        st.sidebar.markdown(f"[Back to Top](#{index})")


if __name__ == "__main__":
    main()