@dosgato/templating 0.0.59 → 0.0.61

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.
@@ -193,11 +193,24 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
193
193
  logError(e: Error): void;
194
194
  protected passError(e: Error, path: string): void;
195
195
  }
196
+ export interface SiteInfo {
197
+ id: string;
198
+ name: string;
199
+ launched: boolean;
200
+ url?: {
201
+ prefix: string;
202
+ path: string;
203
+ };
204
+ }
196
205
  export interface PageRecord<DataType extends PageData = PageData> {
197
206
  id: string;
198
207
  linkId: string;
199
208
  path: string;
200
209
  data: DataType;
210
+ site: SiteInfo;
211
+ }
212
+ export interface PageRecordOptionalData<DataType extends PageData = PageData> extends Omit<PageRecord<DataType>, 'data'> {
213
+ data?: DataType;
201
214
  }
202
215
  export interface ComponentData {
203
216
  templateKey: string;
@@ -239,10 +252,9 @@ export declare abstract class Page<DataType extends PageData = any, FetchedType
239
252
  */
240
253
  id: string;
241
254
  /**
242
- * The page path, can also be used to figure out where the page is, but you'll likely prefer
243
- * using the page id in API queries
255
+ * Other data we've already collected about the page being rendered, in case it's needed.
244
256
  */
245
- pagePath: string;
257
+ pageInfo: PageRecord<DataType>;
246
258
  /**
247
259
  * This will be filled by the rendering server. The template properties are described
248
260
  * over in apitemplate.ts in the comment for APIPageTemplate.templateProperties.
package/dist/component.js CHANGED
@@ -175,10 +175,10 @@ export class Component extends ResourceProvider {
175
175
  export class Page extends Component {
176
176
  constructor(page, editMode) {
177
177
  super(page.data, '', undefined, editMode);
178
- this.pagePath = page.path;
179
178
  this.id = page.id;
179
+ this.pageInfo = page;
180
180
  }
181
181
  passError(e, path) {
182
- console.warn(`Recoverable issue occured during render of ${this.pagePath}. Component at ${path} threw the following error:`, e);
182
+ console.warn(`Recoverable issue occured during render of ${this.pageInfo.path}. Component at ${path} threw the following error:`, e);
183
183
  }
184
184
  }
package/dist/render.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ContextBase, DataData, PageData, PageRecord } from './component.js';
1
+ import { ContextBase, DataData, PageData, PageRecord, PageRecordOptionalData } from './component.js';
2
2
  import { AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js';
3
3
  export declare function printHeader(ctx: ContextBase, content: string): string;
4
4
  export declare function advanceHeader(ctx: ContextBase, content?: string): {
@@ -57,7 +57,10 @@ export interface APIClient {
57
57
  * absolute: true to generate a full URL suitable for a backend http request or non-HTML document
58
58
  * like an RSS feed.
59
59
  */
60
- getHref: (page: PageRecord, absolute?: boolean) => string;
60
+ getHref: (page: PageRecordOptionalData, opts?: {
61
+ absolute?: boolean;
62
+ extension?: string;
63
+ }) => string;
61
64
  /**
62
65
  * This function will be provided by the rendering server and should be used inside your fetch
63
66
  * method to prepare editor-provided HTML for rendering. It will do things like find and resolve
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {