File size: 850 Bytes
b73d72d |
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 |
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.")
|