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

🐛 JavaScript error "Uncaught ReferenceError: oid is not defined" is thrown when not using Firebase integration #1651

Closed
ragibson opened this issue Jul 30, 2024 · 2 comments

Comments

@ragibson
Copy link
Contributor

Describe the bug
Pages with posts throw a ReferenceError in the console when not using a Firebase integration.

To Reproduce
Steps to reproduce the behavior:
View any Blowfish website without likes enabled and you'll see it in the console. Pulling a few arbitrarily from the Blowfish users page: https://joshblais.com/posts/, https://zen96k.github.io/enoshima-escar/posts/, https://blog.wtcx.dev/posts/, etc.

Expected behavior
No errors are thrown in the console.

Screenshots
image
image

Desktop

  • OS: Linux, Windows
  • Browser: Firefox, Chrome
  • Version: Most recent / various

Hugo & Blowfish versions
The most recent version, though it seems to affect a wide range of them.

Additional context
At a glance, this is probably caused by 6190898.

@wtchangdm
Copy link
Contributor

The problem is that

<script>
var oid = "views_{{ $path }}"
var oid_likes = "likes_{{ $path }}"
</script>
doesn't get rendered as expected so there is no oid and oid_likes to being with. Not sure what does this part try to do with the translations.

One way to simply suppress the error is to add some guards here:

var liked_page = false
var id = oid ? oid.replaceAll("/", "-") : oid
var id_likes = oid_likes ? oid_likes.replaceAll("/", "-") : oid_likes
if (typeof auth !== 'undefined') {

@ragibson
Copy link
Contributor Author

ragibson commented Aug 9, 2024

I agree that the guards would work, but I've opted to just include the scripts in the relevant statement scopes to better target the root cause here. Let's see what nunocoracao says in the PR.

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

No branches or pull requests

2 participants