meta.py 1.4 KB

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