@dosgato/templating 0.0.74 → 0.0.76

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.
@@ -30,8 +30,8 @@ export interface PageExtras {
30
30
  pageId?: string;
31
31
  /** The path in the pagetree to the page, or what the path will be. NOTE: looking the page up by path will not work during page creation. */
32
32
  pagePath?: string;
33
- /** The linkId the page has or will have. NOTE: looking the page up by linkId will not work during page creation. */
34
- linkId: string;
33
+ /** The linkId the page has. Null during page creation. */
34
+ linkId?: string;
35
35
  /** The name the page has or will have. NOTE: looking the page up by name will not work during page creation. */
36
36
  name: string;
37
37
  }
package/dist/render.d.ts CHANGED
@@ -33,7 +33,34 @@ export interface PictureAttributes {
33
33
  widths: PictureResize[];
34
34
  }[];
35
35
  }
36
+ export interface PageForNavigation {
37
+ id: string;
38
+ name: string;
39
+ title: string;
40
+ path: string;
41
+ href: string;
42
+ extra: Record<string, any>;
43
+ children: this[];
44
+ }
36
45
  export interface APIClient {
46
+ /**
47
+ * Identify whether we are generating the page for live, preview, or editing
48
+ *
49
+ * Useful for things like google analytics where you only want to add it to live pages
50
+ * or else you'd be getting stats from editors and previewers.
51
+ */
52
+ context: 'live' | 'preview' | 'edit';
53
+ /**
54
+ * Identify whether we are generating the published version of a page or not.
55
+ *
56
+ * The methods provided below all take this into account. For instance, if you are
57
+ * generating the published view of a page and ask for its root page, you get
58
+ * the published version of the root page, not the latest unpublished version.
59
+ *
60
+ * If you make your own queries asking for other pages' data, you should make use
61
+ * of this variable to ensure you get the correct version of the data.
62
+ */
63
+ published: boolean;
37
64
  /**
38
65
  * Run any query against the API.
39
66
  *
@@ -98,6 +125,20 @@ export interface APIClient {
98
125
  id?: string;
99
126
  path?: string;
100
127
  }) => Promise<PageRecord<PageData>>;
128
+ /**
129
+ * Get a hierarchical tree of pages suitable for generating a navigation
130
+ * UI for your template.
131
+ *
132
+ * Returns the root page. Subpages are inside the `children` property.
133
+ *
134
+ * "extra" is a list of dot-separated paths to page data that you need to help you build
135
+ * your interface. For example, ['hideInNav'] would fill page.extra with { hideInNav: true }.
136
+ */
137
+ getNavigation: ({ depth, extra, filter }: {
138
+ depth?: number;
139
+ extra?: string[];
140
+ filter?: (page: PageForNavigation) => boolean;
141
+ }) => Promise<PageForNavigation>;
101
142
  /**
102
143
  * Get data entries by link or folder link
103
144
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.74",
3
+ "version": "0.0.76",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {