Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devotions #32

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ yarn-error.log*

# secrets shh...
.env
!.env.example
!.env.example

#data imports
/imports*
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 26 additions & 0 deletions schemas/custom-internal-page.js
Original file line number Diff line number Diff line change
@@ -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)
}
}
]
};
81 changes: 81 additions & 0 deletions schemas/devotion-content.js
Original file line number Diff line number Diff line change
@@ -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: <MenuReference id={id} />
};
}
}
};
3 changes: 2 additions & 1 deletion schemas/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export default {
{ type: "liturgy" },
{ type: "scripture" },
{ type: "asset" },
{ type: "externalUrl" }
{ type: "externalUrl" },
{ type: "customInternalPage" }
]
},
{
Expand Down
6 changes: 5 additions & 1 deletion schemas/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -50,6 +52,8 @@ export default createSchema({
relativeUrl,
externalUrl,
video,
restrictedContent
restrictedContent,
devotionContent,
customInternalPage
])
});
21 changes: 18 additions & 3 deletions structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(),
Expand Down
27 changes: 27 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down