Update modules/ui/ui.py
Browse files- modules/ui/ui.py +11 -19
modules/ui/ui.py
CHANGED
|
@@ -5,6 +5,8 @@ import sys
|
|
| 5 |
import os
|
| 6 |
import streamlit as st
|
| 7 |
|
|
|
|
|
|
|
| 8 |
# 1. Define the JavaScript logic that builds and appends meta tags to the <head>
|
| 9 |
JS_META_INJECTOR = """
|
| 10 |
export default function(component) {
|
|
@@ -32,19 +34,12 @@ export default function(component) {
|
|
| 32 |
head.appendChild(meta);
|
| 33 |
};
|
| 34 |
|
| 35 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
setMetaTag('og:type', 'website');
|
| 37 |
-
setMetaTag('og:title', data.title);
|
| 38 |
-
setMetaTag('og:description', data.description);
|
| 39 |
-
setMetaTag('og:url', data.url);
|
| 40 |
-
|
| 41 |
-
// CRITICAL: Explicitly set the base image tag
|
| 42 |
-
setMetaTag('og:image', data.image);
|
| 43 |
-
|
| 44 |
-
// Optional structural helpers to assist lazy scrapers:
|
| 45 |
-
if (data.image_type) setMetaTag('og:image:type', data.image_type);
|
| 46 |
-
if (data.image_width) setMetaTag('og:image:width', data.image_width);
|
| 47 |
-
if (data.image_height) setMetaTag('og:image:height', data.image_height);
|
| 48 |
|
| 49 |
// Inject Twitter Card tags
|
| 50 |
if (data.title) setMetaTag('twitter:title', data.title);
|
|
@@ -63,23 +58,20 @@ meta_component = st.components.v2.component(
|
|
| 63 |
|
| 64 |
# 3. Use standard page configuration for the browser tab title & favicon
|
| 65 |
st.set_page_config(
|
| 66 |
-
page_title="
|
| 67 |
page_icon="🚀"
|
| 68 |
)
|
| 69 |
|
| 70 |
# 4. Invoke your custom meta component with the layout data
|
| 71 |
meta_component(data={
|
| 72 |
-
"title": "
|
| 73 |
-
"description": "
|
| 74 |
-
"url": "https://app.aideatext.ai",
|
| 75 |
-
|
| 76 |
-
# MUST BE AN ABSOLUTE SECURE URL
|
| 77 |
"image": "https://huggingface.co/spaces/AIdeaText/v5Prod/resolve/main/assets/img/socialmedia/AIdeaText_sm_cover.png",
|
| 78 |
-
|
| 79 |
# Providing these helps the Facebook Debugger pre-size the card safely
|
| 80 |
"image_type": "image/png",
|
| 81 |
"image_width": "1200",
|
| 82 |
"image_height": "630"
|
|
|
|
| 83 |
})
|
| 84 |
|
| 85 |
##########################################
|
|
|
|
| 5 |
import os
|
| 6 |
import streamlit as st
|
| 7 |
|
| 8 |
+
import streamlit as st
|
| 9 |
+
|
| 10 |
# 1. Define the JavaScript logic that builds and appends meta tags to the <head>
|
| 11 |
JS_META_INJECTOR = """
|
| 12 |
export default function(component) {
|
|
|
|
| 34 |
head.appendChild(meta);
|
| 35 |
};
|
| 36 |
|
| 37 |
+
// Inject Open Graph (Facebook/LinkedIn) tags
|
| 38 |
+
if (data.title) setMetaTag('og:title', data.title);
|
| 39 |
+
if (data.description) setMetaTag('og:description', data.description);
|
| 40 |
+
if (data.image) setMetaTag('og:image', data.image);
|
| 41 |
+
if (data.url) setMetaTag('og:url', data.url);
|
| 42 |
setMetaTag('og:type', 'website');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
// Inject Twitter Card tags
|
| 45 |
if (data.title) setMetaTag('twitter:title', data.title);
|
|
|
|
| 58 |
|
| 59 |
# 3. Use standard page configuration for the browser tab title & favicon
|
| 60 |
st.set_page_config(
|
| 61 |
+
page_title="My Awesome Streamlit App",
|
| 62 |
page_icon="🚀"
|
| 63 |
)
|
| 64 |
|
| 65 |
# 4. Invoke your custom meta component with the layout data
|
| 66 |
meta_component(data={
|
| 67 |
+
"title": "My Awesome Streamlit App",
|
| 68 |
+
"description": "This is a supercharged data app built using Streamlit and Components V2.",
|
|
|
|
|
|
|
|
|
|
| 69 |
"image": "https://huggingface.co/spaces/AIdeaText/v5Prod/resolve/main/assets/img/socialmedia/AIdeaText_sm_cover.png",
|
|
|
|
| 70 |
# Providing these helps the Facebook Debugger pre-size the card safely
|
| 71 |
"image_type": "image/png",
|
| 72 |
"image_width": "1200",
|
| 73 |
"image_height": "630"
|
| 74 |
+
"url": "https://app.aideatext.ai"
|
| 75 |
})
|
| 76 |
|
| 77 |
##########################################
|