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

Blank line in a webc page triggers component rendering mode instead of page #115

Closed
mdarrik opened this issue Dec 23, 2022 · 1 comment
Closed
Labels
bug Something isn't working
Milestone

Comments

@mdarrik
Copy link

mdarrik commented Dec 23, 2022

Not sure if this should go here or in 11ty/webc. Sorry!

It seems that if you have a blank line at the start of a webc page file, the built page will be missing the html and doctype and head elements. This also happens if there's a blank line after the front matter. For example, if I have the following index.webc file:

---
test: "hi"
---

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Test</title>
  </head>
  <body>
    <h1>Hi, this is a test</h1>
  </body>
</html>

will output:

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test</title>
    <h1>Hi, this is a test</h1>

If you remove the blank line it seems to output correctly. However, Prettier adds a newline after the front matter (and my editor runs prettier on save), which can make it a bit tedious to manage. Would probably be nice if the plugin trimmed any newlines from the start of a file before determining which rendering mode to use.

A reproduction can be found here: https://github.com/mdarrik/11ty-plugin-webc-test-page-webc

@zachleat zachleat added the bug Something isn't working label Feb 22, 2023
@zachleat zachleat transferred this issue from 11ty/eleventy-plugin-webc Feb 22, 2023
@zachleat zachleat added this to the WebC v0.9.0 milestone Feb 22, 2023
@zachleat
Copy link
Member

Shipping with WebC v0.9.0—great test case, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants