@dosgato/templating 0.0.7 → 0.0.10

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.
@@ -1,4 +1,3 @@
1
- import { Page } from './page';
2
1
  import { ResourceProvider } from './provider';
3
2
  /**
4
3
  * This is the primary templating class to build your templates. Subclass it and provide
@@ -100,7 +99,7 @@ export interface PageWithAncestors<DataType extends PageData = PageData> extends
100
99
  }
101
100
  export interface ComponentData {
102
101
  templateKey: string;
103
- areas: Record<string, ComponentData[]>;
102
+ areas?: Record<string, ComponentData[]>;
104
103
  }
105
104
  export interface PageData extends ComponentData {
106
105
  savedAtVersion: Date;
@@ -117,3 +116,15 @@ export interface ContextBase {
117
116
  */
118
117
  headerLevel: number;
119
118
  }
119
+ export declare abstract class Page<DataType extends PageData = any, FetchedType = any, RenderContextType extends ContextBase = any> extends Component<DataType, FetchedType, RenderContextType> {
120
+ pagePath: string;
121
+ ancestors: PageRecord[];
122
+ /**
123
+ * we will fill this before rendering, stuff that dosgato knows needs to be added to
124
+ * the <head> element
125
+ * the page's render function must include it
126
+ */
127
+ headContent: string;
128
+ protected passError(e: Error, path: string): void;
129
+ constructor(page: PageWithAncestors<DataType>);
130
+ }
package/dist/component.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Component = void 0;
4
- const page_1 = require("./page");
3
+ exports.Page = exports.Component = void 0;
5
4
  const provider_1 = require("./provider");
6
5
  /**
7
6
  * This is the primary templating class to build your templates. Subclass it and provide
@@ -25,9 +24,9 @@ class Component extends provider_1.ResourceProvider {
25
24
  this.path = path;
26
25
  this.hadError = false;
27
26
  let tmpParent = (_a = this.parent) !== null && _a !== void 0 ? _a : this;
28
- while (!(tmpParent instanceof page_1.Page) && tmpParent.parent)
27
+ while (!(tmpParent instanceof Page) && tmpParent.parent)
29
28
  tmpParent = tmpParent.parent;
30
- if (!(tmpParent instanceof page_1.Page))
29
+ if (!(tmpParent instanceof Page))
31
30
  throw new Error('Hydration failed, could not map component back to its page.');
32
31
  this.page = tmpParent;
33
32
  }
@@ -113,3 +112,14 @@ class Component extends provider_1.ResourceProvider {
113
112
  }
114
113
  }
115
114
  exports.Component = Component;
115
+ class Page extends Component {
116
+ constructor(page) {
117
+ super(page.data, '/', undefined);
118
+ this.pagePath = page.path;
119
+ this.ancestors = page.ancestors;
120
+ }
121
+ passError(e, path) {
122
+ console.warn(`Recoverable issue occured during render of ${this.pagePath}. Component at ${path} threw the following error:`, e);
123
+ }
124
+ }
125
+ exports.Page = Page;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './apitemplate';
2
2
  export * from './component';
3
3
  export * from './links';
4
- export * from './page';
5
4
  export * from './provider';
package/dist/index.js CHANGED
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./apitemplate"), exports);
18
18
  __exportStar(require("./component"), exports);
19
19
  __exportStar(require("./links"), exports);
20
- __exportStar(require("./page"), exports);
21
20
  __exportStar(require("./provider"), exports);
package/dist/links.d.ts CHANGED
@@ -7,9 +7,8 @@ export interface AssetLink {
7
7
  type: 'asset';
8
8
  source: string;
9
9
  id: string;
10
- siteId: string;
11
- path: string;
12
- checksum: string;
10
+ path?: string;
11
+ checksum?: string;
13
12
  }
14
13
  /**
15
14
  * Some components (e.g. document list) can point at a folder instead of individual
@@ -20,7 +19,6 @@ export interface AssetFolderLink {
20
19
  type: 'assetfolder';
21
20
  source: string;
22
21
  id: string;
23
- siteId: string;
24
22
  path: string;
25
23
  }
26
24
  /**
@@ -29,7 +27,6 @@ export interface AssetFolderLink {
29
27
  export interface PageLink {
30
28
  type: 'page';
31
29
  linkId: string;
32
- siteId: string;
33
30
  path: string;
34
31
  }
35
32
  /**
@@ -50,8 +47,9 @@ export interface WebLink {
50
47
  */
51
48
  export interface DataLink {
52
49
  type: 'data';
50
+ templateKey: string;
53
51
  id: string;
54
- siteId: string | null;
52
+ siteId?: string;
55
53
  path: string;
56
54
  }
57
55
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.7",
3
+ "version": "0.0.10",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "exports": {
6
6
  "require": "./dist/index.js",
package/dist/page.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import { PageData, ContextBase, Component, PageRecord, PageWithAncestors } from './component';
2
- export declare abstract class Page<DataType extends PageData = any, FetchedType = any, RenderContextType extends ContextBase = any> extends Component<DataType, FetchedType, RenderContextType> {
3
- pagePath: string;
4
- ancestors: PageRecord[];
5
- /**
6
- * we will fill this before rendering, stuff that dosgato knows needs to be added to
7
- * the <head> element
8
- * the page's render function must include it
9
- */
10
- headContent: string;
11
- protected passError(e: Error, path: string): void;
12
- constructor(page: PageWithAncestors<DataType>);
13
- }
package/dist/page.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Page = void 0;
4
- const component_1 = require("./component");
5
- class Page extends component_1.Component {
6
- constructor(page) {
7
- super(page.data, '/', undefined);
8
- this.pagePath = page.path;
9
- this.ancestors = page.ancestors;
10
- }
11
- passError(e, path) {
12
- console.warn(`Recoverable issue occured during render of ${this.pagePath}. Component at ${path} threw the following error:`, e);
13
- }
14
- }
15
- exports.Page = Page;