@constela/start 1.8.4 → 1.8.5

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.
@@ -2524,7 +2524,7 @@ function matchRoute2(url, routes) {
2524
2524
  function escapeHtml(str) {
2525
2525
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
2526
2526
  }
2527
- function extractMdxContentSlot(loadedData, dataSourceName, routeParams) {
2527
+ function extractMdxContentSlotWithData(loadedData, dataSourceName, routeParams) {
2528
2528
  const dataSource = loadedData[dataSourceName];
2529
2529
  if (!Array.isArray(dataSource)) {
2530
2530
  return void 0;
@@ -2536,7 +2536,10 @@ function extractMdxContentSlot(loadedData, dataSourceName, routeParams) {
2536
2536
  if (!item || typeof item !== "object" || !("content" in item)) {
2537
2537
  return void 0;
2538
2538
  }
2539
- return { "mdx-content": item.content };
2539
+ return {
2540
+ slot: { "mdx-content": item.content },
2541
+ matchedItem: item
2542
+ };
2540
2543
  }
2541
2544
  async function createDevServer(options = {}) {
2542
2545
  const {
@@ -2623,6 +2626,7 @@ async function createDevServer(options = {}) {
2623
2626
  const program = await convertToCompiledProgram(pageInfo);
2624
2627
  let composedProgram = program;
2625
2628
  const widgets = pageInfo.widgets.map((w) => ({ id: w.id, program: w.program }));
2629
+ const mdxResult = extractMdxContentSlotWithData(pageInfo.loadedData, "docs", match.params);
2626
2630
  if (program.route?.layout && layoutResolver) {
2627
2631
  const layoutProgram = await layoutResolver.getLayout(program.route.layout);
2628
2632
  if (layoutProgram) {
@@ -2630,7 +2634,7 @@ async function createDevServer(options = {}) {
2630
2634
  if (analysis.ok) {
2631
2635
  const compiledLayout = transformLayoutPass(layoutProgram, analysis.context);
2632
2636
  const layoutParams = program.route?.layoutParams;
2633
- const slots = extractMdxContentSlot(pageInfo.loadedData, "docs", match.params);
2637
+ const slots = mdxResult?.slot;
2634
2638
  composedProgram = composeLayoutWithPage(
2635
2639
  compiledLayout,
2636
2640
  program,
@@ -2647,6 +2651,14 @@ async function createDevServer(options = {}) {
2647
2651
  }
2648
2652
  }
2649
2653
  }
2654
+ if (mdxResult?.matchedItem) {
2655
+ const existingImportData = composedProgram.importData ?? {};
2656
+ composedProgram.importData = {
2657
+ ...existingImportData,
2658
+ docs: mdxResult.matchedItem
2659
+ // Bind single matched item instead of array
2660
+ };
2661
+ }
2650
2662
  const cookies = parseCookies(req.headers.cookie ?? null);
2651
2663
  const ssrContext = {
2652
2664
  url: pathname,
@@ -3129,7 +3141,7 @@ async function loadLayout2(layoutName, layoutsDir) {
3129
3141
  function applyLayout(pageView, layoutView, namedSlots) {
3130
3142
  return replaceSlot(layoutView, pageView, namedSlots);
3131
3143
  }
3132
- function extractMdxContentSlot2(loadedData, dataSourceName, routeParams) {
3144
+ function extractMdxContentSlot(loadedData, dataSourceName, routeParams) {
3133
3145
  const dataSource = loadedData[dataSourceName];
3134
3146
  if (dataSource && typeof dataSource === "object" && !Array.isArray(dataSource)) {
3135
3147
  if ("content" in dataSource) {
@@ -3381,7 +3393,7 @@ async function processLayouts(pageInfo, layoutsDir, routeParams = {}) {
3381
3393
  }
3382
3394
  if (pageInfo.loadedData && Object.keys(pageInfo.loadedData).length > 0) {
3383
3395
  for (const dataSourceName of Object.keys(pageInfo.loadedData)) {
3384
- const slots = extractMdxContentSlot2(pageInfo.loadedData, dataSourceName, effectiveRouteParams);
3396
+ const slots = extractMdxContentSlot(pageInfo.loadedData, dataSourceName, effectiveRouteParams);
3385
3397
  if (slots) {
3386
3398
  namedSlots = namedSlots ? { ...namedSlots, ...slots } : slots;
3387
3399
  break;
@@ -3390,7 +3402,7 @@ async function processLayouts(pageInfo, layoutsDir, routeParams = {}) {
3390
3402
  }
3391
3403
  if (!namedSlots && pageInfo.resolvedImports && Object.keys(pageInfo.resolvedImports).length > 0) {
3392
3404
  for (const importName of Object.keys(pageInfo.resolvedImports)) {
3393
- const slots = extractMdxContentSlot2(
3405
+ const slots = extractMdxContentSlot(
3394
3406
  pageInfo.resolvedImports,
3395
3407
  importName,
3396
3408
  effectiveRouteParams
@@ -3404,7 +3416,7 @@ async function processLayouts(pageInfo, layoutsDir, routeParams = {}) {
3404
3416
  const pageWithImportData = pageInfo.page;
3405
3417
  if (!namedSlots && pageWithImportData.importData && Object.keys(pageWithImportData.importData).length > 0) {
3406
3418
  for (const importName of Object.keys(pageWithImportData.importData)) {
3407
- const slots = extractMdxContentSlot2(
3419
+ const slots = extractMdxContentSlot(
3408
3420
  pageWithImportData.importData,
3409
3421
  importName,
3410
3422
  effectiveRouteParams
package/dist/cli/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  hyperlink,
5
5
  loadConfig,
6
6
  resolveConfig
7
- } from "../chunk-4Q7CF76Z.js";
7
+ } from "../chunk-PT6FDT6M.js";
8
8
  import "../chunk-3GFRJEKD.js";
9
9
 
10
10
  // src/cli/index.ts
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  transformCsv,
29
29
  transformMdx,
30
30
  transformYaml
31
- } from "./chunk-4Q7CF76Z.js";
31
+ } from "./chunk-PT6FDT6M.js";
32
32
  import {
33
33
  evaluateMetaExpression,
34
34
  generateHydrationScript,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/start",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
4
4
  "description": "Meta-framework for Constela applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,9 +45,9 @@
45
45
  "tailwindcss": "^4.0.0",
46
46
  "ws": "^8.18.0",
47
47
  "@constela/compiler": "0.12.0",
48
- "@constela/router": "15.0.0",
49
- "@constela/core": "0.13.0",
50
48
  "@constela/runtime": "0.16.5",
49
+ "@constela/core": "0.13.0",
50
+ "@constela/router": "15.0.0",
51
51
  "@constela/server": "9.0.0"
52
52
  },
53
53
  "devDependencies": {