@frontman-ai/astro 0.2.4 → 0.4.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/toolbar.js CHANGED
@@ -43,14 +43,29 @@ function getOr(opt, $$default2) {
43
43
  return $$default2;
44
44
  }
45
45
  }
46
+
47
+ // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Null.js
48
+ function flatMap(value, f) {
49
+ if (value !== null) {
50
+ return f(value);
51
+ } else {
52
+ return null;
53
+ }
54
+ }
55
+ var defaultBasePath = "frontman";
56
+ function _getBasePath() {
57
+ return getOr(fromNull(flatMap(document.querySelector(`meta[name="frontman-base-path"]`), (el) => el.getAttribute("content"))), defaultBasePath);
58
+ }
46
59
  function app_init(_canvas, app2, _server) {
47
60
  app2.onToggled((param) => {
48
61
  if (!param.state) {
49
62
  return;
50
63
  }
51
- let meta = document.querySelector(`meta[name="frontman-base-path"]`);
52
- let basePath = meta !== null ? getOr(fromNull(meta.getAttribute("content")), "frontman") : "frontman";
53
- window.location.assign(`/` + basePath + `/`);
64
+ let basePath = _getBasePath();
65
+ let pathname = location.pathname.replace(/\/$/, "");
66
+ let alreadyInFrontman = pathname === `/` + basePath || pathname.endsWith(`/` + basePath);
67
+ let url = alreadyInFrontman ? pathname : pathname === "" ? `/` + basePath : pathname + `/` + basePath;
68
+ window.location.assign(url);
54
69
  app2.toggleState({
55
70
  state: false
56
71
  });
@@ -60,6 +75,5 @@ var app = {
60
75
  init: app_init
61
76
  };
62
77
  var $$default = Toolbar.defineToolbarApp(app);
63
- var Bindings;
64
78
 
65
- export { Bindings, app, $$default as default };
79
+ export { _getBasePath, app, $$default as default, defaultBasePath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontman-ai/astro",
3
- "version": "0.2.4",
3
+ "version": "0.4.1",
4
4
  "description": "Astro integration for Frontman",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Frontman AI",