Skip to content

Commit

Permalink
fix compiler for description
Browse files Browse the repository at this point in the history
  • Loading branch information
Lendemor committed Mar 13, 2024
1 parent ad21c86 commit b95b2ef
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions reflex/compiler/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common utility functions used in the compiler."""

from __future__ import annotations

import os
Expand Down Expand Up @@ -404,27 +405,36 @@ def get_asset_path(filename: str | None = None) -> str:


def add_meta(
page: Component, title: str, image: str, description: str, meta: list[dict]
page: Component,
title: str,
image: str,
meta: list[dict],
description: str | None = None,
) -> Component:
"""Add metadata to a page.
Args:
page: The component for the page.
title: The title of the page.
image: The image for the page.
description: The description of the page.
meta: The metadata list.
description: The description of the page.
Returns:
The component with the metadata added.
"""
meta_tags = [Meta.create(**item) for item in meta]

children: list[Any] = [
Title.create(title),
]
if description:
children.append(Description.create(content=description))
children.append(Image.create(content=image))

page.children.append(
Head.create(
Title.create(title),
Description.create(content=description),
Image.create(content=image),
*children,
*meta_tags,
)
)
Expand Down

0 comments on commit b95b2ef

Please sign in to comment.