File tree Expand file tree Collapse file tree 1 file changed +26
-23
lines changed Expand file tree Collapse file tree 1 file changed +26
-23
lines changed Original file line number Diff line number Diff line change 7070 └── index.html
7171```
7272
73- Add a [ pure function] ( https://en.wikipedia.org/wiki/Pure_function ) that returns an HTML string.
74- Your function will be passed an object containing an ` html ` render function for expanding custom elements.
75-
76- Add a ` my-header.mjs ` file in the ` app/elements/ ` folder. Notice that we're using a two-word-or-more name for our custom element.
77-
78- The contents of ` my-header.mjs ` should look like this:
79-
80- <doc-code filename =" app/elements/my-header.mjs " >
81-
82- ``` javascript
83- export default function MyHeader ({ html }) {
84- return html `
85- <header >
86- <h1 >Header</h1 >
87- <nav >
88- <a href =/>home</a >
89- <a href =/about >about</a >
90- </nav >
91- </header >
92- `
93- }
73+ Start with simple ` .html ` files for your app's custom elements.
74+ Your custom elements will be automatically expanded when their tags are used in your pages.
75+
76+ <doc-callout level =" info " >
77+
78+ Beginning with simple HTML elements helps get an app off the ground and gives a great baseline for enhancement.
79+ Converting to dynamic ` .mjs ` is an easy upgrade when needed! [ Further docs] ( /docs/conventions/elements ) cover that in more detail.
80+
81+ </doc-callout >
82+
83+ Create a ` my-header.html ` file in the ` app/elements/ ` folder. Notice that we're using a two-word-or-more name for our custom element.
84+
85+ The contents of ` my-header.html ` should look like this:
86+
87+ <doc-code filename =" app/elements/my-header.html " >
88+
89+ ``` html
90+ <header >
91+ <h1 >Header</h1 >
92+ <nav >
93+ <a href =/>home</a >
94+ <a href =" /about" >about</a >
95+ </nav >
96+ </header >
9497```
9598
9699</doc-code >
@@ -99,8 +102,8 @@ Your project should now look like this:
99102
100103```
101104app
102- ├── elements .......... custom element pure functions
103- │ └── my-header.mjs
105+ ├── elements .......... custom elements
106+ │ └── my-header.html
104107└── pages ............. file-based routing
105108 ├── about.html
106109 └── index.html
You can’t perform that action at this time.
0 commit comments