@saacms/host-astro 0.1.5 → 0.1.6
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/host-astro-adapter.d.ts.map +1 -1
- package/dist/index.js +14 -7
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-astro-adapter.d.ts","sourceRoot":"","sources":["../src/host-astro-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,OAAO,KAAK,EAIV,WAAW,EAEX,UAAU,EAEX,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"host-astro-adapter.d.ts","sourceRoot":"","sources":["../src/host-astro-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,OAAO,KAAK,EAIV,WAAW,EAEX,UAAU,EAEX,MAAM,YAAY,CAAA;AAkKnB;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAMtE;AAuCD,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,wBAAgB,sBAAsB,CACpC,IAAI,GAAE,uBAA4B,GACjC,WAAW,CAuGb"}
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,17 @@ import { readFileSync } from "node:fs";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import { SCHEME_COOKIE, DARK_MODE_COOKIE } from "@saacms/core";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
6
|
+
function templatesDir() {
|
|
7
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), "..", "templates");
|
|
8
|
+
}
|
|
9
|
+
var _mountTemplate;
|
|
10
|
+
function loadMountTemplate() {
|
|
11
|
+
return _mountTemplate ??= readFileSync(resolve(templatesDir(), "api-mount.ts.txt"), "utf8");
|
|
12
|
+
}
|
|
13
|
+
var _previewTemplate;
|
|
14
|
+
function loadPreviewTemplate() {
|
|
15
|
+
return _previewTemplate ??= readFileSync(resolve(templatesDir(), "preview-route.astro.txt"), "utf8");
|
|
16
|
+
}
|
|
10
17
|
function assertSafeUrl(url) {
|
|
11
18
|
if (url.includes("\\")) {
|
|
12
19
|
throw new Error(`generateRoute: url '${url}' contains a backslash; use forward slashes`);
|
|
@@ -118,10 +125,10 @@ function createAstroHostAdapter(opts = {}) {
|
|
|
118
125
|
return assetRootPath;
|
|
119
126
|
},
|
|
120
127
|
mountTemplate() {
|
|
121
|
-
return
|
|
128
|
+
return loadMountTemplate();
|
|
122
129
|
},
|
|
123
130
|
previewRouteTemplate(blockSlug) {
|
|
124
|
-
return
|
|
131
|
+
return loadPreviewTemplate().replaceAll("${blockSlug}", blockSlug);
|
|
125
132
|
},
|
|
126
133
|
generateRoute(page, options) {
|
|
127
134
|
assertSafeUrl(page.url);
|
|
@@ -177,7 +184,7 @@ function createAstroHostAdapter(opts = {}) {
|
|
|
177
184
|
generatePreviewRoute(block) {
|
|
178
185
|
return {
|
|
179
186
|
path: `src/pages/saacms/preview/${block.slug}.astro`,
|
|
180
|
-
source:
|
|
187
|
+
source: loadPreviewTemplate().replaceAll("${blockSlug}", block.slug)
|
|
181
188
|
};
|
|
182
189
|
}
|
|
183
190
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saacms/host-astro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@saacms/core": "0.1.
|
|
28
|
+
"@saacms/core": "0.1.6"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"astro": "^4.0.0 || ^5.0.0"
|