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

docs imply <html> etc added for you #54

Closed
WickyNilliams opened this issue Oct 21, 2022 · 4 comments
Closed

docs imply <html> etc added for you #54

WickyNilliams opened this issue Oct 21, 2022 · 4 comments
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@WickyNilliams
Copy link

In the section of the readme "html imports (kidding... kinda)" it is implied that the <html>, <!doctype> etc get added for you but this doesn't appear to the case. Given the following, as described in the readme:

page.webc:

<title>WebC Example</title>
<my-component></my-component>

components/my-component.webc":

Components don’t need a root element, y’all.

and the following JS:

import { WebC } from "@11ty/webc";

let page = new WebC();

page.defineComponents("components/**.webc");
page.setInputPath("page.webc")

const { html } = await page.compile()
console.log(html)

the docs say:

compiling page.webc will return the following HTML:

<!doctype html>
<html>
	<head>
		<title>WebC Example</title>
	</head>
<body>
	Components don’t need a root element, y’all.
</body>
</html>

I do not see <doctype> etc in the output, i just see:

<title>WebC Example</title>
Components don’t need a root element, y’all.

Here's a stackblitz showing the issue. Check the output of the console https://stackblitz.com/edit/webc-html-doc-type-added

Wondering if this is a bug or a docs issue?

@zachleat
Copy link
Member

zachleat commented Oct 21, 2022

Ah, yeah. I think that’s a docs issue. WebC has two rendering modes for the output HTML: component and page. Component is for component fragments and page is the one you’re expecting here.

webc/webc.js

Line 61 in 7e4558b

getRenderingMode(content) {

I think the safest thing is to update the docs to include a doctype for these examples, but starting them with html would work too.

The other point of discussion might be if it’s worthwhile to add another check for <title> but my vote would be no 😅

@zachleat
Copy link
Member

Docs updates are deploying, thank you!

@zachleat zachleat added the documentation Improvements or additions to documentation label Oct 21, 2022
@zachleat zachleat added this to the Next Version milestone Oct 21, 2022
@WickyNilliams
Copy link
Author

Ah ok, now I get it. Wondering if the two modes should be noted anywhere? It's sort of implied with the changes you made to the docs, but something explicit would be useful to have written down

@zachleat
Copy link
Member

zachleat commented Nov 1, 2022

Filed at #64 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants