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

chore: migrate the root template to .heex #2376

Merged
merged 8 commits into from
Mar 5, 2025
Merged

Conversation

thecristen
Copy link
Collaborator

No ticket, just tech debt—This'll make it easier to include function components on the homepage! ✨

Follow the commits one-by-one to see more legible diffs of what changed between each stage.

  • In Dotcom.BodyTag, I had to make an adjustment because HEEX doesn't like the <%= Dotcom.BodyTag.render(@conn) %> </body> format 😓
  • 🔥 I simplified the template logic for generating the <meta name="robots" content="noindex, nofollow"> tag because the current one was driving me nuts. I added a function to handle whether we should show the tag or not.
    • This removes the recently-added mbtace.com-host-based logic. However, that shouldn't be needed anymore since DotcomWeb.Plugs.CanonicalHostname adds a 301 redirect for that case.

Visually this should be a no-op. Going to deploy it to verify it works as expected with MIX_ENV=prod.

@thecristen thecristen requested a review from a team as a code owner February 11, 2025 16:10
@thecristen thecristen added the dev-blue Deploy to dev-blue label Feb 11, 2025
@thecristen thecristen enabled auto-merge (squash) February 11, 2025 16:11
@thecristen
Copy link
Collaborator Author

@joshlarson or @anthonyshull might remember this as a repeat of #2233 but that included some other changes and was reverted in #2239 🥲

@github-actions github-actions bot removed the dev-blue Deploy to dev-blue label Feb 11, 2025
Copy link
Contributor

@joshlarson joshlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about the change-tracking thing - that some of the root template looks like it's running afoul of a documented pitfall.

This is a lite request-changes. I really just want to make sure that this won't cause trouble.

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
{csrf_meta_tag()}
<% meta_description =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's best practice to avoid setting variables in components like this, since it can cause unnecessary full-component (in this case, full-page) re-renders. (Got this rec from the pitfalls section of the Assigns & HEEx guide.)

I admit that I'm not sure what the implications are for how layouts act, with the existence of an @inner_block that does do change-tracking properly - maybe it re-renders the template, but keeps the inner block change-tracked? Maybe it re-renders the entire page?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm skeptical it'd affect layouts the same way, but I've added a commit which avoids doing this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it would have an effect unless you're expecting that variable to change. In the example given in the link, they are summing something. In this case it is just a string being set.

@thecristen thecristen force-pushed the cbj/root-template-heex branch from c312772 to c8c66ae Compare March 5, 2025 02:28
Copy link
Contributor

@joshlarson joshlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫚

@thecristen thecristen merged commit d605f36 into main Mar 5, 2025
17 checks passed
@thecristen thecristen deleted the cbj/root-template-heex branch March 5, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants