diff --git a/sanity/schemas/article-new.js b/sanity/schemas/article-new.js new file mode 100644 index 0000000..d870a66 --- /dev/null +++ b/sanity/schemas/article-new.js @@ -0,0 +1,50 @@ +import { localize } from "../utils/locale"; + +export default { + title: "New article", + name: "newArticle", + type: "document", + fields: [ + { + title: "Article title", + name: "articleTitle", + type: "string" + }, + { + title: "Article Content", + name: "articleContent", + type: "array", + of: [ + localize( + { + title: "Body", + name: "body", + type: "array", + of: [ + { type: "block" }, + { + type: "image", + options: { hotspot: true } + }, + { type: "youtube" }, + { type: "iframe" } + ] + }, + (lang, Rule) => (lang.isDefault ? Rule.required() : undefined) + ), + { + title: "Quotes", + name: "quotes", + type: "object", + fields: [ + { + title: "Quote text", + name: "quoteText", + type: "string" + } + ] + } + ] + } + ] +}; diff --git a/sanity/schemas/schema.js b/sanity/schemas/schema.js index 5b91196..3856b05 100644 --- a/sanity/schemas/schema.js +++ b/sanity/schemas/schema.js @@ -35,6 +35,7 @@ import externalLink from "./types/external-link"; import internalLink from "./types/internal-link"; import youtube from "./types/youtube"; import iframe from "./types/iframe"; +import articleNew from "./article-new"; // Then we give our schema to the builder and provide the result to Sanity export default createSchema({ @@ -70,6 +71,7 @@ export default createSchema({ internalLink, externalLink, youtube, - iframe + iframe, + articleNew ]) }); diff --git a/web/src/app.tsx b/web/src/app.tsx index 5cd4e09..56c2264 100644 --- a/web/src/app.tsx +++ b/web/src/app.tsx @@ -22,6 +22,7 @@ import { import ErrorPage from "./pages/error"; import Partner from "./pages/partner"; import Live from "./pages/live"; +import NewArticle from "./pages/new-article"; const App: React.FC = () => { const { data, error } = useSWR< @@ -65,6 +66,7 @@ const App: React.FC = () => {
+ diff --git a/web/src/pages/new-article.tsx b/web/src/pages/new-article.tsx new file mode 100644 index 0000000..64c41c7 --- /dev/null +++ b/web/src/pages/new-article.tsx @@ -0,0 +1,30 @@ +import React from "react"; +import { RouteComponentProps } from "@reach/router"; +import useSWR from "swr"; +import { SanityNewArticle } from "../sanity/models"; +import Loading from "../components/loading"; +import NotFound from "./not-found"; +import Error from "./error"; + +type Props = { slug?: string } & RouteComponentProps; + +const NewArticle: React.FC = () => { + // const { slug } = props; + + const { data: article, error } = useSWR( + `*[_type == "newArticle"][0]{...}` + ); + console.log("new article ", article); + + if (error) return ; + if (article === undefined) return ; + if (article === null) return ; + + return ( +
+

New Article

+
+ ); +}; + +export default NewArticle; diff --git a/web/src/sanity/models.ts b/web/src/sanity/models.ts index 517eb36..3ac36ab 100644 --- a/web/src/sanity/models.ts +++ b/web/src/sanity/models.ts @@ -239,6 +239,31 @@ export type SanityArticle = SanityDocument< } >; +export type SanityNewArticle = SanityDocument< + "newArticle", + { + // slug: { current: string }; + title: Locale; + // publishedAt: string; + articleContent: Locale< + SanityObjectArray< + | SanityBlock + | SanityObject< + "quotes", + { + title: string; + } + > + > + >; + + // image: SanityImage; + // summary: Locale; + // body: Locale>; + // credits: Locale; + } +>; + export type SanityArticleList = Array; export type SanityArchive = SanityDocument<