Commit cd1818f 1 parent ef38838 commit cd1818f Copy full SHA for cd1818f
File tree 1 file changed +26
-23
lines changed
1 file changed +26
-23
lines changed Original file line number Diff line number Diff line change 70
70
└── index.html
71
71
```
72
72
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 >
94
97
```
95
98
96
99
</doc-code >
@@ -99,8 +102,8 @@ Your project should now look like this:
99
102
100
103
```
101
104
app
102
- ├── elements .......... custom element pure functions
103
- │ └── my-header.mjs
105
+ ├── elements .......... custom elements
106
+ │ └── my-header.html
104
107
└── pages ............. file-based routing
105
108
├── about.html
106
109
└── index.html
You can’t perform that action at this time.
0 commit comments