@turnipxenon/pineapple 2.4.33 → 2.4.34

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.
@@ -5,7 +5,9 @@
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
7
  <list default="true" id="accb6ba2-c343-4f84-ad30-6e2d71eceee5" name="Changes" comment="Migrate from relying on json instead of comments for meta">
8
- <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/src/lib/components/navigation_component/PageMeta.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/components/navigation_component/PageMeta.ts" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/src/routes/(pineapple)/pineapple/(extra-pages)/page1/meta.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/routes/(pineapple)/pineapple/(extra-pages)/page1/meta.json" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/src/routes/(pineapple)/pineapple/(extra-pages)/page2/meta.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/routes/(pineapple)/pineapple/(extra-pages)/page2/meta.json" afterDir="false" />
9
11
  </list>
10
12
  <option name="SHOW_DIALOG" value="false" />
11
13
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -120,11 +122,11 @@
120
122
  <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\(pineapple)\pineapple\page3" />
121
123
  </key>
122
124
  <key name="MoveFile.RECENT_KEYS">
125
+ <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\(pineapple)\pineapple\(extra-pages)\page1" />
126
+ <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\(pineapple)\pineapple\(extra-pages)\page2" />
127
+ <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\(pineapple)\pineapple\(extra-pages)\page3" />
123
128
  <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\(pineapple)\pineapple\(extra-pages)" />
124
129
  <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\(pineapple)\pineapple\page3\page7\(test_layout)" />
125
- <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\lib\components\navigation_component" />
126
- <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\lib\components\dialog_overlay" />
127
- <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\lib\components\overrideable_meta" />
128
130
  </key>
129
131
  <key name="es6.move.members.recent.items">
130
132
  <recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\types\RootLayoutProps.ts" />
@@ -243,6 +245,8 @@
243
245
  <workItem from="1711487798169" duration="264000" />
244
246
  <workItem from="1711488375110" duration="856000" />
245
247
  <workItem from="1711490061858" duration="2823000" />
248
+ <workItem from="1711492999560" duration="85000" />
249
+ <workItem from="1711493260312" duration="1358000" />
246
250
  </task>
247
251
  <task id="LOCAL-00062" summary="Improve text contrast in dark mode">
248
252
  <option name="closed" value="true" />
@@ -1,8 +1,7 @@
1
1
  export interface PageMeta {
2
- relativeLink: string;
3
- nestedPages: PageMeta[];
4
- title: string;
5
- tags: string[];
2
+ datePublished?: string;
3
+ description?: string;
4
+ imageAlt?: string;
6
5
  /**
7
6
  * imageID is an ID that NavigationComponent can use to identify imported images
8
7
  *
@@ -17,18 +16,29 @@ export interface PageMeta {
17
16
  * - Your image map typescript: ImageMap.ts
18
17
  * - The page you want with an image represented in the navigation: ./topic1/+page.svelte
19
18
  * - The meta for that page: ./topic1/meta.json
19
+ *
20
+ * imageID takes precedence over imageURL
20
21
  */
21
22
  imageID?: string;
22
23
  /**
23
24
  * imageURL is only limited to absolute paths (includes files in static folder)
25
+ *
26
+ * if imageID is defined, this will be ignored
24
27
  */
25
28
  imageUrl?: string;
26
- imageAlt?: string;
27
- description?: string;
28
- datePublished?: string;
29
29
  lastUpdated?: string;
30
+ nestedPages: PageMeta[];
31
+ /**
32
+ * relativeLink is generated automatically. This will be ignored in meta.json.
33
+ */
34
+ relativeLink: string;
30
35
  shouldGroup?: boolean;
31
36
  shouldHide?: boolean;
37
+ tags: string[];
38
+ /**
39
+ * title defaults to the directory name if it's an empty string.
40
+ */
41
+ title: string;
32
42
  }
