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: duplicate ld+json data #3444

Merged

Conversation

michael-genson
Copy link
Collaborator

What type of PR is this?

(REQUIRED)

  • bug

What this PR does / why we need it:

(REQUIRED)

Fixes the duplicate ld+json data causing scrapers to grab the wrong recipes. I used two different solutions:

  1. the data is injected only in the instance of the HTML being served, rather than the global state
  2. the injected data replaces the existing data, if it exists, rather than just appending it (this ensures if there are any other instances of the metadata being injected, there is exactly one instance of recipe metadata)

Due to how our metadata injection works, technically the recipe's data follows you around (for example, if you open a recipe for chocolate brownies, then head to the home page, the chocolate brownie metadata is still present) however I tested this and it's always correct when navigating to any page directly (which is all that matters for scrapers).

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #3068
Fixes #3374

Testing

(fill-in or delete this section)

Built a production instance locally and verified that exactly one instance of recipe metadata is present, and it's the correct recipe.

@michael-genson
Copy link
Collaborator Author

michael-genson commented Apr 12, 2024

@hay-kot if you could confirm this works on a local prod instance that would be great. I did prior to the latest commit so I'm pretty confident it works, but it would be good to verify.

I wanted to myself but local prod isn't working (probably WSL)

@michael-genson
Copy link
Collaborator Author

Fixed my local prod and confirmed it still works as expected

Copy link
Collaborator

@boc-the-git boc-the-git left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@boc-the-git boc-the-git enabled auto-merge (squash) April 16, 2024 10:40
@boc-the-git boc-the-git merged commit 2ff1135 into mealie-recipes:mealie-next Apr 16, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants