From fc71667147b1609d96c44e75d63260ce067bdfa5 Mon Sep 17 00:00:00 2001 From: Akash Bhave Date: Sun, 17 Sep 2023 15:18:21 -0400 Subject: [PATCH] Support embeds in blog posts --- .gitignore | 3 + cms/schema.js | 2 + cms/schemas/collections/post.js | 4 +- cms/schemas/modular/block-content.js | 3 +- cms/schemas/modular/captioned-image.js | 2 +- cms/schemas/modular/code-block.js | 2 +- cms/schemas/modular/embed.js | 22 ++ cms/schemas/modular/icon-link.js | 2 +- cms/schemas/singletons/about.js | 2 +- web/package-lock.json | 291 ++++++++++++++++++------- web/package.json | 2 + web/src/components/BlockContent.js | 56 +++++ web/src/components/BlockContentCode.js | 21 -- web/src/pages/gpg.js | 8 +- web/src/pages/index.js | 16 +- web/src/templates/Post.js | 20 +- web/src/utils/sanity.js | 14 ++ 17 files changed, 337 insertions(+), 133 deletions(-) create mode 100644 cms/schemas/modular/embed.js create mode 100644 web/src/components/BlockContent.js delete mode 100644 web/src/components/BlockContentCode.js create mode 100644 web/src/utils/sanity.js diff --git a/.gitignore b/.gitignore index 697fd0a..d6907c2 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,6 @@ sw.* # macOS .DS_Store + +# Local Netlify folder +.netlify diff --git a/cms/schema.js b/cms/schema.js index ce570d2..27f813b 100644 --- a/cms/schema.js +++ b/cms/schema.js @@ -8,6 +8,7 @@ import captionedImage from "./schemas/modular/captioned-image"; import codeBlock from "./schemas/modular/code-block"; import iconLink from "./schemas/modular/icon-link"; import skill from "./schemas/modular/skill"; +import embed from "./schemas/modular/embed"; // Collection schemas import post from "./schemas/collections/post"; import project from "./schemas/collections/project"; @@ -34,5 +35,6 @@ export default createSchema({ codeBlock, iconLink, skill, + embed, ]), }); diff --git a/cms/schemas/collections/post.js b/cms/schemas/collections/post.js index 6889ad6..b56c345 100644 --- a/cms/schemas/collections/post.js +++ b/cms/schemas/collections/post.js @@ -23,7 +23,7 @@ export default { }, { name: "mainImage", - title: "Main Image", + title: "Main image", type: "image", options: { hotspot: true, @@ -56,7 +56,7 @@ export default { }, { name: "publishedAt", - title: "Published At", + title: "Published at", type: "datetime", }, { diff --git a/cms/schemas/modular/block-content.js b/cms/schemas/modular/block-content.js index 99cbf4f..573f8db 100644 --- a/cms/schemas/modular/block-content.js +++ b/cms/schemas/modular/block-content.js @@ -11,7 +11,7 @@ export default { name: "blockContent", - title: "Block Content", + title: "Block content", type: "array", of: [ { @@ -40,5 +40,6 @@ export default { }, { type: "captionedImage" }, { type: "codeBlock" }, + { type: "embed" }, ], }; diff --git a/cms/schemas/modular/captioned-image.js b/cms/schemas/modular/captioned-image.js index 4e33de3..c0d2d70 100644 --- a/cms/schemas/modular/captioned-image.js +++ b/cms/schemas/modular/captioned-image.js @@ -1,6 +1,6 @@ export default { name: "captionedImage", - title: "Captioned Image", + title: "Captioned image", type: "object", fields: [ { diff --git a/cms/schemas/modular/code-block.js b/cms/schemas/modular/code-block.js index 8638ca9..fe49834 100644 --- a/cms/schemas/modular/code-block.js +++ b/cms/schemas/modular/code-block.js @@ -1,6 +1,6 @@ export default { name: "codeBlock", - title: "Code Block", + title: "Code block", type: "object", fields: [ { diff --git a/cms/schemas/modular/embed.js b/cms/schemas/modular/embed.js new file mode 100644 index 0000000..4a82a6a --- /dev/null +++ b/cms/schemas/modular/embed.js @@ -0,0 +1,22 @@ +import React from "react"; + +export default { + title: "Embed", + name: "embed", + type: "object", + fields: [ + { + title: "URL", + name: "url", + type: "url", + }, + ], + preview: { + select: { + url: "url", + }, + component: ({ value }) => ( +