33
43
  /**
34
44
  * todo: doc
@@ -38,3 +48,11 @@ export interface PageMeta {
38
48
  export declare const findPageMetaParent: (parentList: PageMeta[], child: PageMeta) => boolean;
39
49
  export type ParsePageMetaCompareFn = ((a: PageMeta, b: PageMeta) => number);
40
50
  export declare const parsePageMeta: (fileList: Record<string, unknown>, jsonList: Record<string, unknown>, imageMap: Map<string, string>, compareFn?: ParsePageMetaCompareFn) => PageMeta[];
51
+ /**
52
+ * Prioritizes, in order, lastUpdated, datePublished, has description, then title
53
+ *
54
+ * @param a
55
+ * @param b
56
+ * @constructor
57
+ */
58
+ export declare const DefaultPageMetaSorter: ParsePageMetaCompareFn;
@@ -75,6 +75,9 @@ export const parsePageMeta = (fileList, jsonList, imageMap, compareFn) => {
75
75
  }
76
76
  }
77
77
  }
78
+ if (meta.shouldHide) {
79
+ continue;
80
+ }
78
81
  pageFlatList.push(meta);
79
82
  }
80
83
  pageFlatList.sort((a, b) => a.relativeLink.localeCompare(b.relativeLink));
@@ -89,5 +92,44 @@ export const parsePageMeta = (fileList, jsonList, imageMap, compareFn) => {
89
92
  if (compareFn) {
90
93
  pageFlatList.sort(compareFn);
91
94
  }
95
+ else {
96
+ pageFlatList.sort(DefaultPageMetaSorter);
97
+ }
92
98
  return pageFlatList;
93
99
  };
100
+ const AWins = -1;
101
+ const BWins = 1;
102
+ /**
103
+ * Prioritizes, in order, lastUpdated, datePublished, has description, then title
104
+ *
105
+ * @param a
106
+ * @param b
107
+ * @constructor
108
+ */
109
+ export const DefaultPageMetaSorter = (a, b) => {
110
+ if (a.lastUpdated && !b.lastUpdated) {
111
+ return AWins;
112
+ }
113
+ else if (!a.lastUpdated && b.lastUpdated) {
114
+ return BWins;
115
+ }
116
+ else if (a.lastUpdated && b.lastUpdated) {
117
+ return a.lastUpdated.localeCompare(b.lastUpdated);
118
+ }
119
+ if (a.datePublished && !b.datePublished) {
120
+ return AWins;
121
+ }
122
+ else if (!a.lastUpdated && b.datePublished) {
123
+ return BWins;
124
+ }
125
+ else if (a.datePublished && b.datePublished) {
126
+ return a.datePublished.localeCompare(b.datePublished);
127
+ }
128
+ if (a.description && !b.description) {
129
+ return AWins;
130
+ }
131
+ else if (!a.description && b.description) {
132
+ return BWins;
133
+ }
134
+ return a.title.localeCompare(b.title);
135
+ };
@@ -21,7 +21,7 @@ export const options = {
21
21
  app: ({ head, body, assets, nonce, env }) => "<!DOCTYPE html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"" + assets + "/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width\" />\n\t\t" + head + "\n\t</head>\n\n\t<body data-sveltekit-preload-data=\"hover\" data-theme=\"crimson\">\n\t\t<div style=\"display: contents\" class=\"h-full overflow-hidden\">" + body + "</div>\n\t</body>\n</html>\n",
22
22
  error: ({ status, message }) => "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<title>" + message + "</title>\n\n\t\t<style>\n\t\t\tbody {\n\t\t\t\t--bg: white;\n\t\t\t\t--fg: #222;\n\t\t\t\t--divider: #ccc;\n\t\t\t\tbackground: var(--bg);\n\t\t\t\tcolor: var(--fg);\n\t\t\t\tfont-family:\n\t\t\t\t\tsystem-ui,\n\t\t\t\t\t-apple-system,\n\t\t\t\t\tBlinkMacSystemFont,\n\t\t\t\t\t'Segoe UI',\n\t\t\t\t\tRoboto,\n\t\t\t\t\tOxygen,\n\t\t\t\t\tUbuntu,\n\t\t\t\t\tCantarell,\n\t\t\t\t\t'Open Sans',\n\t\t\t\t\t'Helvetica Neue',\n\t\t\t\t\tsans-serif;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t.error {\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tmax-width: 32rem;\n\t\t\t\tmargin: 0 1rem;\n\t\t\t}\n\n\t\t\t.status {\n\t\t\t\tfont-weight: 200;\n\t\t\t\tfont-size: 3rem;\n\t\t\t\tline-height: 1;\n\t\t\t\tposition: relative;\n\t\t\t\ttop: -0.05rem;\n\t\t\t}\n\n\t\t\t.message {\n\t\t\t\tborder-left: 1px solid var(--divider);\n\t\t\t\tpadding: 0 0 0 1rem;\n\t\t\t\tmargin: 0 0 0 1rem;\n\t\t\t\tmin-height: 2.5rem;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t}\n\n\t\t\t.message h1 {\n\t\t\t\tfont-weight: 400;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t@media (prefers-color-scheme: dark) {\n\t\t\t\tbody {\n\t\t\t\t\t--bg: #222;\n\t\t\t\t\t--fg: #ddd;\n\t\t\t\t\t--divider: #666;\n\t\t\t\t}\n\t\t\t}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<div class=\"error\">\n\t\t\t<span class=\"status\">" + status + "</span>\n\t\t\t<div class=\"message\">\n\t\t\t\t<h1>" + message + "</h1>\n\t\t\t</div>\n\t\t</div>\n\t</body>\n</html>\n"
23
23
  },
24
- version_hash: "99eys7"
24
+ version_hash: "1l3dq8o"
25
25
  };
26
26
 
27
27
  export async function get_hooks() {
@@ -1,8 +1,7 @@
1
1
  export interface PageMeta {
2
- relativeLink: string;
3
- nestedPages: PageMeta[];
4
- title: string;
5
- tags: string[];
2
+ datePublished?: string;
3
+ description?: string;
4
+ imageAlt?: string;
6
5
  /**
7
6
  * imageID is an ID that NavigationComponent can use to identify imported images
8
7
  *
@@ -17,18 +16,29 @@ export interface PageMeta {
17
16
  * - Your image map typescript: ImageMap.ts
18
17
  * - The page you want with an image represented in the navigation: ./topic1/+page.svelte
19
18
  * - The meta for that page: ./topic1/meta.json
19
+ *
20
+ * imageID takes precedence over imageURL
20
21
  */
21
22
  imageID?: string;
22
23
  /**
23
24
  * imageURL is only limited to absolute paths (includes files in static folder)
25
+ *
26
+ * if imageID is defined, this will be ignored
24
27
  */
25
28
  imageUrl?: string;
26
- imageAlt?: string;
27
- description?: string;
28
- datePublished?: string;
29
29
  lastUpdated?: string;
30
+ nestedPages: PageMeta[];
31
+ /**
32
+ * relativeLink is generated automatically. This will be ignored in meta.json.
33
+ */
34
+ relativeLink: string;
30
35
  shouldGroup?: boolean;
31
36
  shouldHide?: boolean;
37
+ tags: string[];
38
+ /**
39
+ * title defaults to the directory name if it's an empty string.
40
+ */
41
+ title: string;
32
42
  }
33
43
  /**
34
44
  * todo: doc
@@ -38,3 +48,11 @@ export interface PageMeta {
38
48
  export declare const findPageMetaParent: (parentList: PageMeta[], child: PageMeta) => boolean;
39
49
  export type ParsePageMetaCompareFn = ((a: PageMeta, b: PageMeta) => number);
40
50
  export declare const parsePageMeta: (fileList: Record<string, unknown>, jsonList: Record<string, unknown>, imageMap: Map<string, string>, compareFn?: ParsePageMetaCompareFn) => PageMeta[];
51
+ /**
52
+ * Prioritizes, in order, lastUpdated, datePublished, has description, then title
53
+ *
54
+ * @param a
55
+ * @param b
56
+ * @constructor
57
+ */
58
+ export declare const DefaultPageMetaSorter: ParsePageMetaCompareFn;
@@ -75,6 +75,9 @@ export const parsePageMeta = (fileList, jsonList, imageMap, compareFn) => {
75
75
  }
76
76
  }
