@dosgato/templating 0.0.112 → 0.0.114

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.
@@ -80,6 +80,17 @@ export interface APITemplate<DataType> {
80
80
  * by this function will also be scanned for links.
81
81
  */
82
82
  getFulltext?: FulltextGatheringFn<DataType>;
83
+ /**
84
+ * The available component list in the main content area can get very long, among others. Therefore, each
85
+ * template may set a displayCategory and any templates that share a displayCategory will be grouped together
86
+ * underneath one tab when a user is presented with a choice of template.
87
+ *
88
+ * If a displayCategory is not set, there will be a default category like 'Standard'. If only one category
89
+ * exists for a group of available components, the tabs will not be shown at all. This means you do not have
90
+ * to bother setting displayCategory for minor cases like different kinds of slides in a slider (until there
91
+ * are so many that it becomes a good idea!).
92
+ */
93
+ displayCategory?: string;
83
94
  }
84
95
  export interface APIComponentTemplate<DataType extends ComponentData = any> extends APITemplate<DataType> {
85
96
  type: 'component';
@@ -136,6 +147,20 @@ export interface APIPageTemplate<DataType extends PageData = any> extends APITem
136
147
  * Must be null for non-page templates.
137
148
  */
138
149
  templateProperties?: any;
150
+ /**
151
+ * Container components specify their own list of compatible templates for each of their areas,
152
+ * but it is possible that a sub-component could be compatible with its container while not really
153
+ * being compatible with the template as a whole. For instance, a special purpose template may want
154
+ * to allow containers but only a couple simple components inside those containers.
155
+ *
156
+ * Without this property, the only choice would be to re-make all your container components with a special
157
+ * templateKey just for this page template and their custom set of availableComponents. That's a lot to maintain,
158
+ * so this property is available to disallow sub-components at the page template level.
159
+ *
160
+ * Any template key you list here will be unavailable inside this page template, no matter how many
161
+ * nested containers are in between.
162
+ */
163
+ disallowComponents?: string[];
139
164
  }
140
165
  export interface APIDataTemplate<DataType extends DataData = any> extends APITemplate<DataType> {
141
166
  type: 'data';
package/dist/render.d.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  import { ContextBase, DataData, PageData, PageRecord, PageRecordOptionalData } from './component.js';
2
2
  import { AssetFolderLink, AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js';
3
+ /**
4
+ * Safely encapsulates `content` in header tags based on the `ctx` context passed and adds any passed `attributes` to the header tagging.
5
+ * If the headerLevel passed through `ctx` is outside the range of 1..6 the header tag generated is normalized to the nearest value of 1 or 6.
6
+ * @returns An empty string if content is blank, undefined, or null - else an h<1..6> encapsulated content with attributes added to the encapsulating tag.
7
+ * @example ```
8
+ * printHeader(this.renderCtx, htmlEncode(this.data.title), {class: 'some-extra-cssclass'})
9
+ * // Renders: '<h1 class="some-extra-cssclass">Title</h1>'
10
+ * ``` */
3
11
  export declare function printHeader(ctx: ContextBase, content: string | undefined | null, attributes?: Record<string, string>): string;
4
12
  export declare function advanceHeader<T extends ContextBase>(ctx: T, content: string | undefined | null): T;
5
13
  export interface PictureResize {
@@ -150,17 +158,50 @@ export interface APIClient {
150
158
  path?: string;
151
159
  }) => Promise<PageRecord<PageData>>;
152
160
  /**
153
- * Get a hierarchical tree of pages suitable for generating a navigation
154
- * UI for your template.
161
+ * Get a hierarchical tree of pages suitable for generating a navigation UI for your template.
155
162
  *
156
- * Returns the root page(s). Subpages are inside the `children` property.
157
- */
163
+ * Each element in the array is recursive such that any subpage descendants can be found by
164
+ * traversing each element's respective `children` property.
165
+ *
166
+ * @param opts
167
+ * ```
168
+ * { // Return pages beneath this path but not the page that is this path.
169
+ // If `undefined` you will get back a single element array that
170
+ // references the `PageForNaviation` of the root page of the pageTree.
171
+ beneath? string
172
+
173
+ // Relative to `beneath` this controls how many levels deep to fetch past
174
+ // the top level set of results in the array. 0 returns the top level only
175
+ // while n > 0 traverses n levels of children deep past the top level
176
+ // results. Leave `undefined` to fetch all.
177
+ depth?: number
178
+
179
+ // Set to true to filter for only pages that are published. Else the default
180
+ // of false will automatically not filter unpublished pages when in edit or
181
+ // preview mode but will filter if in published mode.
182
+ // WARNING:
183
+ // If none of the pages in the current pageTree have been published and this is
184
+ // set to `true` an error will be thrown as there will be no pages to return.
185
+ published?: boolean
186
+
187
+ // Array of strings that specify dot-separated object paths describing page
188
+ // data not normally fetched within the PageForNavigation results. For example,
189
+ // ['hideInNav'] would append the page record hideInNav value to the
190
+ // `PageForNavigation.extra` property as its own sub-property `hideInNav` that
191
+ // would normally be excluded from the `PageForNavigation` properties.
192
+ extra?: string[]
193
+
194
+ // Whether the href property in the returned records should be an absolute URL.
195
+ absolute?: boolean
196
+ }
197
+ ``` */
158
198
  getNavigation: (opts?: {
159
199
  /**
160
200
  * Return pages beneath this path
161
201
  *
162
202
  * For instance, if you set this to '/site1' you will get back ['/site1/about',
163
- * '/site1/history', '/site1/history/traditions', ...etc]
203
+ * '/site1/history', '/site1/history/traditions', ...etc] but you will NOT get
204
+ * back the '/site1' page.
164
205
  *
165
206
  * If you do not set `beneath`, you will get back an array that contains only
166
207
  * the root page of the pagetree you are in.
@@ -193,8 +234,8 @@ export interface APIClient {
193
234
  * transfer, but if you need some of the data, you can specify an array of dot-separated
194
235
  * paths to retrieve from it.
195
236
  *
196
- * For example, ['hideInNav'] would get you { extra: { hideInNav: tru } } in each returned
197
- * page record.
237
+ * For example, ['hideInNav'] would get you the additional property `extra.hideInNav` in
238
+ * each returned page record.
198
239
  */
199
240
  extra?: string[];
200
241
  /**
package/dist/render.js CHANGED
@@ -1,4 +1,12 @@
1
1
  import { htmlEncode, isBlank, isNotEmpty } from 'txstate-utils';
2
+ /**
3
+ * Safely encapsulates `content` in header tags based on the `ctx` context passed and adds any passed `attributes` to the header tagging.
4
+ * If the headerLevel passed through `ctx` is outside the range of 1..6 the header tag generated is normalized to the nearest value of 1 or 6.
5
+ * @returns An empty string if content is blank, undefined, or null - else an h<1..6> encapsulated content with attributes added to the encapsulating tag.
6
+ * @example ```
7
+ * printHeader(this.renderCtx, htmlEncode(this.data.title), {class: 'some-extra-cssclass'})
8
+ * // Renders: '<h1 class="some-extra-cssclass">Title</h1>'
9
+ * ``` */
2
10
  export function printHeader(ctx, content, attributes) {
3
11
  if (isBlank(content))
4
12
  return '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.112",
3
+ "version": "0.0.114",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {