fix page title

This commit is contained in:
Khaleel Al-Adhami 2024-10-04 14:19:47 -07:00
parent 8085d7e203
commit 1df7c8ddf7

View File

@ -186,8 +186,8 @@ class UnevaluatedPage:
component: Union[Component, ComponentCallable] component: Union[Component, ComponentCallable]
route: str route: str
title: Union[Var, str] title: Union[Var, str, None]
description: Union[Var, str] description: Union[Var, str, None]
image: str image: str
on_load: Union[EventHandler, EventSpec, List[Union[EventHandler, EventSpec]], None] on_load: Union[EventHandler, EventSpec, List[Union[EventHandler, EventSpec]], None]
meta: List[Dict[str, str]] meta: List[Dict[str, str]]
@ -407,12 +407,11 @@ class App(MiddlewareMixin, LifespanMixin, Base):
def _add_optional_endpoints(self): def _add_optional_endpoints(self):
"""Add optional api endpoints (_upload).""" """Add optional api endpoints (_upload)."""
# To upload files.
self.api.post(str(constants.Endpoint.UPLOAD))(upload(self))
# To access uploaded files.
if Upload.is_used: if Upload.is_used:
# To upload files.
self.api.post(str(constants.Endpoint.UPLOAD))(upload(self))
# To access uploaded files.
self.api.mount( self.api.mount(
str(constants.Endpoint.UPLOAD), str(constants.Endpoint.UPLOAD),
StaticFiles(directory=get_upload_dir()), StaticFiles(directory=get_upload_dir()),
@ -536,10 +535,8 @@ class App(MiddlewareMixin, LifespanMixin, Base):
self.unevaluated_pages[route] = UnevaluatedPage( self.unevaluated_pages[route] = UnevaluatedPage(
component=component, component=component,
route=route, route=route,
title=title if title is not None else constants.DefaultPage.TITLE, title=title,
description=description description=description,
if description is not None
else constants.DefaultPage.DESCRIPTION,
image=image, image=image,
on_load=on_load, on_load=on_load,
meta=meta, meta=meta,
@ -551,6 +548,7 @@ class App(MiddlewareMixin, LifespanMixin, Base):
Args: Args:
route: The route of the page to compile. route: The route of the page to compile.
""" """
print(f"Compiling page: {route} {self.unevaluated_pages[route]}")
component, enable_state = compiler.compile_unevaluated_page( component, enable_state = compiler.compile_unevaluated_page(
route, self.unevaluated_pages[route], self.state route, self.unevaluated_pages[route], self.state
) )