From a451f10d4c501cbd154d5d1df204f5000e83da41 Mon Sep 17 00:00:00 2001 From: Bratalix Date: Mon, 21 Nov 2022 13:42:57 +1100 Subject: [PATCH 1/6] Add devotion schema --- package.json | 1 + schemas/devotion.js | 69 +++++++++++++++++++++++++++++++++++++++++++++ schemas/schema.js | 4 ++- structure.js | 14 +++++++-- yarn.lock | 27 ++++++++++++++++++ 5 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 schemas/devotion.js diff --git a/package.json b/package.json index 1158e70..254cb23 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@sanity/vision": "0.147.10-document-actions.37", "@u-wave/react-vimeo": "^0.8.1", "get-video-id": "^3.1.4", + "groq": "^2.33.2", "pptxgenjs": "gitbrent/PptxGenJS#master", "prop-types": "^15.6", "react": "^16.2", diff --git a/schemas/devotion.js b/schemas/devotion.js new file mode 100644 index 0000000..2a9c058 --- /dev/null +++ b/schemas/devotion.js @@ -0,0 +1,69 @@ +import React from "react"; +import MenuReference from "../menu-refs"; +import client from "part:@sanity/base/client"; +import groq from "groq"; + +// const isUniqueDate = (date, context) => { +// console.log(date, context); +// const { document } = context; +// const id = document._id.replace(/^drafts\./, ""); +// const params = { +// draft: `drafts.${id}`, +// published: id, +// date +// }; + +// const query = groq`!defined(*[ +// _type == 'devotion' && +// !(_id in ['${params.draft}', '${params.published}']) && +// date == '${date}' +// ][0]._id)`; + +// console.log(query, params); + +// return client.fetch(query); +// }; + +export default { + name: "devotion", + title: "Devotion", + type: "document", + fields: [ + { + name: "title", + title: "Title", + type: "string" + }, + { + name: "date", + title: "Devotion Date", + type: "date" + // validation: (Rule) => + // Rule.custom(async (value, context) => { + // const isUnique = await isUniqueDate(value, context); + // if (!isUnique) return "Devotion date is not unique"; + // return true; + // }) + }, + { + name: "content", + title: "Content", + type: "content" + } + ], + preview: { + select: { + title: "title", + date: "date", + id: "_id" + }, + prepare(selection) { + const { id } = selection; + const title = `${selection.date} ${selection.title}`; + return { + title, + media: + }; + } + } +}; diff --git a/schemas/schema.js b/schemas/schema.js index cd6a1d5..27d490c 100644 --- a/schemas/schema.js +++ b/schemas/schema.js @@ -24,6 +24,7 @@ import relativeUrl from "./relative-url"; import externalUrl from "./external-url"; import video from "./video"; import restrictedContent from "./restricted-content"; +import devotion from "./devotion"; export default createSchema({ name: "default", @@ -50,6 +51,7 @@ export default createSchema({ relativeUrl, externalUrl, video, - restrictedContent + restrictedContent, + devotion ]) }); diff --git a/structure.js b/structure.js index 0297390..156ccaf 100644 --- a/structure.js +++ b/structure.js @@ -14,7 +14,7 @@ import { MdLock } from "react-icons/md"; import { FiBookOpen } from "react-icons/fi"; -import { FaPrayingHands } from "react-icons/fa"; +import { FaPrayingHands, FaBible } from "react-icons/fa"; export default () => { return S.list() @@ -85,10 +85,18 @@ export default () => { .title("Files") .icon(MdAttachFile) .child(S.documentTypeList("asset").title("Files")), - S.listItem() + S.listItem() .title("External URLs") .icon(MdLink) - .child(S.documentTypeList("externalUrl").title("External URLs")) + .child(S.documentTypeList("externalUrl").title("External URLs")), + S.listItem() + .title("Devotions") + .icon(FaBible) + .child( + S.documentTypeList("devotion") + .title("Devotions") + .defaultOrdering([{ field: "date", direction: "desc" }]) + ) ]) ), S.divider(), diff --git a/yarn.lock b/yarn.lock index e42749d..fe5c97b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1643,6 +1643,13 @@ "@types/minimatch" "*" "@types/node" "*" +"@types/jszip@^3.1.7": + version "3.4.1" + resolved "https://registry.yarnpkg.com/@types/jszip/-/jszip-3.4.1.tgz#e7a4059486e494c949ef750933d009684227846f" + integrity sha512-TezXjmf3lj+zQ651r6hPqvSScqBLvyPI9FxdXBqpEwBijNGQ2NXpaFW/7joGzveYkKQUil7iiDHLo6LV71Pc0A== + dependencies: + jszip "*" + "@types/lodash@^4.14.149": version "4.14.149" resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.149.tgz#1342d63d948c6062838fbf961012f74d4e638440" @@ -1659,6 +1666,11 @@ version "13.7.1" resolved "https://registry.npmjs.org/@types/node/-/node-13.7.1.tgz#238eb34a66431b71d2aaddeaa7db166f25971a0d" +"@types/node@^13.7.1": + version "13.13.52" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.52.tgz#03c13be70b9031baaed79481c0c0cfb0045e53f7" + integrity sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ== + "@types/node@^8.0.0": version "8.10.59" resolved "https://registry.npmjs.org/@types/node/-/node-8.10.59.tgz#9e34261f30183f9777017a13d185dfac6b899e04" @@ -4656,6 +4668,11 @@ graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2 version "4.2.3" resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" +groq@^2.33.2: + version "2.33.2" + resolved "https://registry.yarnpkg.com/groq/-/groq-2.33.2.tgz#3a85c85a1e43e79bba77f171f23997f541d61010" + integrity sha512-5pf4c91JESCS28IJCgolJq/WBw4Xvf2m8FgZVUlrCig17I+qERosALAHLyyutXu403EYnyCD3DdCLaPb3aGneA== + gud@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0" @@ -5626,6 +5643,16 @@ jsx-ast-utils@^2.2.3: array-includes "^3.0.3" object.assign "^4.1.0" +jszip@*: + version "3.10.1" + resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2" + integrity sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g== + dependencies: + lie "~3.3.0" + pako "~1.0.2" + readable-stream "~2.3.6" + setimmediate "^1.0.5" + jszip@^3.2.2: version "3.2.2" resolved "https://registry.npmjs.org/jszip/-/jszip-3.2.2.tgz#b143816df7e106a9597a94c77493385adca5bd1d" From 59188a6b7f719696071fca1086586dfd2a6575e6 Mon Sep 17 00:00:00 2001 From: Bratalix Date: Mon, 21 Nov 2022 13:43:46 +1100 Subject: [PATCH 2/6] log cleanup --- schemas/devotion.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/schemas/devotion.js b/schemas/devotion.js index 2a9c058..260ee1e 100644 --- a/schemas/devotion.js +++ b/schemas/devotion.js @@ -4,7 +4,6 @@ import client from "part:@sanity/base/client"; import groq from "groq"; // const isUniqueDate = (date, context) => { -// console.log(date, context); // const { document } = context; // const id = document._id.replace(/^drafts\./, ""); // const params = { @@ -19,8 +18,6 @@ import groq from "groq"; // date == '${date}' // ][0]._id)`; -// console.log(query, params); - // return client.fetch(query); // }; From e1677f88d5c009f5bc9d1f098dd1f105743af147 Mon Sep 17 00:00:00 2001 From: Bratalix Date: Thu, 24 Nov 2022 16:09:26 +1100 Subject: [PATCH 3/6] Devotion chema updates --- schemas/{devotion.js => devotion-content.js} | 11 ++++++----- schemas/schema.js | 4 ++-- structure.js | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) rename schemas/{devotion.js => devotion-content.js} (86%) diff --git a/schemas/devotion.js b/schemas/devotion-content.js similarity index 86% rename from schemas/devotion.js rename to schemas/devotion-content.js index 260ee1e..d306b86 100644 --- a/schemas/devotion.js +++ b/schemas/devotion-content.js @@ -1,7 +1,7 @@ import React from "react"; import MenuReference from "../menu-refs"; -import client from "part:@sanity/base/client"; -import groq from "groq"; +// import client from "part:@sanity/base/client"; +// import groq from "groq"; // const isUniqueDate = (date, context) => { // const { document } = context; @@ -13,7 +13,7 @@ import groq from "groq"; // }; // const query = groq`!defined(*[ -// _type == 'devotion' && +// _type == 'devotionContent' && // !(_id in ['${params.draft}', '${params.published}']) && // date == '${date}' // ][0]._id)`; @@ -22,7 +22,7 @@ import groq from "groq"; // }; export default { - name: "devotion", + name: "devotionContent", title: "Devotion", type: "document", fields: [ @@ -34,7 +34,8 @@ export default { { name: "date", title: "Devotion Date", - type: "date" + type: "date", + validation: Rule=>Rule.required() // validation: (Rule) => // Rule.custom(async (value, context) => { // const isUnique = await isUniqueDate(value, context); diff --git a/schemas/schema.js b/schemas/schema.js index 27d490c..7c72111 100644 --- a/schemas/schema.js +++ b/schemas/schema.js @@ -24,7 +24,7 @@ import relativeUrl from "./relative-url"; import externalUrl from "./external-url"; import video from "./video"; import restrictedContent from "./restricted-content"; -import devotion from "./devotion"; +import devotionContent from "./devotion-content"; export default createSchema({ name: "default", @@ -52,6 +52,6 @@ export default createSchema({ externalUrl, video, restrictedContent, - devotion + devotionContent ]) }); diff --git a/structure.js b/structure.js index 156ccaf..1289460 100644 --- a/structure.js +++ b/structure.js @@ -93,7 +93,7 @@ export default () => { .title("Devotions") .icon(FaBible) .child( - S.documentTypeList("devotion") + S.documentTypeList("devotionContent") .title("Devotions") .defaultOrdering([{ field: "date", direction: "desc" }]) ) From 8a9c3bbe99cee46afcef19b0c7548a3ffc9cfda2 Mon Sep 17 00:00:00 2001 From: Bratalix Date: Sat, 11 Mar 2023 15:56:56 +1100 Subject: [PATCH 4/6] update devotion schema --- .gitignore | 5 ++++- schemas/devotion-content.js | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6cd7595..7990e21 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ yarn-error.log* # secrets shh... .env -!.env.example \ No newline at end of file +!.env.example + +#data imports +/imports* \ No newline at end of file diff --git a/schemas/devotion-content.js b/schemas/devotion-content.js index d306b86..93900a1 100644 --- a/schemas/devotion-content.js +++ b/schemas/devotion-content.js @@ -31,11 +31,25 @@ export default { title: "Title", type: "string" }, + { + name: "slug", + title: "Slug", + type: "slug", + options: { + source: "title", + maxLength: 200, // Will be ignored if slugify is set + slugify: (input) => + input + .toLowerCase() + .replace(/\s+/g, "-") + .slice(0, 200) + } + }, { name: "date", title: "Devotion Date", type: "date", - validation: Rule=>Rule.required() + validation: (Rule) => Rule.required() // validation: (Rule) => // Rule.custom(async (value, context) => { // const isUnique = await isUniqueDate(value, context); From 3801739e773ed25d46e8884f5f4b353b42a2bb60 Mon Sep 17 00:00:00 2001 From: Bratalix Date: Sat, 5 Aug 2023 09:48:32 +1000 Subject: [PATCH 5/6] devotions --- schemas/devotion-content.js | 2 +- structure.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/schemas/devotion-content.js b/schemas/devotion-content.js index 93900a1..5c69421 100644 --- a/schemas/devotion-content.js +++ b/schemas/devotion-content.js @@ -71,7 +71,7 @@ export default { }, prepare(selection) { const { id } = selection; - const title = `${selection.date} ${selection.title}`; + const title = `${selection.title}`; return { title, media: diff --git a/structure.js b/structure.js index 1289460..7b1308d 100644 --- a/structure.js +++ b/structure.js @@ -95,7 +95,10 @@ export default () => { .child( S.documentTypeList("devotionContent") .title("Devotions") - .defaultOrdering([{ field: "date", direction: "desc" }]) + .defaultOrdering([ + { field: "date", direction: "asc" }, + { field: "title", direction: "asc" } + ]) ) ]) ), From a03d44f4221725f365157b7f519cea4159497c59 Mon Sep 17 00:00:00 2001 From: Bratalix Date: Sat, 28 Oct 2023 14:53:42 +1100 Subject: [PATCH 6/6] schema updates --- schemas/custom-internal-page.js | 26 ++++++++++++++++++++++++++ schemas/main.js | 3 ++- schemas/schema.js | 4 +++- structure.js | 4 ++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 schemas/custom-internal-page.js diff --git a/schemas/custom-internal-page.js b/schemas/custom-internal-page.js new file mode 100644 index 0000000..d0b1e40 --- /dev/null +++ b/schemas/custom-internal-page.js @@ -0,0 +1,26 @@ +export default { + name: "customInternalPage", + title: "Custom Internal Page", + type: "document", + fields: [ + { + name: "title", + title: "Title", + type: "string" + }, + { + name: "slug", + title: "Slug", + type: "slug", + options: { + source: "title", + maxLength: 200, // Will be ignored if slugify is set + slugify: (input) => + input + .toLowerCase() + .replace(/\s+/g, "-") + .slice(0, 200) + } + } + ] +}; diff --git a/schemas/main.js b/schemas/main.js index 6fa69b2..f8554b9 100644 --- a/schemas/main.js +++ b/schemas/main.js @@ -74,7 +74,8 @@ export default { { type: "liturgy" }, { type: "scripture" }, { type: "asset" }, - { type: "externalUrl" } + { type: "externalUrl" }, + { type: "customInternalPage" } ] }, { diff --git a/schemas/schema.js b/schemas/schema.js index 7c72111..83d471b 100644 --- a/schemas/schema.js +++ b/schemas/schema.js @@ -25,6 +25,7 @@ import externalUrl from "./external-url"; import video from "./video"; import restrictedContent from "./restricted-content"; import devotionContent from "./devotion-content"; +import customInternalPage from "./custom-internal-page"; export default createSchema({ name: "default", @@ -52,6 +53,7 @@ export default createSchema({ externalUrl, video, restrictedContent, - devotionContent + devotionContent, + customInternalPage ]) }); diff --git a/structure.js b/structure.js index 7b1308d..0ac3d14 100644 --- a/structure.js +++ b/structure.js @@ -89,6 +89,10 @@ export default () => { .title("External URLs") .icon(MdLink) .child(S.documentTypeList("externalUrl").title("External URLs")), + S.listItem() + .title("Custom Internal Pages") + .icon(MdLink) + .child(S.documentTypeList("customInternalPage").title("Custom Internal Pages")), S.listItem() .title("Devotions") .icon(FaBible)