@emberkit/cli 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/commands/build.js
CHANGED
|
@@ -129,14 +129,32 @@ function siteConfigToHeadOptions(site) {
|
|
|
129
129
|
}
|
|
130
130
|
function getServerEntryShim(site) {
|
|
131
131
|
const siteHeadOptions = siteConfigToHeadOptions(site);
|
|
132
|
-
return `import { routes, notFoundRoute, errorRoute } from 'virtual:emberkit-routes';
|
|
133
|
-
import {
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
return `import { routes, rootLayout, notFoundRoute, errorRoute } from 'virtual:emberkit-routes';
|
|
133
|
+
import {
|
|
134
|
+
createElement,
|
|
135
|
+
buildRouteHeadFromMetadata,
|
|
136
|
+
drainHeadContent,
|
|
137
|
+
clearHeadContent,
|
|
138
|
+
} from '@emberkit/core';
|
|
136
139
|
import { readFileSync } from 'node:fs';
|
|
137
140
|
import { join, dirname } from 'node:path';
|
|
138
141
|
import { fileURLToPath } from 'node:url';
|
|
139
142
|
|
|
143
|
+
const siteHeadOptions = ${siteHeadOptions};
|
|
144
|
+
|
|
145
|
+
const wrapWithRootLayout = async (RouteComponent) => {
|
|
146
|
+
if (!rootLayout) {
|
|
147
|
+
return RouteComponent;
|
|
148
|
+
}
|
|
149
|
+
const layoutMod = await rootLayout();
|
|
150
|
+
const Layout = layoutMod.default || layoutMod;
|
|
151
|
+
return (routeProps) =>
|
|
152
|
+
createElement(Layout, {
|
|
153
|
+
pathname: routeProps?.pathname,
|
|
154
|
+
children: createElement(RouteComponent, routeProps),
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
140
158
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
141
159
|
|
|
142
160
|
const routeToRegex = (routePath) => {
|
|
@@ -264,14 +282,18 @@ export async function render(url) {
|
|
|
264
282
|
if (match) {
|
|
265
283
|
try {
|
|
266
284
|
const mod = await match.route.component();
|
|
267
|
-
const
|
|
268
|
-
|
|
285
|
+
const Route = mod.default || mod;
|
|
286
|
+
clearHeadContent();
|
|
287
|
+
const Page = await wrapWithRootLayout(Route);
|
|
288
|
+
const element = createElement(Page, { params: match.params, pathname });
|
|
289
|
+
appHtml = renderToString(element);
|
|
290
|
+
const drained = drainHeadContent();
|
|
269
291
|
if (mod.metadata) {
|
|
270
|
-
headContent
|
|
292
|
+
headContent =
|
|
293
|
+
buildRouteHeadFromMetadata(mod.metadata, pathname, siteHeadOptions ?? undefined) + '\\n';
|
|
294
|
+
} else if (drained) {
|
|
295
|
+
headContent = drained + '\\n';
|
|
271
296
|
}
|
|
272
|
-
|
|
273
|
-
const element = createElement(Component, { params: match.params });
|
|
274
|
-
appHtml = renderToString(element);
|
|
275
297
|
} catch (e) {
|
|
276
298
|
console.error('[SSR] Failed to render route:', pathname, e);
|
|
277
299
|
if (errorRoute) {
|
|
@@ -300,9 +322,18 @@ export async function render(url) {
|
|
|
300
322
|
if (notFoundRoute) {
|
|
301
323
|
try {
|
|
302
324
|
const mod = await notFoundRoute();
|
|
303
|
-
const
|
|
304
|
-
|
|
325
|
+
const Route = mod.default || mod;
|
|
326
|
+
clearHeadContent();
|
|
327
|
+
const Page = await wrapWithRootLayout(Route);
|
|
328
|
+
const element = createElement(Page, {});
|
|
305
329
|
appHtml = renderToString(element);
|
|
330
|
+
const drained = drainHeadContent();
|
|
331
|
+
if (drained) {
|
|
332
|
+
headContent = drained + '\\n';
|
|
333
|
+
} else if (mod.metadata) {
|
|
334
|
+
headContent =
|
|
335
|
+
buildRouteHeadFromMetadata(mod.metadata, pathname, siteHeadOptions ?? undefined) + '\\n';
|
|
336
|
+
}
|
|
306
337
|
} catch (e) {
|
|
307
338
|
console.error('[SSR] Failed to render 404 page:', e);
|
|
308
339
|
appHtml = '<div style="padding: 20px;">404 - Page not found</div>';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Semver ranges for @emberkit/* packages written into generated projects.
|
|
2
2
|
// When releasing libraries, bump these to match packages/*/package.json "version".
|
|
3
3
|
export const EMBERKIT_PACKAGE_VERSIONS = {
|
|
4
|
-
core: "^0.6.
|
|
4
|
+
core: "^0.6.1",
|
|
5
5
|
ui: "^4.0.0",
|
|
6
|
-
icons: "^4.0.
|
|
7
|
-
cli: "^0.7.
|
|
6
|
+
icons: "^4.0.1",
|
|
7
|
+
cli: "^0.7.1",
|
|
8
8
|
edge: "^0.2.4",
|
|
9
9
|
tsconfig: "^0.2.1",
|
|
10
10
|
};
|