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/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/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/devotion-content.js b/schemas/devotion-content.js new file mode 100644 index 0000000..5c69421 --- /dev/null +++ b/schemas/devotion-content.js @@ -0,0 +1,81 @@ +import React from "react"; +import MenuReference from "../menu-refs"; +// import client from "part:@sanity/base/client"; +// import groq from "groq"; + +// const isUniqueDate = (date, context) => { +// const { document } = context; +// const id = document._id.replace(/^drafts\./, ""); +// const params = { +// draft: `drafts.${id}`, +// published: id, +// date +// }; + +// const query = groq`!defined(*[ +// _type == 'devotionContent' && +// !(_id in ['${params.draft}', '${params.published}']) && +// date == '${date}' +// ][0]._id)`; + +// return client.fetch(query); +// }; + +export default { + name: "devotionContent", + title: "Devotion", + 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) + } + }, + { + name: "date", + title: "Devotion Date", + type: "date", + validation: (Rule) => Rule.required() + // 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.title}`; + return { + title, + media: + }; + } + } +}; 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 cd6a1d5..83d471b 100644 --- a/schemas/schema.js +++ b/schemas/schema.js @@ -24,6 +24,8 @@ import relativeUrl from "./relative-url"; 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", @@ -50,6 +52,8 @@ export default createSchema({ relativeUrl, externalUrl, video, - restrictedContent + restrictedContent, + devotionContent, + customInternalPage ]) }); diff --git a/structure.js b/structure.js index 0297390..0ac3d14 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,25 @@ 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("Custom Internal Pages") + .icon(MdLink) + .child(S.documentTypeList("customInternalPage").title("Custom Internal Pages")), + S.listItem() + .title("Devotions") + .icon(FaBible) + .child( + S.documentTypeList("devotionContent") + .title("Devotions") + .defaultOrdering([ + { field: "date", direction: "asc" }, + { field: "title", direction: "asc" } + ]) + ) ]) ), 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"