8000 Can't seem to include inline script for head in @global/layout.html · Issue #512 · nuejs/nue · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Can't seem to include inline script for head in @global/layout.html #512

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

Closed
wgehner opened this issue Mar 17, 2025 · 3 comments
Closed

Can't seem to include inline script for head in @global/layout.html #512

wgehner opened this issue Mar 17, 2025 · 3 comments
Labels
question Further information is requested

Comments

@wgehner
Copy link
wgehner commented Mar 17, 2025

Describe the Bug

Using inline script in head layout appears to suppress any custom html

Environment

MacOS RC2

Minimal Reproduction

I added some custom meta tags in layout.html

<head>
<meta name='foo' content='bar'/>
</head>

This gets appended to the autogenerated content of head, which is great. When I try to add an inline script for googletagmanager, as in

<script>window.datalayer = 'etc'</script>

the head is rendered as default, without script or my custom meta foo. So I can't inject Google Analytics to the site. Is there a workaround or solution?

@nobkd
Copy link
Collaborator
nobkd commented Mar 18, 2025

Try using <script type="module"> in to have normal js in html.
Scripts with out type are interpreted as component scripts I think.

@nobkd nobkd added the question Further information is requested label Mar 18, 2025
@wgehner
8000
Copy link
Author
wgehner commented Mar 18, 2025

Happy to confirm that type="text/javascript" as well keeps the head layout from breaking :-) Without it the stack trace is

SyntaxError: Unexpected identifier '_start'. Expected a ';' following a class field.
at (/Users/Wolfgang/node_modules/nuejs-core/src/fn.js:95:18)

Script type is technically optional, browser defaults to to text/javascript, Nue could do the same. Great workaround in the meantime!

@nobkd
Copy link
Collaborator
nobkd commented Mar 18, 2025

I'll close this as completed.

I don't think it will be possible to use plain <script> tags without the type property using the current model, because plain <script> tags get interpreted as component script (afaik).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants
0