@dosgato/templating 1.1.9 → 1.1.11
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/component.d.ts +11 -4
- package/dist/component.js +14 -5
- package/dist/render.d.ts +15 -3
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -211,20 +211,27 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
211
211
|
* render of the parent component.
|
|
212
212
|
*/
|
|
213
213
|
abstract render(): string;
|
|
214
|
+
/**
|
|
215
|
+
* If you are rendering a variation for a component that has areas and children,
|
|
216
|
+
* you can call Component.renderVariation(extension, this.renderedAreas) to help you easily
|
|
217
|
+
* render the areas and children inside whatever wrapper content you need.
|
|
218
|
+
*/
|
|
219
|
+
static renderVariation(extension: string, renderedAreas: Map<string, RenderedComponent[]>): string;
|
|
214
220
|
/**
|
|
215
221
|
* Sometimes pages are requested with an alternate extension like .rss or .ics. In these
|
|
216
222
|
* situations, each component should consider whether it should output anything. For
|
|
217
223
|
* instance, if the extension is .rss and a component represents an article, it should
|
|
218
224
|
* probably output an RSS item. If you don't recognize the extension, just return
|
|
219
|
-
*
|
|
225
|
+
* Component.renderVariation(extension, this.renderedAreas) to give your child components a chance to
|
|
220
226
|
* respond, or return empty string if you want your child components to be silent in all
|
|
221
227
|
* cases.
|
|
222
228
|
*
|
|
229
|
+
* If you implement this function to add content for a specific extension, you should also
|
|
230
|
+
* probably override `shouldFetchVariation` to return true for that extension. Also remember
|
|
231
|
+
* to use Component.renderVariation(extension, this.renderedAreas) to render your child components.
|
|
232
|
+
*
|
|
223
233
|
* The extension will NOT include the preceding dot. In the case of an extended extension like
|
|
224
234
|
* '.js.map', you will receive 'js.map'.
|
|
225
|
-
*
|
|
226
|
-
* This function will be run after the fetch phase. The context and html rendering phases
|
|
227
|
-
* will be skipped.
|
|
228
235
|
*/
|
|
229
236
|
renderVariation(extension: string): string;
|
|
230
237
|
/**
|
package/dist/component.js
CHANGED
|
@@ -85,23 +85,32 @@ export class Component extends ResourceProvider {
|
|
|
85
85
|
setContext(renderCtxFromParent, areaName) {
|
|
86
86
|
return renderCtxFromParent;
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* If you are rendering a variation for a component that has areas and children,
|
|
90
|
+
* you can call Component.renderVariation(extension, this.renderedAreas) to help you easily
|
|
91
|
+
* render the areas and children inside whatever wrapper content you need.
|
|
92
|
+
*/
|
|
93
|
+
static renderVariation(extension, renderedAreas) {
|
|
94
|
+
return Array.from(renderedAreas.values()).flatMap(ras => ras.map(ra => ra.output)).join('');
|
|
95
|
+
}
|
|
88
96
|
/**
|
|
89
97
|
* Sometimes pages are requested with an alternate extension like .rss or .ics. In these
|
|
90
98
|
* situations, each component should consider whether it should output anything. For
|
|
91
99
|
* instance, if the extension is .rss and a component represents an article, it should
|
|
92
100
|
* probably output an RSS item. If you don't recognize the extension, just return
|
|
93
|
-
*
|
|
101
|
+
* Component.renderVariation(extension, this.renderedAreas) to give your child components a chance to
|
|
94
102
|
* respond, or return empty string if you want your child components to be silent in all
|
|
95
103
|
* cases.
|
|
96
104
|
*
|
|
105
|
+
* If you implement this function to add content for a specific extension, you should also
|
|
106
|
+
* probably override `shouldFetchVariation` to return true for that extension. Also remember
|
|
107
|
+
* to use Component.renderVariation(extension, this.renderedAreas) to render your child components.
|
|
108
|
+
*
|
|
97
109
|
* The extension will NOT include the preceding dot. In the case of an extended extension like
|
|
98
110
|
* '.js.map', you will receive 'js.map'.
|
|
99
|
-
*
|
|
100
|
-
* This function will be run after the fetch phase. The context and html rendering phases
|
|
101
|
-
* will be skipped.
|
|
102
111
|
*/
|
|
103
112
|
renderVariation(extension) {
|
|
104
|
-
return
|
|
113
|
+
return Component.renderVariation(extension, this.renderedAreas);
|
|
105
114
|
}
|
|
106
115
|
/**
|
|
107
116
|
* helper function to print an area's component list, but you can also override this if you
|
package/dist/render.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContextBase, DataRecord, PageData, PageRecord, PageRecordNoData,
|
|
1
|
+
import type { ContextBase, DataRecord, PageData, PageRecord, PageRecordNoData, SiteInfo } from './component.js';
|
|
2
2
|
import type { AssetFolderLink, AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js';
|
|
3
3
|
/**
|
|
4
4
|
* Safely encapsulates `content` in header tags based on the `ctx` context passed and adds any passed `attributes` to the header tagging.
|
|
@@ -134,7 +134,13 @@ export interface APIClient {
|
|
|
134
134
|
* broken, but if a site has launch info that is simply disabled, getHref will still work. Any links generated
|
|
135
135
|
* would work as soon as the launch info is enabled.
|
|
136
136
|
*/
|
|
137
|
-
getHref: (page:
|
|
137
|
+
getHref: (page: {
|
|
138
|
+
path: string;
|
|
139
|
+
site: SiteInfo;
|
|
140
|
+
pagetree: {
|
|
141
|
+
id: string;
|
|
142
|
+
};
|
|
143
|
+
}, opts?: {
|
|
138
144
|
absolute?: boolean;
|
|
139
145
|
extension?: string;
|
|
140
146
|
}) => string | undefined;
|
|
@@ -151,7 +157,13 @@ export interface APIClient {
|
|
|
151
157
|
* Based on that boolean, components can be configured to render a shiny red warning message in edit mode
|
|
152
158
|
* so that editors can quickly identify broken links on their pages.
|
|
153
159
|
*/
|
|
154
|
-
getHrefPlus: (page:
|
|
160
|
+
getHrefPlus: (page: {
|
|
161
|
+
path: string;
|
|
162
|
+
site: SiteInfo;
|
|
163
|
+
pagetree: {
|
|
164
|
+
id: string;
|
|
165
|
+
};
|
|
166
|
+
}, opts?: {
|
|
155
167
|
absolute?: boolean;
|
|
156
168
|
extension?: string;
|
|
157
169
|
}) => {
|