Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/add default title #604

Merged
merged 3 commits into from
Dec 22, 2024
Merged

Conversation

banditburai
Copy link
Contributor


name: Pull Request
about: Propose changes to the codebase
title: '[PR] '
labels: ''
assignees: ''


Related Issue
Currently, FastHTML uses a hardcoded "FastHTML page" title in the _xt_cts function. This makes it difficult for users to set their own default page titles across all pages of their app.

Proposed Changes
This PR adds the ability to set a custom default title for FastHTML pages and fixes title override behavior:

  • Adding title parameter to FastHTML class with default value "FastHTML page"
  • Updating _xt_cts to use app.title instead of hardcoded value
  • Fix _xt_cts to properly respect manually passed Title components

Types of changes
What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist
Go over all the following points, and put an x in all the boxes that apply:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I am aware that this is an nbdev project, and I have edited, cleaned, and synced the source notebooks instead of editing .py or .md files directly.

Usage Example

app = FastHTML(title="My Custom Title")

Additional Information
This change is backwards compatible - if no title is provided, it defaults to "FastHTML page" as before.

- Add title parameter to FastHTML class with default value

- Update _xt_cts to use app.title instead of hardcoded value
- Fix _xt_cts to respect manually passed Title components

- Add tests for default title

- Add tests for custom title

- Add tests for title override behavior
Copy link

gitnotebooks bot commented Dec 14, 2024

Found 1 changed notebook. Review the changes at https://app.gitnotebooks.com/AnswerDotAI/fasthtml/pull/604

@jamilraichouni
Copy link

Nice one. Found it difficult to find a way to rename an app and ended up with some workaround of a function
def application_shell() that returns a Title, Div tuple.

@jph00
Copy link
Contributor

jph00 commented Dec 22, 2024

Thanks!

@jph00 jph00 merged commit 971d401 into AnswerDotAI:main Dec 22, 2024
@jph00 jph00 added the enhancement New feature or request label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants