File size: 1,538 Bytes
327a70d
 
0febb3e
327a70d
 
 
0febb3e
287969e
 
 
 
 
0febb3e
287969e
 
 
0febb3e
 
 
287969e
0febb3e
 
327a70d
0febb3e
327a70d
287969e
0febb3e
287969e
0febb3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
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:]

    # Split content by H1 headers
    sections = readme_content.split("\n# ")
    
    # Remove the first element as it's empty due to the initial split
    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()
    
    # Display links to separate pages for each section
    st.subheader("Blog Sections:")
    for section in sections:
        section_title, *section_content = section.split("\n")
        section_content = "\n".join(section_content)
        
        # Display links to separate pages with the section title as the link text
        st.markdown(f"- [{section_title.strip('#').strip()}](#{section_title.strip('#').strip().lower().replace(' ', '-')})")
        
        # Display the section content on the separate page
        st.write(f"## {section_title}")
        st.markdown(section_content, unsafe_allow_html=True)
        st.write("---")


if __name__ == "__main__":
    main()