@dosgato/templating 0.0.43 → 0.0.46

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.
@@ -69,7 +69,7 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
69
69
  * The inherited components will be added to the appropriate area's array in the renderedAreas
70
70
  * parameter of your render function.
71
71
  */
72
- registerInherited: (area: string, components: ComponentData[], top?: true) => void;
72
+ registerInherited: (area: string, components: ComponentData[], fromPageId: string, top?: true) => void;
73
73
  /**
74
74
  * The second phase of rendering a component is the context phase. This step is TOP-DOWN and
75
75
  * NON-MUTATING. Each component will receive the parent component's context and then pass a
@@ -131,12 +131,12 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
131
131
  *
132
132
  * For instance, you could return this.data.title
133
133
  */
134
- editLabel(): undefined;
134
+ editLabel(): string | undefined;
135
135
  /**
136
136
  * Components may override this function to give their edit bars a custom
137
137
  * CSS class
138
138
  */
139
- editClass(): undefined;
139
+ editClass(): string | undefined;
140
140
  /**
141
141
  * Components may override this function to give their new bars a custom
142
142
  * label
@@ -144,12 +144,12 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
144
144
  * For instance, an area that only accepts 'layout' components could
145
145
  * return "Add Layout"
146
146
  */
147
- newLabel(areaName: string): undefined;
147
+ newLabel(areaName: string): string | undefined;
148
148
  /**
149
149
  * Components may override this function to give their new bars a custom
150
150
  * CSS class
151
151
  */
152
- newClass(areaName: string): undefined;
152
+ newClass(areaName: string): string | undefined;
153
153
  /**
154
154
  * Components may override this function to provide a custom edit bar
155
155
  *
@@ -180,7 +180,6 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
180
180
  renderedAreas: Map<string, RenderedComponent[]>;
181
181
  hadError: boolean;
182
182
  autoLabel: string;
183
- autoNewLabel: string;
184
183
  /**
185
184
  * For logging errors during rendering without crashing the render. If your fetch, setContext,
186
185
  * render, or renderVariation functions throw, the error will be logged but the page render will
package/dist/component.js CHANGED
@@ -152,7 +152,7 @@ export class Component extends ResourceProvider {
152
152
  * Generally should not be overridden - override newLabel and newClass instead
153
153
  */
154
154
  newBar(areaName, opts = {}) {
155
- opts.label ?? (opts.label = this.newLabel(areaName) ?? this.autoNewLabel);
155
+ opts.label ?? (opts.label = this.newLabel(areaName) ?? (this.areas.size > 1 ? `Add ${areaName} Content` : `Add ${this.autoLabel} Content`));
156
156
  opts.extraClass ?? (opts.extraClass = this.newClass(areaName));
157
157
  opts.editMode ?? (opts.editMode = this.editMode);
158
158
  opts.inheritedFrom ?? (opts.inheritedFrom = this.inheritedFrom);
package/dist/render.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ContextBase, DataData, PageData, PageRecord } from './component.js';
2
- import { AssetLink, DataFolderLink, DataLink, LinkDefinition } from './links.js';
2
+ import { AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js';
3
3
  export declare function printHeader(ctx: ContextBase, content: string): string;
4
4
  export declare function advanceHeader(ctx: ContextBase, content?: string): {
5
5
  headerLevel: number;
@@ -69,20 +69,21 @@ export interface APIClient {
69
69
  *
70
70
  * Will be dataloaded.
71
71
  */
72
- getPageData: ({ id, path }: {
72
+ getPage: ({ id, path, link }: {
73
73
  id?: string;
74
74
  path?: string;
75
- }) => Promise<PageData>;
75
+ link?: string | PageLink;
76
+ }) => Promise<PageRecord<PageData>>;
76
77
  /** Get all ancestor pages of a specific page. First array element will be the pagetree root page. */
77
78
  getAncestors: ({ id, path }: {
78
79
  id?: string;
79
80
  path?: string;
80
- }) => Promise<PageRecord[]>;
81
+ }) => Promise<PageRecord<PageData>[]>;
81
82
  /** Get the pagetree root page from which the specified page descends. */
82
- getRootPageData: ({ id, path }: {
83
+ getRootPage: ({ id, path }: {
83
84
  id?: string;
84
85
  path?: string;
85
- }) => Promise<PageData>;
86
+ }) => Promise<PageRecord<PageData>>;
86
87
  /**
87
88
  * Get data entries by link or folder link
88
89
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.43",
3
+ "version": "0.0.46",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {