| import os | |
| import streamlit as st | |
| from mongodb import get_post_titles, get_post_by_id | |
| post_titles = list(get_post_titles("public")) | |
| if post_titles: | |
| st.sidebar.subheader("Select a post to view:") | |
| # Display titles as clickable buttons in the sidebar | |
| selected_post = None | |
| for post in post_titles: | |
| if st.sidebar.button(post["title"]): | |
| # Get the content of the clicked post | |
| post_id = post["_id"] | |
| selected_post = get_post_by_id(post_id) | |
| # Display the content of the selected post | |
| st.subheader(selected_post["title"]) | |
| st.divider() | |
| st.markdown(selected_post["content"], unsafe_allow_html = True) # Render the content as Markdown | |
| # Provide options to update or delete the selected post | |
| else: | |
| st.sidebar.write("No posts available.") | |