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

[MWPW-143407] Search Marquee And Content Replace #7

Merged
merged 38 commits into from
Apr 23, 2024
Merged

Conversation

echen-adobe
Copy link
Collaborator

@echen-adobe echen-adobe commented Mar 27, 2024

Adds the search marquee block into Milo.

Requires the injection of a content-replacer script into our scripts.js however. The existing pages are authored with {{ }} tokens that are filled with content from metadata sheets. Milo however removes these {{ }} tokens and does its own replacement.

At the moment, there is no easy way to get around the widespread usage of {{ }} tokens in our pages except to run our own token replacement logic before Milo does. Open to better solutions.

Also working on using the correct fetchPlaceholders, the one that is currently on Milo does not seem to work

After:
https://search-marquee--express-milo--adobecom.hlx.page/express/templates/?milolibs=local

miloLibs must be set to local and a local milo instance must be running due to an issue with placeholders. This should be resolved after Mobile GA when we can change our placeholders file to be compatible with Milo

Screenshot 2024-04-08 at 8 15 26 AM Screenshot 2024-04-08 at 8 17 28 AM

@echen-adobe echen-adobe added the enhancement New feature or request label Mar 27, 2024
Copy link

aem-code-sync bot commented Mar 27, 2024

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

express/scripts/scripts.js Outdated Show resolved Hide resolved
express/scripts/utils/fetch-placeholders.js Outdated Show resolved Hide resolved
express/scripts/utils/autocomplete-api-v3.js Outdated Show resolved Hide resolved
express/scripts/utils/free-plan.js Outdated Show resolved Hide resolved
express/scripts/utils/sampleRUM.js Outdated Show resolved Hide resolved
express/scripts/utils/icons.js Outdated Show resolved Hide resolved
express/scripts/html-sanitizer.js Outdated Show resolved Hide resolved
express/scripts/scripts.js Outdated Show resolved Hide resolved
express/blocks/search-marquee/search-marquee.js Outdated Show resolved Hide resolved
express/blocks/search-marquee/search-marquee.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

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

Just a few more notes :)

  1. why not just change our template default pages to use [[]] instead of {{}}? That seems like a day of effort and then we don't have this problem anymore. We'd have to work with Ernest for this, but that's the whole point of these tasks right.
  2. I saw your notes regarding the placeholders not working. You can get them to work pretty easily by overriding a piece of the milo placeholder code to accept Text as column value as well. I can show you how that works. Just send me a ping.

@echen-adobe
Copy link
Collaborator Author

echen-adobe commented Mar 28, 2024

Just a few more notes :)

  1. why not just change our template default pages to use [[]] instead of {{}}? That seems like a day of effort and then we don't have this problem anymore. We'd have to work with Ernest for this, but that's the whole point of these tasks right.

I think a lot of issues with this PR revolve around this. From what I understand, replacing all the {{}} tokens with [[]] is a non trivial task, which is why I went with content-replace. Content replace also includes {{ }} usage logic itself, such as replacing tokens with metadata, so it is not as simple as replacing all {{ }} with [[]] throughout the docs, many pages will need the {{}} logic distributed to them.

I think it will be possible to map all the pages that do require the {{ }} token efficiently if a script of mine works out, but we will still need to figure out how to distribute the replacement logic within content.js

@vhargrave
Copy link
Collaborator

Just a few more notes :)

  1. why not just change our template default pages to use [[]] instead of {{}}? That seems like a day of effort and then we don't have this problem anymore. We'd have to work with Ernest for this, but that's the whole point of these tasks right.

I think a lot of issues with this PR revolve around this. From what I understand, replacing all the {{}} tokens with [[]] is a non trivial task, which is why I went with content-replace. Content replace also includes {{ }} usage logic itself, such as replacing tokens with metadata, so it is not as simple as replacing all {{ }} with [[]] throughout the docs, many pages will need the {{}} logic distributed to them.

I think it will be possible to map all the pages that do require the {{ }} token efficiently if a script of mine works out, but we will still need to figure out how to distribute the replacement logic within content.js

we probably only want it to run on the template-x block & colors block right?
So I would select for them. For all other blocks I expect {{}} to only contain placeholders.

@echen-adobe
Copy link
Collaborator Author

Just a few more notes :)

  1. why not just change our template default pages to use [[]] instead of {{}}? That seems like a day of effort and then we don't have this problem anymore. We'd have to work with Ernest for this, but that's the whole point of these tasks right.

I think a lot of issues with this PR revolve around this. From what I understand, replacing all the {{}} tokens with [[]] is a non trivial task, which is why I went with content-replace. Content replace also includes {{ }} usage logic itself, such as replacing tokens with metadata, so it is not as simple as replacing all {{ }} with [[]] throughout the docs, many pages will need the {{}} logic distributed to them.
I think it will be possible to map all the pages that do require the {{ }} token efficiently if a script of mine works out, but we will still need to figure out how to distribute the replacement logic within content.js

we probably only want it to run on the template-x block & colors block right? So I would select for them. For all other blocks I expect {{}} to only contain placeholders.

I know that it is used in the marquee and pricing cards blocks to substitute information based on locales, its likely present elsewhere.

removed local sampleRUM, replaced with imported lib
removed fetch-placeholders, replaced with imported lib
updated content replace with version from events-milo
removed dependencies of sampleRUM and fetch placeholders
Copy link
Collaborator

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

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

looking better and better mate!

@@ -215,6 +216,7 @@ export function listenMiloEvents() {
}

export function decorateArea(area = document) {
autoUpdateContent(area, getLibs());
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a clean approach, but I need the most performant approach possible.
That means instead of importing and delaying the whole page load by another 100-200 milliseconds just add the code from autoUpdateContent that you really really need even if it's copy pasted. Don't add the whole file if possible. Just the code that you really need executed here.

express/blocks/search-marquee/search-marquee.js Outdated Show resolved Hide resolved
Copy link

aem-code-sync bot commented Apr 8, 2024

Page Scores Audits
/express/templates/?milolibs=local PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS

@echen-adobe echen-adobe changed the title [Draft] Search Marquee [MWPW-143407] Search Marquee And Content Replace Apr 8, 2024
@echen-adobe echen-adobe merged commit 195c35c into main Apr 23, 2024
5 of 6 checks passed
@vhargrave vhargrave deleted the search-marquee branch April 24, 2024 11:18
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