@dosgato/templating 0.0.35 → 0.0.38

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.
@@ -192,11 +192,11 @@ export declare type GraphQLQueryFn = <T>(query: string, variables?: any) => Prom
192
192
  * This function is used by API template definitions to help them identify links inside large blocks
193
193
  * of text and return them for indexing.
194
194
  */
195
- export declare function extractLinksFromText(text: string): LinkDefinition[];
195
+ export declare function extractLinksFromText(text: string | undefined): LinkDefinition[];
196
196
  /**
197
197
  * This function is used by API template definitions to help them identify all the searchable
198
198
  * words in a large block of text and return them for indexing.
199
199
  */
200
- export declare function getKeywords(text: string, options?: {
200
+ export declare function getKeywords(text?: string, options?: {
201
201
  stopwords?: boolean;
202
202
  }): string[];
@@ -10,6 +10,8 @@ export var ValidationMessageType;
10
10
  * of text and return them for indexing.
11
11
  */
12
12
  export function extractLinksFromText(text) {
13
+ if (!text)
14
+ return [];
13
15
  const matches = text.matchAll(/{.*"type"\s?:\s+"\w+".*?}/gi);
14
16
  return Array.from(matches).map(m => JSON.parse(m[0]));
15
17
  }
@@ -18,6 +20,8 @@ export function extractLinksFromText(text) {
18
20
  * words in a large block of text and return them for indexing.
19
21
  */
20
22
  export function getKeywords(text, options) {
23
+ if (!text)
24
+ return [];
21
25
  return Array.from(new Set(text
22
26
  .toLocaleLowerCase()
23
27
  .normalize('NFD').replace(/\p{Diacritic}/gu, '')
@@ -171,11 +171,11 @@ export interface ComponentData {
171
171
  areas?: Record<string, ComponentData[]>;
172
172
  }
173
173
  export interface PageData extends ComponentData {
174
- savedAtVersion: Date;
174
+ savedAtVersion: string;
175
175
  }
176
176
  export interface DataData {
177
177
  templateKey: string;
178
- savedAtVersion: Date;
178
+ savedAtVersion: string;
179
179
  }
180
180
  export interface ContextBase {
181
181
  /**
package/dist/component.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { isNotBlank } from 'txstate-utils';
1
2
  import { editBar, newBar } from './editbar.js';
2
3
  import { ResourceProvider } from './provider.js';
3
4
  /**
@@ -160,12 +161,12 @@ export class Component extends ResourceProvider {
160
161
  newBar(areaName, opts = {}) {
161
162
  opts.label ?? (opts.label = this.newLabel(areaName));
162
163
  opts.extraClass ?? (opts.extraClass = this.newClass(areaName));
163
- return newBar(this.path + '.' + areaName, opts);
164
+ return newBar([this.path, 'areas', areaName].filter(isNotBlank).join('.'), opts);
164
165
  }
165
166
  }
166
167
  export class Page extends Component {
167
168
  constructor(page) {
168
- super(page.data, '/', undefined);
169
+ super(page.data, '', undefined);
169
170
  this.pagePath = page.path;
170
171
  }
171
172
  passError(e, path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.35",
3
+ "version": "0.0.38",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {