1
0

meta.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """Display the title of the current page."""
  2. from __future__ import annotations
  3. from reflex.components.base.bare import Bare
  4. from reflex.components.el import elements
  5. class Title(elements.Title):
  6. """A component that displays the title of the current page."""
  7. def render(self) -> dict:
  8. """Render the title component.
  9. Raises:
  10. ValueError: If the title is not a single string.
  11. Returns:
  12. The rendered title component.
  13. """
  14. # Make sure the title is a single string.
  15. if len(self.children) != 1 or not isinstance(self.children[0], Bare):
  16. raise ValueError("Title must be a single string.")
  17. return super().render()
  18. class Meta(elements.Meta):
  19. """A component that displays metadata for the current page."""
  20. # The description of character encoding.
  21. char_set: str | None = None
  22. # The value of meta.
  23. content: str | None = None
  24. # The name of metadata.
  25. name: str | None = None
  26. # The type of metadata value.
  27. property: str | None = None
  28. # The type of metadata value.
  29. http_equiv: str | None = None
  30. class Description(elements.Meta):
  31. """A component that displays the title of the current page."""
  32. # The type of the description.
  33. name: str | None = "description"
  34. class Image(elements.Meta):
  35. """A component that displays the title of the current page."""
  36. # The type of the image.
  37. property: str | None = "og:image"