Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds custom meta image config #1007

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/chainlit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
# Specify a custom font url.
# custom_font = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"

# Specify a custom meta image url.
# custom_meta_image_url = "https://chainlit-cloud.s3.eu-west-3.amazonaws.com/logo/chainlit_banner.png"

# Specify a custom build directory for the frontend.
# This can be used to customize the frontend code.
# Be careful: If this is a relative path, it should not start with a slash.
Expand Down Expand Up @@ -244,6 +247,9 @@ class UISettings(DataClassJsonMixin):
custom_css: Optional[str] = None
custom_js: Optional[str] = None
custom_font: Optional[str] = None
# Optional custom meta tag for image preview
custom_meta_image_url: Optional[str] = None
# Optional custom build directory for the frontend
custom_build: Optional[str] = None


Expand Down
4 changes: 3 additions & 1 deletion backend/chainlit/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,16 @@ def get_html_template():
CSS_PLACEHOLDER = "<!-- CSS INJECTION PLACEHOLDER -->"

default_url = "https://github.com/Chainlit/chainlit"
default_meta_image_url = "https://chainlit-cloud.s3.eu-west-3.amazonaws.com/logo/chainlit_banner.png"
url = config.ui.github or default_url
meta_image_url = config.ui.custom_meta_image_url or default_meta_image_url

tags = f"""<title>{config.ui.name}</title>
<meta name="description" content="{config.ui.description}">
<meta property="og:type" content="website">
<meta property="og:title" content="{config.ui.name}">
<meta property="og:description" content="{config.ui.description}">
<meta property="og:image" content="https://chainlit-cloud.s3.eu-west-3.amazonaws.com/logo/chainlit_banner.png">
<meta property="og:image" content="{meta_image_url}">
<meta property="og:url" content="{url}">"""

js = f"""<script>{f"window.theme = {json.dumps(config.ui.theme.to_dict())}; " if config.ui.theme else ""}</script>"""
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/state/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export interface IProjectSettings {
default_expand_messages?: boolean;
github?: string;
theme: any;
custom_css?: string;
custom_js?: string;
custom_font?: string;
custom_meta_image_url?: string;
};
features: {
spontaneous_file_upload?: {
Expand Down
Loading