77
77
  }
78
+ if (meta.shouldHide) {
79
+ continue;
80
+ }
78
81
  pageFlatList.push(meta);
79
82
  }
80
83
  pageFlatList.sort((a, b) => a.relativeLink.localeCompare(b.relativeLink));
@@ -89,5 +92,44 @@ export const parsePageMeta = (fileList, jsonList, imageMap, compareFn) => {
89
92
  if (compareFn) {
90
93
  pageFlatList.sort(compareFn);
91
94
  }
95
+ else {
96
+ pageFlatList.sort(DefaultPageMetaSorter);
97
+ }
92
98
  return pageFlatList;
93
99
  };
100
+ const AWins = -1;
101
+ const BWins = 1;
102
+ /**
103
+ * Prioritizes, in order, lastUpdated, datePublished, has description, then title
104
+ *
105
+ * @param a
106
+ * @param b
107
+ * @constructor
108
+ */
109
+ export const DefaultPageMetaSorter = (a, b) => {
110
+ if (a.lastUpdated && !b.lastUpdated) {
111
+ return AWins;
112
+ }
113
+ else if (!a.lastUpdated && b.lastUpdated) {
114
+ return BWins;
115
+ }
116
+ else if (a.lastUpdated && b.lastUpdated) {
117
+ return a.lastUpdated.localeCompare(b.lastUpdated);
118
+ }
119
+ if (a.datePublished && !b.datePublished) {
120
+ return AWins;
121
+ }
122
+ else if (!a.lastUpdated && b.datePublished) {
123
+ return BWins;
124
+ }
125
+ else if (a.datePublished && b.datePublished) {
126
+ return a.datePublished.localeCompare(b.datePublished);
127
+ }
128
+ if (a.description && !b.description) {
129
+ return AWins;
130
+ }
131
+ else if (!a.description && b.description) {
132
+ return BWins;
133
+ }
134
+ return a.title.localeCompare(b.title);
135
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turnipxenon/pineapple",
3
3
  "description": "personal package for base styling for other personal projects",
4
- "version": "2.4.33",
4
+ "version": "2.4.34",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "npm run check-requirements && vite build && yarn package",
@@ -1,14 +1,10 @@
1
1
  import type { RawGlob } from "$pkg/util/util";
2
2
 
3
3
  export interface PageMeta {
4
- // generated meta
5
- relativeLink: string;
6
- nestedPages: PageMeta[];
7
-
8
- // defined meta
9
- title: string; // defaults to directory name
10
- tags: string[];
4
+ datePublished?: string;
5
+ description?: string;
11
6
 
7
+ imageAlt?: string; // defaults to directory name
12
8
  /**
13
9
  * imageID is an ID that NavigationComponent can use to identify imported images
14
10
  *
@@ -23,19 +19,33 @@ export interface PageMeta {
23
19
  * - Your image map typescript: ImageMap.ts
24
20
  * - The page you want with an image represented in the navigation: ./topic1/+page.svelte
25
21
  * - The meta for that page: ./topic1/meta.json
22
+ *
23
+ * imageID takes precedence over imageURL
26
24
  */
27
25
  imageID?: string;
28
26
 
29
27
  /**
30
28
  * imageURL is only limited to absolute paths (includes files in static folder)
29
+ *
30
+ * if imageID is defined, this will be ignored
31
31
  */
32
32
  imageUrl?: string;
33
- imageAlt?: string;
34
- description?: string;
35
- datePublished?: string;
33
+
36
34
  lastUpdated?: string;
35
+ nestedPages: PageMeta[];
36
+
37
+ /**
38
+ * relativeLink is generated automatically. This will be ignored in meta.json.
39
+ */
40
+ relativeLink: string;
37
41
  shouldGroup?: boolean;
38
42
  shouldHide?: boolean;
43
+ tags: string[];
44
+
45
+ /**
46
+ * title defaults to the directory name if it's an empty string.
47
+ */
48
+ title: string;
39
49
  }
40
50
 
41
51
  /**
@@ -135,7 +145,10 @@ export const parsePageMeta = (fileList: Record<string, unknown>,
135
145
  console.warn(`Accessibility issues: image alt missing for image ${meta.imageUrl}`);
136
146
  }
137
147
  }
148
+ }
138
149
 
150
+ if (meta.shouldHide) {
151
+ continue;
139
152
  }
140
153
 
141
154
  pageFlatList.push(meta);
@@ -154,7 +167,45 @@ export const parsePageMeta = (fileList: Record<string, unknown>,
154
167
 
155
168
  if (compareFn) {
156
169
  pageFlatList.sort(compareFn);
170
+ } else {
171
+ pageFlatList.sort(DefaultPageMetaSorter);
157
172
  }
158
173
 
159
174
  return pageFlatList;
175
+ };
176
+
177
+ const AWins = -1;
178
+ const BWins = 1;
179
+
180
+ /**
181
+ * Prioritizes, in order, lastUpdated, datePublished, has description, then title
182
+ *
183
+ * @param a
184
+ * @param b
185
+ * @constructor
186
+ */
187
+ export const DefaultPageMetaSorter: ParsePageMetaCompareFn = (a, b) => {
188
+ if (a.lastUpdated && !b.lastUpdated) {
189
+ return AWins;
190
+ } else if (!a.lastUpdated && b.lastUpdated) {
191
+ return BWins;
192
+ } else if (a.lastUpdated && b.lastUpdated) {
193
+ return a.lastUpdated.localeCompare(b.lastUpdated);
194
+ }
195
+
196
+ if (a.datePublished && !b.datePublished) {
197
+ return AWins;
198
+ } else if (!a.lastUpdated && b.datePublished) {
199
+ return BWins;
200
+ } else if (a.datePublished && b.datePublished) {
201
+ return a.datePublished.localeCompare(b.datePublished);
202
+ }
203
+
204
+ if (a.description && !b.description) {
205
+ return AWins;
206
+ } else if (!a.description && b.description) {
207
+ return BWins;
208
+ }
209
+
210
+ return a.title.localeCompare(b.title);
160
211
  };
@@ -1,5 +1,14 @@
1
1
  {
2
- "title": "Custom title for page 1",
3
- "imageUrl": "/favicon.png",
4
- "tags": ["random"]
2
+ "datePublished": "23-01-01",
3
+ "description": "random description but look at Ares!",
4
+ "imageAlt": "Image of Ares being excited",
5
+ "imageID": "testImageID",
6
+ "imageURL": "./favicon.png/?q=imageIDTakesPrecedence",
7
+ "lastUpdated": "23-02-02",
8
+ "shouldGroup": false,
9
+ "shouldHide": false,
10
+ "tags": [
11
+ "random"
12
+ ],
13
+ "title": "Custom title for page 1!!!"
5
14
  }
@@ -1,5 +1,8 @@
1
1
  {
2
- "title": "Custom title for page 2!!!",
3
- "imageID": "testImageID",
4
- "tags": ["random"]
2
+ "lastUpdated": "2024-03-03",
3
+ "title": "Custom title for page 2",
4
+ "imageUrl": "/favicon.png",
5
+ "tags": [
6
+ "random"
7
+ ]
5
8
  }