Skip to content

Commit ee22a86

Browse files
committed
Add SSG for the docs app -- ready to deploy
1 parent 98e40bf commit ee22a86

5 files changed

Lines changed: 64 additions & 20 deletions

File tree

docs/app/app-ssr.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Application from 'ember-strict-application-resolver';
2+
import { settled } from '@ember/test-helpers';
3+
import { entries } from 'ember-page-title/service-registry';
4+
5+
export default class SsrApp extends Application {
6+
modules = {
7+
...entries(),
8+
...import.meta.glob('./router.js', { eager: true }),
9+
...import.meta.glob('./routes/**/*.js', { eager: true }),
10+
...import.meta.glob('./templates/**/*.{gts,gjs}', { eager: true }),
11+
};
12+
}
13+
14+
export function createSsrApp() {
15+
const app = SsrApp.create({ autoboot: false });
16+
17+
const originalVisit = app.visit.bind(app);
18+
19+
Object.assign(app, {
20+
visit: async (...args) => {
21+
const instance = await originalVisit(...args);
22+
23+
await settled();
24+
25+
return instance;
26+
},
27+
});
28+
29+
return app;
30+
}

docs/app/config/environment.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { setTesting } from '@embroider/macros';
2-
31
const config = {
42
environment: import.meta.env.DEV ? 'development' : 'production',
53
rootURL: '/',
@@ -11,8 +9,6 @@ const config = {
119
export default config;
1210

1311
export function enterTestMode() {
14-
setTesting(true);
15-
1612
config.locationType = 'none';
1713
config.APP.rootElement = '#ember-testing';
1814
config.APP.autoboot = false;

docs/app/styles/app.scss

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
@import 'fonts';
2-
@import 'colors';
3-
@import 'code';
4-
@import 'grid';
1+
@import './fonts.scss';
2+
@import './colors.scss';
3+
@import './code.scss';
4+
@import './grid.scss';
55

6-
@import 'components';
7-
@import './routes/docs';
6+
@import './components.scss';
7+
@import './routes/docs.scss';
88

99
* {
1010
box-sizing: border-box;
1111
}
1212

13-
html, body {
13+
html,
14+
body {
1415
margin: 0;
1516
padding: 0;
1617
font-family: OfficeCodePro, Consolas, Inconsolata, monspace;
@@ -37,17 +38,19 @@ textarea {
3738
max-width: 100%;
3839
transition: box-shadow 120ms;
3940
-webkit-appearance: textfield;
40-
-moz-appearance: textfield;
41-
-ms-appearance: textfield;
42-
appearance: textfield;
41+
-moz-appearance: textfield;
42+
-ms-appearance: textfield;
43+
appearance: textfield;
4344

4445
background: $transparent;
4546
box-shadow: none;
47+
4648
&:hover {
4749
box-shadow: 0 0 0 3px rgba($black, 0.1);
4850
}
4951

50-
&:focus, &:active {
52+
&:focus,
53+
&:active {
5154
outline: none;
5255
box-shadow: 0 0 0 3px rgba($black, 0.25);
5356
}
@@ -84,7 +87,7 @@ header {
8487

8588
svg {
8689
-webkit-filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
87-
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
90+
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
8891
}
8992

9093
nav {
@@ -107,7 +110,7 @@ header {
107110
}
108111
}
109112

110-
section > h2 {
113+
section>h2 {
111114
padding: 30px 0;
112115
margin: 40px 0;
113116
}
@@ -134,7 +137,8 @@ hr {
134137
}
135138

136139

137-
pre, pre.hljs {
140+
pre,
141+
pre.hljs {
138142
font-family: 'OfficeCodePro';
139143
font-size: 14px;
140144
background: #FAFAFA;
@@ -146,6 +150,7 @@ pre, pre.hljs {
146150
::selection {
147151
background: #DEDDED;
148152
}
153+
149154
::-moz-selection {
150155
background: #DEDDED;
151156
}
@@ -180,14 +185,14 @@ pre, pre.hljs {
180185
width: 100%;
181186
height: 39px;
182187
display: -webkit-flex;
183-
display: flex;
188+
display: flex;
184189
display: flex;
185190
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
186191

187192
a {
188193
margin: 0;
189194
-webkit-flex: 1;
190-
flex: 1;
195+
flex: 1;
191196
text-align: center;
192197
line-height: 38px;
193198
background: rgba(0, 0, 0, 0.4);

docs/tests/test-helper.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import Application from 'docs/app';
22
import config, { enterTestMode } from 'docs/config/environment';
33
import { setApplication } from '@ember/test-helpers';
44
import { start as qunitStart, setupEmberOnerrorValidation } from 'ember-qunit';
5+
import { setTesting } from '@embroider/macros';
56

67
export function start() {
8+
setTesting(true);
79
enterTestMode();
810
setApplication(Application.create(config.APP));
911

docs/vite.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from 'vite';
22
import { extensions, ember } from '@embroider/vite';
33
import { babel } from '@rollup/plugin-babel';
4+
import { emberSsg } from 'vite-ember-ssr/vite-plugin';
45

56
export default defineConfig({
67
plugins: [
@@ -9,5 +10,15 @@ export default defineConfig({
910
babelHelpers: 'runtime',
1011
extensions,
1112
}),
13+
emberSsg({
14+
// weierdness: '', because we renamed
15+
// "docs" to "/" in the router
16+
routes: [''],
17+
ssrEntry: 'app/app-ssr.js',
18+
rehydrate: true,
19+
}),
1220
],
21+
ssr: {
22+
noExternal: [/./],
23+
},
1324
});

0 commit comments

Comments
 (0)