@dosgato/templating 0.0.99 → 0.0.100
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.
- package/dist/component.d.ts +16 -0
- package/dist/component.js +6 -0
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -573,6 +573,22 @@ export declare abstract class Page<DataType extends PageData = any, FetchedType
|
|
|
573
573
|
* at any time during fetch, context, or render, to set an HTTP header on the response
|
|
574
574
|
*/
|
|
575
575
|
addHeader: (key: string, value: string | undefined) => void;
|
|
576
|
+
/**
|
|
577
|
+
* URL for the currently rendering page
|
|
578
|
+
*
|
|
579
|
+
* The URL currently being rendered. For instance, if we are in edit mode it would begin
|
|
580
|
+
* with /.edit/ or in preview mode, /.preview/. Useful for referencing variations of the
|
|
581
|
+
* current page.
|
|
582
|
+
*
|
|
583
|
+
* Does not include hash or querystring.
|
|
584
|
+
*
|
|
585
|
+
* Also see `variationUrl` below.
|
|
586
|
+
*/
|
|
587
|
+
url: string;
|
|
588
|
+
/**
|
|
589
|
+
* Get a URL for the current page with a different extension
|
|
590
|
+
*/
|
|
591
|
+
variationUrl(extension: string): string;
|
|
576
592
|
protected passError(e: Error, path: string): void;
|
|
577
593
|
constructor(page: PageRecord<DataType>, editMode: boolean, extension: string);
|
|
578
594
|
}
|
package/dist/component.js
CHANGED
|
@@ -287,6 +287,12 @@ export class Page extends Component {
|
|
|
287
287
|
get title() {
|
|
288
288
|
return this.pageInfo.data.title ?? titleCase(this.pageInfo.name);
|
|
289
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Get a URL for the current page with a different extension
|
|
292
|
+
*/
|
|
293
|
+
variationUrl(extension) {
|
|
294
|
+
return `${this.url.replace(/\.\w+$/, '')}.${extension}`;
|
|
295
|
+
}
|
|
290
296
|
passError(e, path) {
|
|
291
297
|
console.warn(`Recoverable issue occured during render of ${this.pageInfo.path}. Component at ${path} threw the following error:`, e);
|
|
292
298
|
}
|