@dosgato/templating 0.0.131 → 0.0.133

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.
@@ -168,7 +168,9 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
168
168
  * method to prepare editor-provided HTML for later rendering. It will do things like find and
169
169
  * resolve link definitions in the internal dosgato format.
170
170
  */
171
- fetchRichText: (html: string | undefined) => Promise<void>;
171
+ fetchRichText: (html: string | undefined, opts?: {
172
+ absolute?: boolean;
173
+ }) => Promise<void>;
172
174
  /**
173
175
  * This function will be provided by the rendering server and should be used during the render
174
176
  * phase to clean up editor-provided HTML. It will do things like clean up tags that were accidentally
package/dist/component.js CHANGED
@@ -286,7 +286,7 @@ export class Page extends Component {
286
286
  * Get a URL for the current page with a different extension
287
287
  */
288
288
  variationUrl(extension) {
289
- return `${this.url.replace(/\.\w+$/, '')}.${extension}`;
289
+ return (this.url === '/' ? '/.root' : this.url.replace(/\.[^/]+$/, '')) + '.' + extension;
290
290
  }
291
291
  passError(e, path) {
292
292
  console.warn(`Recoverable issue occured during render of ${this.pageInfo.path}. Component at ${path} threw the following error:`, e);
package/dist/render.d.ts CHANGED
@@ -106,16 +106,22 @@ export interface APIClient {
106
106
  extension?: string;
107
107
  }) => Promise<string | undefined>;
108
108
  /**
109
- * Exactly like resolveLink but also returns the title of the target page, if the target page
110
- * is internal to the CMS. If the target is a random web page outside the CMS, title will be
111
- * undefined. Perhaps in the future title could be scraped from the page HTML.
109
+ * Exactly like resolveLink but also returns more data.
110
+ *
111
+ * First, the title of the target page, if the target page is internal to the CMS. If the
112
+ * target is a random web page outside the CMS, title will be undefined. Perhaps in the future
113
+ * title could be scraped from the page HTML.
114
+ *
115
+ * Second, a broken boolean that indicates whether the targeted page actually exists. See getHrefPlus
116
+ * for a detailed explanation.
112
117
  */
113
- resolveLinkAndTitle: (lnk: string | LinkDefinition | undefined, opts?: {
118
+ resolveLinkPlus: (lnk: string | LinkDefinition | undefined, opts?: {
114
119
  absolute?: boolean;
115
120
  extension?: string;
116
121
  }) => Promise<{
117
122
  href?: string;
118
123
  title?: string;
124
+ broken: boolean;
119
125
  }>;
120
126
  /**
121
127
  * Get a link href for a page
@@ -132,6 +138,26 @@ export interface APIClient {
132
138
  absolute?: boolean;
133
139
  extension?: string;
134
140
  }) => string | undefined;
141
+ /**
142
+ * Exactly like getHref except it also returns whether or not the link it's returning is actually
143
+ * a broken link.
144
+ *
145
+ * When an internal link points at a page that has since been deleted, we don't want to return
146
+ * undefined or empty string or something like that, because it would mask the issue that a link has
147
+ * stopped working. Instead we return the path that we once pointed at, which we know won't work, but
148
+ * is at least something the user can read, and then reason about why the link broke and how to fix it.
149
+ *
150
+ * Since we are returning data we know is broken, it's nice to have a boolean that indicates that fact.
151
+ * Based on that boolean, components can be configured to render a shiny red warning message in edit mode
152
+ * so that editors can quickly identify broken links on their pages.
153
+ */
154
+ getHrefPlus: (page: PageRecordOptionalData, opts?: {
155
+ absolute?: boolean;
156
+ extension?: string;
157
+ }) => {
158
+ href: string | undefined;
159
+ broken: boolean;
160
+ };
135
161
  /**
136
162
  * Get assets by link
137
163
  *
@@ -124,6 +124,12 @@ export declare function dialogQuery<T = any>(query: string, variables?: any): Pr
124
124
  export interface TracingEnvironment {
125
125
  tracingServer: string;
126
126
  }
127
+ export interface TracingInterface {
128
+ init?: (env: TracingEnvironment) => void;
129
+ startTransaction?: (name: string, details: any, env?: TracingEnvironment) => void;
130
+ endTransaction?: (name: string, details: any, env?: TracingEnvironment) => void;
131
+ event?: (name: string, details: any, env?: TracingEnvironment) => void;
132
+ }
127
133
  /**
128
134
  * A type for the config object that should be exported from a CMS instance's admin/local/index.js
129
135
  * to configure how that instance should work.
@@ -187,11 +193,6 @@ export interface UIConfig {
187
193
  * here. The data collected will be available when you retrieve assets.
188
194
  */
189
195
  assetMetaDialog?: UITemplate['dialog'];
190
- tracing?: {
191
- init?: (env: TracingEnvironment) => void;
192
- startTransaction?: (name: string, details: any, env: TracingEnvironment) => void;
193
- endTransaction?: (name: string, details: any, env: TracingEnvironment) => void;
194
- event?: (name: string, details: any, env: TracingEnvironment) => void;
195
- };
196
+ tracing?: TracingInterface;
196
197
  }
197
198
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.131",
3
+ "version": "0.0.133",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {