@dosgato/templating 0.0.99 → 0.0.101

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.
@@ -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
  }
@@ -81,6 +81,21 @@ export interface JSBlock {
81
81
  * (unless their dependents are smart enough to wait for the global to be defined).
82
82
  */
83
83
  async?: boolean;
84
+ /**
85
+ * Do not treat this script like a module
86
+ *
87
+ * By default we set the `type="module"` attribute on script tags. Mostly what this will do is ensure
88
+ * your top-level variables don't accidentally pollute the global scope. You would need to do
89
+ * `window.myVar =` instead of `const myVar =`.
90
+ *
91
+ * If your script is full of intentional globals and you don't want to refactor it, you can set
92
+ * this to false.
93
+ *
94
+ * This is also useful for frameworks like jQuery or prototype to ensure that they are executed
95
+ * immediately instead of just before DOMContentLoaded. jQuery in particular behaves poorly when
96
+ * you combine `type="module"` or `defer` with jQuery(document).ready().
97
+ */
98
+ nomodule?: boolean;
84
99
  }
85
100
  export interface FileDeclaration {
86
101
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.99",
3
+ "version": "0.0.101",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {