@nuasite/cms-sidecar 0.72.0 → 0.72.2

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.
Files changed (2) hide show
  1. package/dist/cli.bundle.js +13 -11
  2. package/package.json +3 -3
@@ -26864,17 +26864,16 @@ function pascalCase(name) {
26864
26864
  return name.replace(/(^|[-_])(\w)/g, (_, _sep, char) => char.toUpperCase());
26865
26865
  }
26866
26866
  function generatePageContent(title, layoutImport) {
26867
- const escapedTitle = title.replace(/'/g, "\\'").replace(/`/g, "\\`");
26868
- const htmlTitle = escapeHtml(title);
26867
+ const textTitle = escapeTemplateText(title);
26869
26868
  if (layoutImport) {
26870
26869
  const { importPath, componentName } = layoutImport;
26871
26870
  return `---
26872
26871
  import ${componentName} from '${importPath}'
26873
26872
  ---
26874
26873
 
26875
- <${componentName} title="${escapedTitle}" description="">
26874
+ <${componentName} title=${propValue(title)} description="">
26876
26875
  <main>
26877
- <h1>${htmlTitle}</h1>
26876
+ <h1>${textTitle}</h1>
26878
26877
  </main>
26879
26878
  </${componentName}>
26880
26879
  `;
@@ -26887,22 +26886,25 @@ import ${componentName} from '${importPath}'
26887
26886
  <head>
26888
26887
  <meta charset="utf-8" />
26889
26888
  <meta name="viewport" content="width=device-width" />
26890
- <title>${escapedTitle}</title>
26889
+ <title>${textTitle}</title>
26891
26890
  </head>
26892
26891
  <body>
26893
26892
  <main>
26894
- <h1>${htmlTitle}</h1>
26893
+ <h1>${textTitle}</h1>
26895
26894
  </main>
26896
26895
  </body>
26897
26896
  </html>
26898
26897
  `;
26899
26898
  }
26900
26899
  function replacePageTitle(content, newTitle) {
26901
- let result = content;
26902
- result = result.replace(/(title\s*=\s*")([^"]*)(")/, `$1${newTitle}$3`);
26903
- result = result.replace(/(<title>)([^<]*)(<\/title>)/, `$1${newTitle}$3`);
26904
- result = result.replace(/(<h1[^>]*>)([^<]*)(<\/h1>)/, `$1${escapeHtml(newTitle)}$3`);
26905
- return result;
26900
+ const textTitle = escapeTemplateText(newTitle);
26901
+ return content.replace(/title\s*=\s*(?:"[^"]*"|\{"(?:[^"\\]|\\.)*"\})/, () => `title=${propValue(newTitle)}`).replace(/(<title>)[^<]*(<\/title>)/, (_, open, close) => open + textTitle + close).replace(/(<h1[^>]*>)[^<]*(<\/h1>)/, (_, open, close) => open + textTitle + close);
26902
+ }
26903
+ function propValue(text) {
26904
+ return text.includes('"') ? `{${JSON.stringify(text)}}` : `"${text}"`;
26905
+ }
26906
+ function escapeTemplateText(text) {
26907
+ return escapeHtml(text).replace(/\{/g, "&#123;").replace(/\}/g, "&#125;");
26906
26908
  }
26907
26909
 
26908
26910
  // ../cms-core/src/redirects.ts
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "directory": "packages/cms-sidecar"
15
15
  },
16
16
  "license": "Apache-2.0",
17
- "version": "0.72.0",
17
+ "version": "0.72.2",
18
18
  "module": "./dist/index.js",
19
19
  "types": "./dist/index.d.ts",
20
20
  "type": "module",
@@ -30,8 +30,8 @@
30
30
  "cms-sidecar": "src/cli.ts"
31
31
  },
32
32
  "dependencies": {
33
- "@nuasite/cms-core": "0.72.0",
34
- "@nuasite/cms-types": "0.72.0"
33
+ "@nuasite/cms-core": "0.72.2",
34
+ "@nuasite/cms-types": "0.72.2"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/bun": "1.3.11"