musora-content-services 1.0.9 → 1.0.11
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/CHANGELOG.md +4 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/global.html +947 -933
- package/docs/index.html +27 -9
- package/docs/index.js.html +147 -51
- package/docs/scripts/collapse.js +39 -0
- package/docs/scripts/commonNav.js +28 -0
- package/docs/scripts/nav.js +12 -0
- package/docs/scripts/polyfill.js +4 -0
- package/docs/scripts/search.js +99 -265
- package/docs/styles/jsdoc.css +776 -0
- package/docs/styles/prettify.css +80 -0
- package/jsdoc.json +1 -1
- package/package.json +5 -4
- package/src/index.js +127 -43
package/docs/index.html
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
+
|
|
4
5
|
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
6
|
<title>Home - Documentation</title>
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
|
|
8
9
|
<script src="scripts/prettify/prettify.js"></script>
|
|
9
10
|
<script src="scripts/prettify/lang-css.js"></script>
|
|
10
11
|
<!--[if lt IE 9]>
|
|
11
12
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
12
13
|
<![endif]-->
|
|
13
|
-
<link type="text/css" rel="stylesheet" href="
|
|
14
|
-
<link type="text/css" rel="stylesheet" href="styles/
|
|
15
|
-
<
|
|
14
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
15
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
16
|
+
<script src="scripts/nav.js" defer></script>
|
|
17
|
+
|
|
18
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
16
19
|
</head>
|
|
17
20
|
<body>
|
|
18
21
|
|
|
@@ -23,8 +26,11 @@
|
|
|
23
26
|
|
|
24
27
|
<label for="nav-trigger" class="overlay"></label>
|
|
25
28
|
|
|
26
|
-
<nav>
|
|
27
|
-
|
|
29
|
+
<nav >
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#fetchAll">fetchAll</a></li><li><a href="global.html#fetchAllFilterOptions">fetchAllFilterOptions</a></li><li><a href="global.html#fetchAllSongs">fetchAllSongs</a></li><li><a href="global.html#fetchArtists">fetchArtists</a></li><li><a href="global.html#fetchByRailContentId">fetchByRailContentId</a></li><li><a href="global.html#fetchByRailContentIds">fetchByRailContentIds</a></li><li><a href="global.html#fetchChildren">fetchChildren</a></li><li><a href="global.html#fetchLessonContent">fetchLessonContent</a></li><li><a href="global.html#fetchMethodChildren">fetchMethodChildren</a></li><li><a href="global.html#fetchMethodNextLesson">fetchMethodNextLesson</a></li><li><a href="global.html#fetchNewReleases">fetchNewReleases</a></li><li><a href="global.html#fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li><a href="global.html#fetchPackAll">fetchPackAll</a></li><li><a href="global.html#fetchPackChildren">fetchPackChildren</a></li><li><a href="global.html#fetchRelatedLessons">fetchRelatedLessons</a></li><li><a href="global.html#fetchRelatedSongs">fetchRelatedSongs</a></li><li><a href="global.html#fetchSanity">fetchSanity</a></li><li><a href="global.html#fetchSongArtistCount">fetchSongArtistCount</a></li><li><a href="global.html#fetchSongById">fetchSongById</a></li><li><a href="global.html#fetchSongCount">fetchSongCount</a></li><li><a href="global.html#fetchSongFilterOptions">fetchSongFilterOptions</a></li><li><a href="global.html#fetchUpcomingEvents">fetchUpcomingEvents</a></li><li><a href="global.html#fetchWorkouts">fetchWorkouts</a></li><li><a href="global.html#initializeSanityService">initializeSanityService</a></li></ul>
|
|
33
|
+
|
|
28
34
|
</nav>
|
|
29
35
|
|
|
30
36
|
<div id="main">
|
|
@@ -37,6 +43,11 @@
|
|
|
37
43
|
|
|
38
44
|
|
|
39
45
|
|
|
46
|
+
<section class="package">
|
|
47
|
+
<h3> </h3>
|
|
48
|
+
</section>
|
|
49
|
+
|
|
50
|
+
|
|
40
51
|
|
|
41
52
|
|
|
42
53
|
|
|
@@ -47,7 +58,8 @@
|
|
|
47
58
|
|
|
48
59
|
|
|
49
60
|
|
|
50
|
-
|
|
61
|
+
|
|
62
|
+
<section class="readme usertext">
|
|
51
63
|
<article><h1>Musora Content Services</h1>
|
|
52
64
|
<p>Welcome to the <strong>musora-content-services</strong> repository. This package provides a collection of utility functions designed to fetch and manage content from our Sanity Studio. These functions are tailored to interact with our Sanity backend, allowing you to easily retrieve, filter, and manipulate content for use in various applications.</p>
|
|
53
65
|
<h2>Features</h2>
|
|
@@ -84,15 +96,21 @@ Run the following to execute the tests</p>
|
|
|
84
96
|
|
|
85
97
|
|
|
86
98
|
|
|
99
|
+
|
|
100
|
+
|
|
87
101
|
</div>
|
|
88
102
|
|
|
89
103
|
<br class="clear">
|
|
90
104
|
|
|
91
105
|
<footer>
|
|
92
|
-
|
|
106
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 15:31:44 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
93
107
|
</footer>
|
|
94
108
|
|
|
95
109
|
<script>prettyPrint();</script>
|
|
110
|
+
<script src="scripts/polyfill.js"></script>
|
|
96
111
|
<script src="scripts/linenumber.js"></script>
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
97
115
|
</body>
|
|
98
116
|
</html>
|
package/docs/index.js.html
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
+
|
|
4
5
|
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
6
|
<title>index.js - Documentation</title>
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
|
|
8
9
|
<script src="scripts/prettify/prettify.js"></script>
|
|
9
10
|
<script src="scripts/prettify/lang-css.js"></script>
|
|
10
11
|
<!--[if lt IE 9]>
|
|
11
12
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
12
13
|
<![endif]-->
|
|
13
|
-
<link type="text/css" rel="stylesheet" href="
|
|
14
|
-
<link type="text/css" rel="stylesheet" href="styles/
|
|
15
|
-
<
|
|
14
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
15
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
16
|
+
<script src="scripts/nav.js" defer></script>
|
|
17
|
+
|
|
18
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
16
19
|
</head>
|
|
17
20
|
<body>
|
|
18
21
|
|
|
@@ -23,8 +26,11 @@
|
|
|
23
26
|
|
|
24
27
|
<label for="nav-trigger" class="overlay"></label>
|
|
25
28
|
|
|
26
|
-
<nav>
|
|
27
|
-
|
|
29
|
+
<nav >
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#fetchAll">fetchAll</a></li><li><a href="global.html#fetchAllFilterOptions">fetchAllFilterOptions</a></li><li><a href="global.html#fetchAllSongs">fetchAllSongs</a></li><li><a href="global.html#fetchArtists">fetchArtists</a></li><li><a href="global.html#fetchByRailContentId">fetchByRailContentId</a></li><li><a href="global.html#fetchByRailContentIds">fetchByRailContentIds</a></li><li><a href="global.html#fetchChildren">fetchChildren</a></li><li><a href="global.html#fetchLessonContent">fetchLessonContent</a></li><li><a href="global.html#fetchMethodChildren">fetchMethodChildren</a></li><li><a href="global.html#fetchMethodNextLesson">fetchMethodNextLesson</a></li><li><a href="global.html#fetchNewReleases">fetchNewReleases</a></li><li><a href="global.html#fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li><a href="global.html#fetchPackAll">fetchPackAll</a></li><li><a href="global.html#fetchPackChildren">fetchPackChildren</a></li><li><a href="global.html#fetchRelatedLessons">fetchRelatedLessons</a></li><li><a href="global.html#fetchRelatedSongs">fetchRelatedSongs</a></li><li><a href="global.html#fetchSanity">fetchSanity</a></li><li><a href="global.html#fetchSongArtistCount">fetchSongArtistCount</a></li><li><a href="global.html#fetchSongById">fetchSongById</a></li><li><a href="global.html#fetchSongCount">fetchSongCount</a></li><li><a href="global.html#fetchSongFilterOptions">fetchSongFilterOptions</a></li><li><a href="global.html#fetchUpcomingEvents">fetchUpcomingEvents</a></li><li><a href="global.html#fetchWorkouts">fetchWorkouts</a></li><li><a href="global.html#initializeSanityService">initializeSanityService</a></li></ul>
|
|
33
|
+
|
|
28
34
|
</nav>
|
|
29
35
|
|
|
30
36
|
<div id="main">
|
|
@@ -51,7 +57,8 @@
|
|
|
51
57
|
* @param {string} config.dataset - The dataset name in Sanity.
|
|
52
58
|
* @param {string} config.version - The API version to use.
|
|
53
59
|
* @param {boolean} [config.debug=false] - Optional flag to enable debug mode, which logs the query and results.
|
|
54
|
-
* @param {boolean} [config.useCachedAPI=true] - Optional flag to disable cached API.
|
|
60
|
+
* @param {boolean} [config.useCachedAPI=true] - Optional flag to disable cached API.
|
|
61
|
+
*
|
|
55
62
|
* @example
|
|
56
63
|
* // Initialize the Sanity service in your app.js
|
|
57
64
|
* initializeSanityService({
|
|
@@ -59,7 +66,7 @@
|
|
|
59
66
|
* projectId: 'your-sanity-project-id',
|
|
60
67
|
* dataset: 'your-dataset-name',
|
|
61
68
|
* version: '2021-06-07',
|
|
62
|
-
* debug: true // Optional: Enable debug mode
|
|
69
|
+
* debug: true, // Optional: Enable debug mode
|
|
63
70
|
* useCachedAPI: true // Optional: Use cached API
|
|
64
71
|
* });
|
|
65
72
|
*/
|
|
@@ -69,8 +76,14 @@ function initializeSanityService(config) {
|
|
|
69
76
|
|
|
70
77
|
/**
|
|
71
78
|
* Fetch a song by its document ID from Sanity.
|
|
79
|
+
*
|
|
72
80
|
* @param {string} documentId - The ID of the document to fetch.
|
|
73
|
-
* @returns {Promise<Object|null>} -
|
|
81
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an object containing the song data or null if not found.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* fetchSongById('abc123')
|
|
85
|
+
* .then(song => console.log(song))
|
|
86
|
+
* .catch(error => console.error(error));
|
|
74
87
|
*/
|
|
75
88
|
async function fetchSongById(documentId) {
|
|
76
89
|
const fields = [
|
|
@@ -94,8 +107,14 @@ async function fetchSongById(documentId) {
|
|
|
94
107
|
|
|
95
108
|
/**
|
|
96
109
|
* Fetch all artists with lessons available for a specific brand.
|
|
110
|
+
*
|
|
97
111
|
* @param {string} brand - The brand for which to fetch artists.
|
|
98
|
-
* @returns {Promise<Object|null>} -
|
|
112
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an array of artist objects or null if not found.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* fetchArtists('drumeo')
|
|
116
|
+
* .then(artists => console.log(artists))
|
|
117
|
+
* .catch(error => console.error(error));
|
|
99
118
|
*/
|
|
100
119
|
async function fetchArtists(brand) {
|
|
101
120
|
const query = `
|
|
@@ -118,9 +137,15 @@ async function fetchSongArtistCount(brand) {
|
|
|
118
137
|
|
|
119
138
|
/**
|
|
120
139
|
* Fetch related songs for a specific brand and song ID.
|
|
140
|
+
*
|
|
121
141
|
* @param {string} brand - The brand for which to fetch related songs.
|
|
122
142
|
* @param {string} songId - The ID of the song to find related songs for.
|
|
123
|
-
* @returns {Promise<Object|null>} -
|
|
143
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an array of related song objects or null if not found.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* fetchRelatedSongs('drumeo', '12345')
|
|
147
|
+
* .then(relatedSongs => console.log(relatedSongs))
|
|
148
|
+
* .catch(error => console.error(error));
|
|
124
149
|
*/
|
|
125
150
|
async function fetchRelatedSongs(brand, songId) {
|
|
126
151
|
const query = `
|
|
@@ -201,6 +226,18 @@ async function fetchRelatedSongs(brand, songId) {
|
|
|
201
226
|
* @param {Array<string>} [params.includedFields=[]] - The fields to include in the query.
|
|
202
227
|
* @param {string} [params.groupBy=""] - The field to group the results by.
|
|
203
228
|
* @returns {Promise<Object|null>} - The fetched song data or null if not found.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* fetchAllSongs('drumeo', {
|
|
232
|
+
* page: 2,
|
|
233
|
+
* limit: 20,
|
|
234
|
+
* searchTerm: 'rock',
|
|
235
|
+
* sort: 'published_on',
|
|
236
|
+
* includedFields: ['difficulty', 'style'],
|
|
237
|
+
* groupBy: 'artist'
|
|
238
|
+
* })
|
|
239
|
+
* .then(result => console.log(result))
|
|
240
|
+
* .catch(error => console.error(error));
|
|
204
241
|
*/
|
|
205
242
|
async function fetchAllSongs(brand, {
|
|
206
243
|
page = 1,
|
|
@@ -332,8 +369,14 @@ async function fetchAllSongs(brand, {
|
|
|
332
369
|
|
|
333
370
|
/**
|
|
334
371
|
* Fetch filter options for a specific brand.
|
|
372
|
+
*
|
|
335
373
|
* @param {string} brand - The brand for which to fetch filter options.
|
|
336
|
-
* @returns {Promise<Object|null>} -
|
|
374
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an object containing filter options or null if not found.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* fetchSongFilterOptions('drumeo')
|
|
378
|
+
* .then(options => console.log(options))
|
|
379
|
+
* .catch(error => console.error(error));
|
|
337
380
|
*/
|
|
338
381
|
async function fetchSongFilterOptions(brand) {
|
|
339
382
|
const query = `
|
|
@@ -419,8 +462,14 @@ async function fetchNewReleases(brand) {
|
|
|
419
462
|
|
|
420
463
|
/**
|
|
421
464
|
* Fetch upcoming events for a specific brand.
|
|
465
|
+
*
|
|
422
466
|
* @param {string} brand - The brand for which to fetch upcoming events.
|
|
423
|
-
* @returns {Promise<Object|null>} -
|
|
467
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an array of upcoming event objects or null if not found.
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* fetchUpcomingEvents('drumeo')
|
|
471
|
+
* .then(events => console.log(events))
|
|
472
|
+
* .catch(error => console.error(error));
|
|
424
473
|
*/
|
|
425
474
|
async function fetchUpcomingEvents(brand) {
|
|
426
475
|
const liveTypes = {
|
|
@@ -449,8 +498,14 @@ async function fetchUpcomingEvents(brand) {
|
|
|
449
498
|
|
|
450
499
|
/**
|
|
451
500
|
* Fetch content by a specific Railcontent ID.
|
|
501
|
+
*
|
|
452
502
|
* @param {string} id - The Railcontent ID of the content to fetch.
|
|
453
|
-
* @returns {Promise<Object|null>} -
|
|
503
|
+
* @returns {Promise<Object|null>} - A promise that resolves to the content object or null if not found.
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* fetchByRailContentId('abc123')
|
|
507
|
+
* .then(content => console.log(content))
|
|
508
|
+
* .catch(error => console.error(error));
|
|
454
509
|
*/
|
|
455
510
|
async function fetchByRailContentId(id) {
|
|
456
511
|
const query = `*[railcontent_id == ${id}]{
|
|
@@ -469,8 +524,14 @@ async function fetchByRailContentId(id) {
|
|
|
469
524
|
|
|
470
525
|
/**
|
|
471
526
|
* Fetch content by an array of Railcontent IDs.
|
|
527
|
+
*
|
|
472
528
|
* @param {Array<string>} ids - The array of Railcontent IDs of the content to fetch.
|
|
473
|
-
* @returns {Promise<Array<Object>|null>} -
|
|
529
|
+
* @returns {Promise<Array<Object>|null>} - A promise that resolves to an array of content objects or null if not found.
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* fetchByRailContentIds(['abc123', 'def456', 'ghi789'])
|
|
533
|
+
* .then(contents => console.log(contents))
|
|
534
|
+
* .catch(error => console.error(error));
|
|
474
535
|
*/
|
|
475
536
|
async function fetchByRailContentIds(ids) {
|
|
476
537
|
const idsString = ids.join(',');
|
|
@@ -500,6 +561,18 @@ async function fetchByRailContentIds(ids) {
|
|
|
500
561
|
* @param {Array<string>} [params.includedFields=[]] - The fields to include in the query.
|
|
501
562
|
* @param {string} [params.groupBy=""] - The field to group the results by (e.g., 'artist', 'genre').
|
|
502
563
|
* @returns {Promise<Object|null>} - The fetched content data or null if not found.
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* fetchAll('drumeo', 'song', {
|
|
567
|
+
* page: 2,
|
|
568
|
+
* limit: 20,
|
|
569
|
+
* searchTerm: 'jazz',
|
|
570
|
+
* sort: '-popularity',
|
|
571
|
+
* includedFields: ['difficulty,Intermediate'],
|
|
572
|
+
* groupBy: 'artist'
|
|
573
|
+
* })
|
|
574
|
+
* .then(content => console.log(content))
|
|
575
|
+
* .catch(error => console.error(error));
|
|
503
576
|
*/
|
|
504
577
|
async function fetchAll(brand, type, {
|
|
505
578
|
page = 1,
|
|
@@ -759,6 +832,11 @@ async function fetchNextPreviousLesson(railcontentId) {
|
|
|
759
832
|
* Fetch the page data for a specific lesson by Railcontent ID.
|
|
760
833
|
* @param {string} railContentId - The Railcontent ID of the current lesson.
|
|
761
834
|
* @returns {Promise<Object|null>} - The fetched page data or null if found.
|
|
835
|
+
*
|
|
836
|
+
* @example
|
|
837
|
+
* fetchLessonContent('lesson123')
|
|
838
|
+
* .then(data => console.log(data))
|
|
839
|
+
* .catch(error => console.error(error));
|
|
762
840
|
*/
|
|
763
841
|
async function fetchLessonContent(railContentId) {
|
|
764
842
|
const query = `*[railcontent_id == ${railContentId} ]
|
|
@@ -834,6 +912,11 @@ async function fetchPackAll(railcontentId) {
|
|
|
834
912
|
* Fetch all children of a specific pack by Railcontent ID.
|
|
835
913
|
* @param {string} railcontentId - The Railcontent ID of the pack.
|
|
836
914
|
* @returns {Promise<Array<Object>|null>} - The fetched pack children data or null if not found.
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* fetchPackChildren('pack123')
|
|
918
|
+
* .then(children => console.log(children))
|
|
919
|
+
* .catch(error => console.error(error));
|
|
837
920
|
*/
|
|
838
921
|
async function fetchPackChildren(railcontentId) {
|
|
839
922
|
return fetchChildren(railcontentId, 'pack');
|
|
@@ -841,43 +924,50 @@ async function fetchPackChildren(railcontentId) {
|
|
|
841
924
|
|
|
842
925
|
/**
|
|
843
926
|
* Fetch data from the Sanity API based on a provided query.
|
|
927
|
+
*
|
|
844
928
|
* @param {string} query - The GROQ query to execute against the Sanity API.
|
|
845
|
-
* @param {boolean} isList - Whether to return an array or single result
|
|
846
|
-
* @returns {Promise<Object|null>} -
|
|
929
|
+
* @param {boolean} isList - Whether to return an array or a single result.
|
|
930
|
+
* @returns {Promise<Object|null>} - A promise that resolves to the fetched data or null if an error occurs or no results are found.
|
|
931
|
+
*
|
|
932
|
+
* @example
|
|
933
|
+
* const query = `*[_type == "song"]{title, artist->name}`;
|
|
934
|
+
* fetchSanity(query, true)
|
|
935
|
+
* .then(data => console.log(data))
|
|
936
|
+
* .catch(error => console.error(error));
|
|
847
937
|
*/
|
|
848
938
|
async function fetchSanity(query, isList) {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
939
|
+
// Check the config object before proceeding
|
|
940
|
+
if (!checkConfig(globalConfig)) {
|
|
941
|
+
return null;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
if (globalConfig.debug) {
|
|
945
|
+
console.log("fetchSanity Query:", query);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
const encodedQuery = encodeURIComponent(query);
|
|
949
|
+
const api = globalConfig.useCachedAPI ? 'apicdn' : 'api'
|
|
950
|
+
const url = `https://${globalConfig.projectId}.${api}.sanity.io/v${globalConfig.version}/data/query/${globalConfig.dataset}?query=${encodedQuery}`;
|
|
951
|
+
const headers = {
|
|
952
|
+
'Authorization': `Bearer ${globalConfig.token}`,
|
|
953
|
+
'Content-Type': 'application/json'
|
|
954
|
+
};
|
|
955
|
+
|
|
956
|
+
try {
|
|
957
|
+
const response = await fetch(url, {headers});
|
|
958
|
+
const result = await response.json();
|
|
959
|
+
if (result.result) {
|
|
960
|
+
if (globalConfig.debug) {
|
|
961
|
+
console.log("fetchSanity Results:", result);
|
|
962
|
+
}
|
|
963
|
+
return isList ? result.result : result.result[0];
|
|
964
|
+
} else {
|
|
965
|
+
throw new Error('No results found');
|
|
966
|
+
}
|
|
967
|
+
} catch (error) {
|
|
968
|
+
console.error('fetchSanity: Fetch error:', error);
|
|
969
|
+
return null;
|
|
970
|
+
}
|
|
881
971
|
}
|
|
882
972
|
|
|
883
973
|
|
|
@@ -945,15 +1035,21 @@ module.exports = {
|
|
|
945
1035
|
|
|
946
1036
|
|
|
947
1037
|
|
|
1038
|
+
|
|
1039
|
+
|
|
948
1040
|
</div>
|
|
949
1041
|
|
|
950
1042
|
<br class="clear">
|
|
951
1043
|
|
|
952
1044
|
<footer>
|
|
953
|
-
|
|
1045
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 15:31:44 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
954
1046
|
</footer>
|
|
955
1047
|
|
|
956
1048
|
<script>prettyPrint();</script>
|
|
1049
|
+
<script src="scripts/polyfill.js"></script>
|
|
957
1050
|
<script src="scripts/linenumber.js"></script>
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
|
|
958
1054
|
</body>
|
|
959
1055
|
</html>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function hideAllButCurrent(){
|
|
2
|
+
//by default all submenut items are hidden
|
|
3
|
+
//but we need to rehide them for search
|
|
4
|
+
document.querySelectorAll("nav > ul").forEach(function(parent) {
|
|
5
|
+
if (parent.className.indexOf("collapse_top") !== -1) {
|
|
6
|
+
parent.style.display = "none";
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) {
|
|
10
|
+
parent.style.display = "none";
|
|
11
|
+
});
|
|
12
|
+
document.querySelectorAll("nav > h3").forEach(function(section) {
|
|
13
|
+
if (section.className.indexOf("collapsed_header") !== -1) {
|
|
14
|
+
section.addEventListener("click", function(){
|
|
15
|
+
if (section.nextSibling.style.display === "none") {
|
|
16
|
+
section.nextSibling.style.display = "block";
|
|
17
|
+
} else {
|
|
18
|
+
section.nextSibling.style.display = "none";
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
//only current page (if it exists) should be opened
|
|
25
|
+
var file = window.location.pathname.split("/").pop().replace(/\.html/, '');
|
|
26
|
+
document.querySelectorAll("nav > ul > li > a").forEach(function(parent) {
|
|
27
|
+
var href = parent.attributes.href.value.replace(/\.html/, '');
|
|
28
|
+
if (file === href) {
|
|
29
|
+
if (parent.parentNode.parentNode.className.indexOf("collapse_top") !== -1) {
|
|
30
|
+
parent.parentNode.parentNode.style.display = "block";
|
|
31
|
+
}
|
|
32
|
+
parent.parentNode.querySelectorAll("ul li").forEach(function(elem) {
|
|
33
|
+
elem.style.display = "block";
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
hideAllButCurrent();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
if (typeof fetch === 'function') {
|
|
2
|
+
const init = () => {
|
|
3
|
+
if (typeof scrollToNavItem !== 'function') return false
|
|
4
|
+
scrollToNavItem()
|
|
5
|
+
// hideAllButCurrent not always loaded
|
|
6
|
+
if (typeof hideAllButCurrent === 'function') hideAllButCurrent()
|
|
7
|
+
return true
|
|
8
|
+
}
|
|
9
|
+
fetch('./nav.inc.html')
|
|
10
|
+
.then(response => response.ok ? response.text() : `${response.url} => ${response.status} ${response.statusText}`)
|
|
11
|
+
.then(body => {
|
|
12
|
+
document.querySelector('nav').innerHTML += body
|
|
13
|
+
// nav.js should be quicker to load than nav.inc.html, a fallback just in case
|
|
14
|
+
return init()
|
|
15
|
+
})
|
|
16
|
+
.then(done => {
|
|
17
|
+
if (done) return
|
|
18
|
+
let i = 0
|
|
19
|
+
;(function waitUntilNavJs () {
|
|
20
|
+
if (init()) return
|
|
21
|
+
if (i++ < 100) return setTimeout(waitUntilNavJs, 300)
|
|
22
|
+
console.error(Error('nav.js not loaded after 30s waiting for it'))
|
|
23
|
+
})()
|
|
24
|
+
})
|
|
25
|
+
.catch(error => console.error(error))
|
|
26
|
+
} else {
|
|
27
|
+
console.error(Error('Browser too old to display commonNav (remove commonNav docdash option)'))
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function scrollToNavItem() {
|
|
2
|
+
var path = window.location.href.split('/').pop().replace(/\.html/, '');
|
|
3
|
+
document.querySelectorAll('nav a').forEach(function(link) {
|
|
4
|
+
var href = link.attributes.href.value.replace(/\.html/, '');
|
|
5
|
+
if (path === href) {
|
|
6
|
+
link.scrollIntoView({block: 'center'});
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
scrollToNavItem();
|