diff --git a/main.py b/main.py index b561688c17..e00fc8d152 100755 --- a/main.py +++ b/main.py @@ -8,6 +8,7 @@ from nicegui import app, ui from nicegui.page_arguments import RouteMatch from website import documentation, fly, header, imprint_privacy, main_page, rate_limits, svg +from website.seo_constants import NICEGUI_TAGLINE # session middleware is required for demo in documentation app.add_middleware(SessionMiddleware, secret_key=os.environ.get('NICEGUI_SECRET_KEY', '')) @@ -99,4 +100,4 @@ def _status(): # NOTE: do not reload on fly.io (see https://github.com/zauberzeug/nicegui/discussions/1720#discussioncomment-7288741) -ui.run(uvicorn_reload_includes='*.py, *.css, *.html', reload=not on_fly, reconnect_timeout=10.0) +ui.run(uvicorn_reload_includes='*.py, *.css, *.html', reload=not on_fly, reconnect_timeout=10.0, title=NICEGUI_TAGLINE) diff --git a/website/documentation/rendering.py b/website/documentation/rendering.py index 4820704d99..726b394790 100644 --- a/website/documentation/rendering.py +++ b/website/documentation/rendering.py @@ -1,16 +1,40 @@ from nicegui import ui +from ..seo_constants import NICEGUI_TAGLINE from ..style import section_heading, subheading from .content import DocumentationPage +from .content.overview import tiles from .custom_restructured_text import CustomRestructuredText as custom_restructured_text from .demo import demo from .reference import generate_class_doc +TILES_DICT = {a.__name__.rpartition('.')[-1]: b for a, b in tiles} + + +def _drop_after_params(text: str) -> str: + """Drop everything after the first occurrence of ':param' in the given text.""" + param_index = text.find(':param') + return text[:param_index] if param_index != -1 else text + def render_page(documentation: DocumentationPage) -> None: """Render the documentation.""" + description = NICEGUI_TAGLINE + print(documentation.name) + print(TILES_DICT) + if documentation.name in TILES_DICT: + description = TILES_DICT[documentation.name] + elif documentation.parts and documentation.parts[0].description: + description = _drop_after_params(documentation.parts[0].description) + else: + description = NICEGUI_TAGLINE + + if not ui.context.client.has_socket_connection: + ui.add_head_html(f''' + + ''') title = (documentation.title or '').replace('*', '') - ui.page_title('NiceGUI' if not title else title if title.split()[0] == 'NiceGUI' else f'{title} | NiceGUI') + ui.page_title(NICEGUI_TAGLINE if not title else title if title.split()[0] == 'NiceGUI' else f'{title} | NiceGUI') def render_content(): section_heading(documentation.subtitle or '', documentation.heading) diff --git a/website/header.py b/website/header.py index 97ff91e08c..aa59b7d2d1 100644 --- a/website/header.py +++ b/website/header.py @@ -2,6 +2,7 @@ from pathlib import Path from nicegui import app, ui +from website.seo_constants import KEYWORDS from . import svg from .search import Search @@ -19,6 +20,10 @@ def add_head_html() -> None: '' ) + ui.add_head_html(f''' + + + ''') def add_header(menu: ui.left_drawer) -> ui.button: diff --git a/website/imprint_privacy.py b/website/imprint_privacy.py index 5f4df69382..30cf4987ff 100644 --- a/website/imprint_privacy.py +++ b/website/imprint_privacy.py @@ -1,9 +1,13 @@ from nicegui import ui from website.documentation.rendering import section_heading, subheading +from website.seo_constants import NICEGUI_TAGLINE def create(): ui.page_title('Imprint & Privacy | NiceGUI') + ui.add_head_html(f''' + + ''') with ui.column().classes('w-full p-8 lg:p-16 max-w-[1250px] mx-auto'): section_heading('', 'Imprint') diff --git a/website/main_page.py b/website/main_page.py index c9ef2a631c..71a018b9a9 100644 --- a/website/main_page.py +++ b/website/main_page.py @@ -12,6 +12,10 @@ def create() -> None: """Create the content of the main page.""" + ui.add_head_html(''' + + ''') + with ui.row().classes('w-full h-screen items-center gap-8 pr-4 no-wrap into-section'): svg.face(half=True).classes('stroke-black dark:stroke-white w-[200px] md:w-[230px] lg:w-[300px]') with ui.column().classes('gap-4 md:gap-8 pt-32'): diff --git a/website/seo_constants.py b/website/seo_constants.py new file mode 100644 index 0000000000..dfa7826558 --- /dev/null +++ b/website/seo_constants.py @@ -0,0 +1,5 @@ +NICEGUI_TAGLINE = 'NiceGUI - The Full-Stack Python GUI Framework for the Web' # 50 - 60 characters. This is 57. + +# First 5 are from PyPI. The rest from GitHub Copilot +KEYWORDS = ['GUI', 'UI', 'Web', 'Interface', 'Live', 'Python', 'Framework', 'Dashboard', 'App', + 'Application', 'Tool', 'Library', 'Frontend', 'Backend', 'Full-Stack', 'Components', 'Widgets', 'Open Source'] diff --git a/website/static/header.html b/website/static/header.html index 81368add9d..1bf8716b6c 100644 --- a/website/static/header.html +++ b/website/static/header.html @@ -1,8 +1,3 @@ - -