File tree Expand file tree Collapse file tree 12 files changed +76
-48
lines changed Expand file tree Collapse file tree 12 files changed +76
-48
lines changed Original file line number Diff line number Diff line change 54
54
" ./packages/custom-elements-manifest-tools:build" ,
55
55
" ./packages/catalog-api:build" ,
56
56
" ./packages/catalog-server:build" ,
57
+ " ./packages/site-server:build" ,
57
58
" ./packages/site-content:build" ,
58
59
" ./packages/site-client:build"
59
60
]
Original file line number Diff line number Diff line change 6
6
7
7
import { html , css , LitElement } from 'lit' ;
8
8
import { customElement } from 'lit/decorators.js' ;
9
- import './wco-top-bar.js' ;
10
9
import './wco-catalog-search.js' ;
11
10
12
11
@customElement ( 'wco-catalog-page' )
@@ -19,7 +18,6 @@ export class WCOCatalogPage extends LitElement {
19
18
20
19
render ( ) {
21
20
return html `
22
- < wco-top-bar > </ wco-top-bar >
23
21
< h1 > Catalog</ h1 >
24
22
< wco-catalog-search > </ wco-catalog-search >
25
23
` ;
Original file line number Diff line number Diff line change @@ -15,8 +15,6 @@ import {
15
15
normalizeModulePath ,
16
16
} from '@webcomponents/custom-elements-manifest-tools' ;
17
17
18
- import './wco-top-bar.js' ;
19
-
20
18
export interface ElementData {
21
19
packageName : string ;
22
20
elementName : string ;
@@ -46,10 +44,7 @@ export class WCOElementPage extends LitElement {
46
44
47
45
render ( ) {
48
46
if ( this . elementData === undefined ) {
49
- return html `
50
- < wco-top-bar > </ wco-top-bar >
51
- < div class ="full-screen-error "> No element to display</ div >
52
- ` ;
47
+ return html ` < div class ="full-screen-error "> No element to display</ div > ` ;
53
48
}
54
49
const {
55
50
packageName,
@@ -71,7 +66,6 @@ export class WCOElementPage extends LitElement {
71
66
72
67
if ( declaration === undefined || declaration . kind !== 'class' ) {
73
68
return html `
74
- < wco-top-bar > </ wco-top-bar >
75
69
< div class ="full-screen-error "> Could not find element declaration</ div >
76
70
` ;
77
71
}
@@ -80,7 +74,6 @@ export class WCOElementPage extends LitElement {
80
74
const methods = declaration . members ?. filter ( ( m ) => m . kind === 'method' ) ;
81
75
82
76
return html `
83
- < wco-top-bar > </ wco-top-bar >
84
77
< h1 > ${ packageName } /${ elementName } </ h1 >
85
78
< h3 > ${ declaration . summary } </ h3 >
86
79
Original file line number Diff line number Diff line change 4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
6
6
7
- import { renderElementPage } from './element.js' ;
8
7
import { hydrate } from 'lit/experimental-hydrate.js' ;
8
+ import { renderBody } from '../templates/body.js' ;
9
+ import { renderElementPage } from './element.js' ;
9
10
10
11
const data = (
11
12
window as unknown as { __ssrData : Parameters < typeof renderElementPage > }
12
13
) . __ssrData ;
13
- hydrate ( renderElementPage ( ...data ) , document . body ) ;
14
+
15
+ // We need to hydrate the whole page to remove any defer-hydration attributes.
16
+ // We could also remove the attribute manually, or not use deferhydration, but
17
+ // instead manually assign the data into the <wco-element-page> element, and
18
+ // time imports so that automatic element hydration happend after.
19
+ hydrate ( renderBody ( renderElementPage ( ...data ) ) , document . body ) ;
Original file line number Diff line number Diff line change 3
3
* Copyright 2022 Google LLC
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
6
-
7
- import '../components/wco-top-bar.js' ;
6
+ import 'lit/experimental-hydrate-support.js' ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { html } from 'lit' ;
8
+ import '../components/wco-top-bar.js' ;
9
+
10
+ export const renderBody = ( content : unknown ) => html `< wco-top-bar > </ wco-top-bar >
11
+ ${ content } ` ;
Original file line number Diff line number Diff line change 54
54
},
55
55
"build:templates" : {
56
56
"command" : " find templates/src -name \" *.ts\" | xargs esbuild --color --outdir=templates/lib" ,
57
+ "dependencies" : [
58
+ " ../site-client:build"
59
+ ],
57
60
"files" : [
58
61
" templates/src/**/*.ts"
59
62
],
73
76
],
74
77
"dependencies" : [
75
78
" ../catalog-api:build" ,
76
- " ../custom-elements-manifest-tools:build"
79
+ " ../custom-elements-manifest-tools:build" ,
80
+ " ../site-client:build"
77
81
],
78
82
"clean" : " if-file-deleted"
79
83
},
90
94
},
91
95
"dependencies" : {
92
96
"@11ty/eleventy" : " ^1.0.2" ,
97
+ "@webcomponents/internal-site-client" : " ^0.0.0" ,
93
98
"@webcomponents/internal-site-server" : " ^0.0.0"
94
99
}
95
100
}
Original file line number Diff line number Diff line change 6
6
7
7
module . exports = {
8
8
async render ( data ) {
9
- const { renderPage} = await import ( '../../../templates/lib/base.js' ) ;
10
- // TODO (justinfagnani): move the top-bar to a real template or
11
- // back into the base template when we enable 11ty / Lit SSR integration
9
+ const { renderPage, unsafeHTML } = await import (
10
+ '../../../templates/lib/base.js'
11
+ ) ;
12
12
return [
13
13
...renderPage ( {
14
14
...data ,
15
- content : `
16
- <wco-top-bar></wco-top-bar>
17
- ${ data . content }
18
- ` ,
15
+ content : unsafeHTML ( data . content ) ,
19
16
} ) ,
20
17
] . join ( '' ) ;
21
18
} ,
Original file line number Diff line number Diff line change 3
3
* Copyright 2022 Google LLC
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
6
+
7
+ // This must be imported before lit
8
+ import {
9
+ render ,
10
+ RenderInfo ,
11
+ } from '@lit-labs/ssr/lib/render-with-global-dom-shim.js' ;
12
+
13
+ import type { TemplateResult } from 'lit' ;
14
+ import type { DirectiveResult } from 'lit/directive.js' ;
15
+ import { renderBody } from '@webcomponents/internal-site-client/lib/templates/body.js' ;
16
+
6
17
import { escapeHTML } from './escape-html.js' ;
18
+ export { unsafeHTML } from 'lit/directives/unsafe-html.js' ;
7
19
8
- export function * renderPage ( data : {
9
- scripts ?: Array < string > ;
10
- title ?: string ;
11
- content : string | Iterable < string > ;
12
- initialData ?: object ;
13
- initScript ?: string ;
14
- } ) {
20
+ export function * renderPage (
21
+ data : {
22
+ scripts ?: Array < string > ;
23
+ title ?: string ;
24
+ content : TemplateResult | DirectiveResult ;
25
+ initialData ?: object ;
26
+ initScript ?: string ;
27
+ } ,
28
+ options ?: Partial < RenderInfo >
29
+ ) {
15
30
yield `<!doctype html>
16
31
<html lang="en">
17
32
<head>
@@ -55,11 +70,7 @@ export function* renderPage(data: {
55
70
</head>
56
71
<body>
57
72
` ;
58
- if ( typeof data . content === 'string' ) {
59
- yield data . content ;
60
- } else {
61
- yield * data . content ;
62
- }
73
+ yield * render ( renderBody ( data . content ) , options ) ;
63
74
64
75
if ( data . initialData !== undefined ) {
65
76
yield `<script>window.__ssrData = ${ JSON . stringify (
Original file line number Diff line number Diff line change 56
56
" ../../tsconfig.base.json" ,
57
57
" src/**/*.ts"
58
58
],
59
- "output" : [],
59
+ "output" : [
60
+ " tsconfig.tsbuildinfo"
61
+ ],
60
62
"dependencies" : [
61
63
" ../site-client:build:types" ,
62
64
" ../site-content:build:templates:types"
89
91
"@types/koa-etag" : " ^3.0.0" ,
90
92
"@types/koa-static" : " ^4.0.2" ,
91
93
"@web/dev-server" : " ^0.1.34" ,
94
+ "@webcomponents/internal-site-content" : " ^0.0.0" ,
92
95
"koa" : " ^2.13.4" ,
93
96
"koa-conditional-get" : " ^3.0.0" ,
94
97
"koa-etag" : " ^4.0.0" ,
You can’t perform that action at this time.
0 commit comments