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

component at layout.html compile error #251

Open
Hi-Alan opened this issue Apr 5, 2024 · 3 comments
Open

component at layout.html compile error #251

Hi-Alan opened this issue Apr 5, 2024 · 3 comments
Labels
question Further information is requested

Comments

@Hi-Alan
Copy link

Hi-Alan commented Apr 5, 2024

I defined a component at site-level layout.html, it runs ok if there is no<script> block;
An error raised parse error layout.html for codes:

<section @name="compile-time-component">
It will be compiled to static html:{title}{title1}
  <script>
    title1 = `New title`
  </script>
</section>
@nobkd
Copy link
Collaborator

nobkd commented Apr 7, 2024

I can't reproduce this. The code runs just fine when I use the <compile-time-component />.
(I used the Simple Blog example and pasted your code to the layout.html and added the component to the <main> section. I'm using Nue(kit) 0.5.3, Bun 1.1.2, Linux)

Can you create a minimal reproduction/implementation example? (e.g. a gh repo, or a simple layout.html + index.md, or an archive file, or further reproduction steps)

Maybe details about System (Windows, Linux, Mac, ...), Nuekit version, runner (node, bun, ...), package manager (bun, yarn, npm, pnpm, ...) can help too.

Thank you

@Hi-Alan
Copy link
Author

Hi-Alan commented Apr 7, 2024

Thank you for your reply.

If there is One Of <script> blocks in site-level layout.html, or comment import line, It runs OK.

MacOS 13.2.1 (22D68) Nue 0.5.3 • Bun 1.0.36

<script>
    import { render, parseFile } from 'nuejs-core'
    // const [app, ...utils] = await parseFile('./global/app-entry.nue')
    // tmpl = `<app-entry title="title for page 3" :description desc="client?? not execution" />`
    // html1 = render(tmpl, {
    //   description: 'how can I define a component that runs at server side at runtime not compile-time?',
    //   question: 'how can I define a component that it\'s props is a promise? await  etc '
    // }, utils)
</script>

<footer>
  <compile-time-component title="compile time component"></compile-time-component>
</footer>

<section @name="compile-time-component">
It will be compiled to static html:{title}{title1}
  <script>
    title1 = "New title"
  </script>
</section>

@nobkd
Copy link
Collaborator

nobkd commented Apr 14, 2024

I don't think this code should be defined in a layout file. But I also don't know how to do server side components, but here are related discussions / issues:


cc @tipiirai maybe you can tell those / this issue if/how this is already implemented, or if this is just missing from the docs?
When I read the first discussion, I read it, as if this is already implemented...

@nobkd nobkd added the question Further information is requested label Apr 14, 2024
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