@dosgato/templating 0.0.143 → 0.0.145

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.
@@ -91,6 +91,37 @@ export interface APITemplate<DataType> {
91
91
  * can be done by the routine that calls `getFulltext`.
92
92
  */
93
93
  getFulltext?: FulltextGatheringFn<DataType>;
94
+ /**
95
+ * Extra filters for this template
96
+ *
97
+ * Use this function to return arbitrary tags for your template. These tags will be indexed
98
+ * and may be used later as a search filter.
99
+ *
100
+ * For example, pages may set a 'shownInNav' tag and this could be passed to the getNavigation
101
+ * function during rendering to return a smaller set of pages for navigation.
102
+ */
103
+ getTags?: FulltextGatheringFn<DataType>;
104
+ /**
105
+ * Copying components around is a core feature in DosGato, but sometimes the data stored
106
+ * is not suitable for copying, for example unique identifiers generated by FieldIdentifier
107
+ * should be regenerated during a copy.
108
+ *
109
+ * Provide this function to do work like that. It will only be called when content is being
110
+ * copied, i.e. the original still exists.
111
+ *
112
+ * The pageCopy parameter will be true when an entire page is being copied, and false when a
113
+ * component or data entry is being copied. Sometimes you will want to behave differently in
114
+ * those cases. For instance, if you generate a unique id and then make references to it on
115
+ * the same page, you would not want to regenerate those ids during a full page copy because
116
+ * all the references would break, but you would want to regenerate id on an in-page copy
117
+ * because you need new ids for the new objects.
118
+ *
119
+ * workspace is an initially empty object that onCopy methods from various components can use
120
+ * as shared memory. You would need this to do something like regenerating ids and also
121
+ * updating references. You would keep a map of original id -> new id in workspace.mynamespace
122
+ * and set it any time you encounter an id or reference.
123
+ */
124
+ onCopy?: (data: DataType, pageCopy: boolean, workspace: Record<string, any>) => void;
94
125
  /**
95
126
  * The available component list in the main content area can get very long, among others. Therefore, each
96
127
  * template may set a displayCategory and any templates that share a displayCategory will be grouped together
package/dist/provider.js CHANGED
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * If you do this, don't forget to register the provider along with your templates!
10
10
  */
11
- class ResourceProvider {
11
+ export class ResourceProvider {
12
12
  static webpath(name) { return this.webpaths.get(name); }
13
13
  }
14
14
  /**
@@ -86,4 +86,3 @@ ResourceProvider.files = new Map();
86
86
  * `<img src="${TemplateClass.webpath('keyname')}">`
87
87
  */
88
88
  ResourceProvider.webpaths = new Map();
89
- export { ResourceProvider };
package/dist/render.d.ts CHANGED
@@ -282,6 +282,29 @@ export interface APIClient {
282
282
  * The `href` property in the returned records should be an absolute URL.
283
283
  */
284
284
  absolute?: boolean;
285
+ /**
286
+ * Set a filter to use while building the navigation tree, to limit the amount of pages
287
+ * returned.
288
+ *
289
+ * For example, if pages have a `hideInNav` property, you could check that here to avoid
290
+ * returning pages that are supposed to be hidden.
291
+ *
292
+ * You could always do this yourself after getting the full results, but it will improve
293
+ * performance to do it earlier.
294
+ */
295
+ filter?: (page: PageForNavigation) => boolean | undefined;
296
+ /**
297
+ * Filter for a specific tag as returned by the template's getTags function in the API
298
+ * template definition.
299
+ */
300
+ tagsAny?: string[];
301
+ /**
302
+ * Set a maximum number of children to be displayed in the menu per page.
303
+ *
304
+ * For instance, if you set it to 8, no page returned will have more than 8 children. Page
305
+ * order will determine which 8 make the cut.
306
+ */
307
+ maxChildren?: number;
285
308
  }) => Promise<PageForNavigation[]>;
286
309
  /**
287
310
  * Get data entries by link or folder link
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.143",
3
+ "version": "0.0.145",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {