@dosgato/templating 1.0.9 → 1.1.0
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/apitemplate.d.ts +15 -3
- package/dist/component.d.ts +6 -3
- package/dist/component.js +12 -5
- package/package.json +1 -1
package/dist/apitemplate.d.ts
CHANGED
|
@@ -34,15 +34,27 @@ export interface PageExtras {
|
|
|
34
34
|
linkId?: string;
|
|
35
35
|
/** The name the page has or will have. NOTE: looking the page up by name will not work during page creation. */
|
|
36
36
|
name: string;
|
|
37
|
+
/**
|
|
38
|
+
* The full page data before the validation/migration in case validating depends on the previous
|
|
39
|
+
* state of the page.
|
|
40
|
+
*
|
|
41
|
+
* Will be undefined during page creations, and equal to the data already being passed to a migration.
|
|
42
|
+
*/
|
|
43
|
+
page?: PageData;
|
|
37
44
|
}
|
|
38
45
|
export interface ComponentExtras extends PageExtras {
|
|
46
|
+
/** The path within the page data to the component currently being evaluated. */
|
|
47
|
+
path: string;
|
|
39
48
|
/**
|
|
40
|
-
* The full page data in case validating
|
|
49
|
+
* The full page data before the validation/migration in case validating depends on state
|
|
41
50
|
* elsewhere in the page.
|
|
42
51
|
*/
|
|
43
52
|
page: PageData;
|
|
44
|
-
/**
|
|
45
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The component data before validation. Will be present during migration but equal to the
|
|
55
|
+
* data already being passed to the migration.
|
|
56
|
+
*/
|
|
57
|
+
currentData: ComponentData;
|
|
46
58
|
}
|
|
47
59
|
export interface DataExtras {
|
|
48
60
|
/** A function for executing a graphql query to acquire more information than is already at hand. */
|
package/dist/component.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import type { IncomingHttpHeaders } from 'http';
|
|
4
2
|
import type { ParsedUrlQuery } from 'querystring';
|
|
5
3
|
import { ResourceProvider } from './provider.js';
|
|
@@ -89,7 +87,7 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
89
87
|
* The extension will NOT include the preceding dot. In the case of an extended extension like
|
|
90
88
|
* '.js.map', you should receive 'js.map'.
|
|
91
89
|
*/
|
|
92
|
-
shouldFetchVariation(extension: string):
|
|
90
|
+
shouldFetchVariation(extension: string): extension is "html";
|
|
93
91
|
/**
|
|
94
92
|
* Some components may be inheritable to subpages within the same site. For instance, a site's
|
|
95
93
|
* social media links may appear on every page's footer. To accomplish this in your template,
|
|
@@ -280,6 +278,11 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
280
278
|
* Its edit bar will not have a pencil icon.
|
|
281
279
|
*/
|
|
282
280
|
noData: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Override with `true` to indicate that this template renders its own edit bar
|
|
283
|
+
* so that the parent component will avoid rendering it
|
|
284
|
+
*/
|
|
285
|
+
renderIncludesEditBar: boolean;
|
|
283
286
|
/**
|
|
284
287
|
* Components may override this function to give their new bars a custom
|
|
285
288
|
* label
|
package/dist/component.js
CHANGED
|
@@ -122,11 +122,13 @@ export class Component extends ResourceProvider {
|
|
|
122
122
|
return opts.skipContent ? '' : wrap({ ...c, content: c.output, bar: '', indexInArea, siblings });
|
|
123
123
|
}
|
|
124
124
|
else {
|
|
125
|
-
const bar = c.component.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
const bar = c.component.renderIncludesEditBar
|
|
126
|
+
? ''
|
|
127
|
+
: c.component.editBar({
|
|
128
|
+
...opts?.editBarOpts,
|
|
129
|
+
label: typeof opts?.editBarOpts?.label === 'function' ? opts.editBarOpts.label(c.component) : opts?.editBarOpts?.label,
|
|
130
|
+
extraClass: typeof opts?.editBarOpts?.extraClass === 'function' ? opts.editBarOpts.extraClass(c.component) : opts?.editBarOpts?.extraClass
|
|
131
|
+
});
|
|
130
132
|
const content = opts?.skipContent ? '' : c.output;
|
|
131
133
|
return wrap({ output: bar + content, content, bar, component: c.component, indexInArea, siblings });
|
|
132
134
|
}
|
|
@@ -245,6 +247,11 @@ export class Component extends ResourceProvider {
|
|
|
245
247
|
* Its edit bar will not have a pencil icon.
|
|
246
248
|
*/
|
|
247
249
|
this.noData = false;
|
|
250
|
+
/**
|
|
251
|
+
* Override with `true` to indicate that this template renders its own edit bar
|
|
252
|
+
* so that the parent component will avoid rendering it
|
|
253
|
+
*/
|
|
254
|
+
this.renderIncludesEditBar = false;
|
|
248
255
|
// Properties provided during the rendering process. You do not have to provide these when
|
|
249
256
|
// building a template, but you can use them in the functions you do provide
|
|
250
257
|
this.areas = new Map(); // a Map of area names and the array of hydrated components in each
|