├── .gitignore
├── README.md
├── netlify.toml
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
├── src
├── App.css
├── App.js
├── App.test.js
├── client.js
├── components
│ └── Header.js
├── index.css
├── index.js
├── logo.svg
├── pages
│ ├── Blog.js
│ ├── Error.js
│ ├── Homepage.js
│ └── SinglePost.js
├── reportWebVitals.js
└── setupTests.js
└── youtubeblog
├── README.md
├── config
├── .checksums
└── @sanity
│ ├── data-aspects.json
│ ├── default-layout.json
│ ├── default-login.json
│ └── form-builder.json
├── package.json
├── plugins
└── .gitkeep
├── sanity.json
├── schemas
├── author.js
├── blockContent.js
├── category.js
├── post.js
└── schema.js
├── static
├── .gitkeep
└── favicon.ico
├── tsconfig.json
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13 |
14 | The page will reload if you make edits.\
15 | You will also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35 |
36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39 |
40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/netlify.toml:
--------------------------------------------------------------------------------
1 | [[redirects]]
2 | from = "/*"
3 | to = "/index.html"
4 | status = 200
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "youtube-blog",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@sanity/block-content-to-react": "^3.0.0",
7 | "@sanity/client": "^2.13.0",
8 | "@testing-library/jest-dom": "^5.14.1",
9 | "@testing-library/react": "^11.2.7",
10 | "@testing-library/user-event": "^12.8.3",
11 | "react": "^17.0.2",
12 | "react-dom": "^17.0.2",
13 | "react-router-dom": "^5.2.0",
14 | "react-scripts": "4.0.3",
15 | "web-vitals": "^1.1.2"
16 | },
17 | "scripts": {
18 | "start": "react-scripts start",
19 | "build": "react-scripts build",
20 | "test": "react-scripts test",
21 | "eject": "react-scripts eject"
22 | },
23 | "eslintConfig": {
24 | "extends": [
25 | "react-app",
26 | "react-app/jest"
27 | ]
28 | },
29 | "browserslist": {
30 | "production": [
31 | ">0.2%",
32 | "not dead",
33 | "not op_mini all"
34 | ],
35 | "development": [
36 | "last 1 chrome version",
37 | "last 1 firefox version",
38 | "last 1 safari version"
39 | ]
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SankThomas/reactjs-sanity-blog/93c8143f87a0fce3c2c56dfde12348d549db37e0/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 |
28 |
29 |
33 |
40 | Blog using Sanity CMS
41 |
42 |
43 | You need to enable JavaScript to run this app.
44 |
45 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SankThomas/reactjs-sanity-blog/93c8143f87a0fce3c2c56dfde12348d549db37e0/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SankThomas/reactjs-sanity-blog/93c8143f87a0fce3c2c56dfde12348d549db37e0/public/logo512.png
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import { BrowserRouter, Route, Switch } from "react-router-dom"
2 | import Header from "./components/Header"
3 | import Homepage from "./pages/Homepage"
4 | import Blog from "./pages/Blog"
5 | import SinglePost from "./pages/SinglePost"
6 | import Error from "./pages/Error"
7 |
8 | function App() {
9 | return (
10 |
11 |
12 |
13 |
14 |
15 |
16 | }>
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | )
26 | }
27 |
28 | export default App
29 |
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render( );
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/src/client.js:
--------------------------------------------------------------------------------
1 | import client from "@sanity/client"
2 |
3 | export default client({
4 | projectId: "2hp9gld0",
5 | dataset: "production",
6 | useCdn: true,
7 | apiVersion: "2021-08-05",
8 | })
9 |
--------------------------------------------------------------------------------
/src/components/Header.js:
--------------------------------------------------------------------------------
1 | import { Link } from "react-router-dom"
2 |
3 | export default function Header() {
4 | return (
5 | <>
6 |
30 | >
31 | )
32 | }
33 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: "Tajawal", sans-serif;
4 | -webkit-font-smoothing: antialiased;
5 | -moz-osx-font-smoothing: grayscale;
6 | background-color: #f1f1f1;
7 | }
8 |
9 | img {
10 | max-width: 100%;
11 | margin: auto;
12 | }
13 |
14 | .block__content p {
15 | line-height: 1.6;
16 | }
17 |
18 | .block__content h2 {
19 | font-weight: 700;
20 | font-size: 32px;
21 | margin: 10px 0 20px;
22 | }
23 |
24 | @media (min-width: 768px) {
25 | img.blog__image {
26 | height: 600px;
27 | width: 100%;
28 | }
29 |
30 | .block__content p {
31 | font-size: 18px;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/pages/Blog.js:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from "react"
2 | import { Link } from "react-router-dom"
3 | import client from "../client"
4 |
5 | export default function Blog() {
6 | const [posts, setPosts] = useState([])
7 |
8 | useEffect(() => {
9 | client
10 | .fetch(
11 | `*[_type == "post"] {
12 | title,
13 | slug,
14 | body,
15 | mainImage {
16 | asset -> {
17 | _id,
18 | url
19 | },
20 | alt
21 | }
22 | }`
23 | )
24 | .then((data) => setPosts(data))
25 | .catch(console.error)
26 | }, [])
27 |
28 | return (
29 | <>
30 |
31 |
32 | Blog page
33 |
34 |
35 |
36 | {posts.map((post) => (
37 |
38 |
39 | {post.title}
40 |
41 |
45 | Read Full Article
46 |
47 |
48 |
49 | ))}
50 |
51 |
52 | >
53 | )
54 | }
55 |
--------------------------------------------------------------------------------
/src/pages/Error.js:
--------------------------------------------------------------------------------
1 | import { Link } from "react-router-dom"
2 |
3 | export default function Error() {
4 | return (
5 |
6 |
7 | Error 404 | Page Not Found
8 |
9 |
13 | Back to homepage
14 |
15 |
16 | )
17 | }
18 |
--------------------------------------------------------------------------------
/src/pages/Homepage.js:
--------------------------------------------------------------------------------
1 | import { Link } from "react-router-dom"
2 |
3 | export default function Homepage() {
4 | return (
5 |
6 |
7 |
8 | Sankara's Blog
9 |
10 |
11 |
15 | Read my blog posts
16 |
17 |
18 |
19 |
20 | )
21 | }
22 |
--------------------------------------------------------------------------------
/src/pages/SinglePost.js:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from "react"
2 | import { Link, useParams } from "react-router-dom"
3 | import client from "../client"
4 | import BlockContent from "@sanity/block-content-to-react"
5 |
6 | export default function SinglePost() {
7 | const [singlePost, setSinglePost] = useState([])
8 | const [isLoading, setIsLoading] = useState(true)
9 | const { slug } = useParams()
10 |
11 | useEffect(() => {
12 | client
13 | .fetch(
14 | `*[slug.current == "${slug}"] {
15 | title,
16 | body,
17 | mainImage {
18 | asset -> {
19 | _id,
20 | url
21 | },
22 | alt
23 | }
24 | }`
25 | )
26 | .then((data) => setSinglePost(data[0]))
27 | setIsLoading(false)
28 | }, [slug])
29 |
30 | return (
31 | <>
32 | {isLoading ? (
33 |
34 | Loading...
35 |
36 | ) : (
37 |
38 |
39 | {singlePost.title}
40 |
41 | {singlePost.mainImage && singlePost.mainImage.asset && (
42 |
48 | )}
49 | By Thomas Sankara
50 |
51 |
52 |
57 |
58 |
59 |
60 |
64 | Read more articles
65 |
66 |
67 |
68 | )}
69 | >
70 | )
71 | }
72 |
--------------------------------------------------------------------------------
/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/youtubeblog/README.md:
--------------------------------------------------------------------------------
1 | # Sanity Blogging Content Studio
2 |
3 | Congratulations, you have now installed the Sanity Content Studio, an open source real-time content editing environment connected to the Sanity backend.
4 |
5 | Now you can do the following things:
6 |
7 | - [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
8 | - Check out the example frontend: [React/Next.js](https://github.com/sanity-io/tutorial-sanity-blog-react-next)
9 | - [Read the blog post about this template](https://www.sanity.io/blog/build-your-own-blog-with-sanity-and-next-js?utm_source=readme)
10 | - [Join the community Slack](https://slack.sanity.io/?utm_source=readme)
11 | - [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)
12 |
--------------------------------------------------------------------------------
/youtubeblog/config/.checksums:
--------------------------------------------------------------------------------
1 | {
2 | "#": "Used by Sanity to keep track of configuration file checksums, do not delete or modify!",
3 | "@sanity/default-layout": "bb034f391ba508a6ca8cd971967cbedeb131c4d19b17b28a0895f32db5d568ea",
4 | "@sanity/default-login": "6fb6d3800aa71346e1b84d95bbcaa287879456f2922372bb0294e30b968cd37f",
5 | "@sanity/form-builder": "b38478227ba5e22c91981da4b53436df22e48ff25238a55a973ed620be5068aa",
6 | "@sanity/data-aspects": "d199e2c199b3e26cd28b68dc84d7fc01c9186bf5089580f2e2446994d36b3cb6"
7 | }
8 |
--------------------------------------------------------------------------------
/youtubeblog/config/@sanity/data-aspects.json:
--------------------------------------------------------------------------------
1 | {
2 | "listOptions": {}
3 | }
4 |
--------------------------------------------------------------------------------
/youtubeblog/config/@sanity/default-layout.json:
--------------------------------------------------------------------------------
1 | {
2 | "toolSwitcher": {
3 | "order": [],
4 | "hidden": []
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/youtubeblog/config/@sanity/default-login.json:
--------------------------------------------------------------------------------
1 | {
2 | "providers": {
3 | "mode": "append",
4 | "redirectOnSingle": false,
5 | "entries": []
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/youtubeblog/config/@sanity/form-builder.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": {
3 | "directUploads": true
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/youtubeblog/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "youtubeblog",
3 | "private": true,
4 | "version": "1.0.0",
5 | "description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app)",
6 | "main": "package.json",
7 | "author": "Thomas Sankara ",
8 | "license": "UNLICENSED",
9 | "scripts": {
10 | "start": "sanity start",
11 | "build": "sanity build"
12 | },
13 | "keywords": [
14 | "sanity"
15 | ],
16 | "dependencies": {
17 | "@sanity/base": "^2.13.1",
18 | "@sanity/components": "^2.13.0",
19 | "@sanity/core": "^2.13.1",
20 | "@sanity/default-layout": "^2.13.1",
21 | "@sanity/default-login": "^2.13.1",
22 | "@sanity/desk-tool": "^2.13.1",
23 | "@sanity/vision": "^2.13.1",
24 | "prop-types": "^15.7",
25 | "react": "^17.0",
26 | "react-dom": "^17.0"
27 | },
28 | "devDependencies": {}
29 | }
30 |
--------------------------------------------------------------------------------
/youtubeblog/plugins/.gitkeep:
--------------------------------------------------------------------------------
1 | User-specific packages can be placed here
2 |
--------------------------------------------------------------------------------
/youtubeblog/sanity.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "project": {
4 | "name": "youtubeblog"
5 | },
6 | "api": {
7 | "projectId": "2hp9gld0",
8 | "dataset": "production"
9 | },
10 | "plugins": [
11 | "@sanity/base",
12 | "@sanity/components",
13 | "@sanity/default-layout",
14 | "@sanity/default-login",
15 | "@sanity/desk-tool"
16 | ],
17 | "env": {
18 | "development": {
19 | "plugins": [
20 | "@sanity/vision"
21 | ]
22 | }
23 | },
24 | "parts": [
25 | {
26 | "name": "part:@sanity/base/schema",
27 | "path": "./schemas/schema"
28 | }
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/youtubeblog/schemas/author.js:
--------------------------------------------------------------------------------
1 | export default {
2 | name: 'author',
3 | title: 'Author',
4 | type: 'document',
5 | fields: [
6 | {
7 | name: 'name',
8 | title: 'Name',
9 | type: 'string',
10 | },
11 | {
12 | name: 'slug',
13 | title: 'Slug',
14 | type: 'slug',
15 | options: {
16 | source: 'name',
17 | maxLength: 96,
18 | },
19 | },
20 | {
21 | name: 'image',
22 | title: 'Image',
23 | type: 'image',
24 | options: {
25 | hotspot: true,
26 | },
27 | },
28 | {
29 | name: 'bio',
30 | title: 'Bio',
31 | type: 'array',
32 | of: [
33 | {
34 | title: 'Block',
35 | type: 'block',
36 | styles: [{title: 'Normal', value: 'normal'}],
37 | lists: [],
38 | },
39 | ],
40 | },
41 | ],
42 | preview: {
43 | select: {
44 | title: 'name',
45 | media: 'image',
46 | },
47 | },
48 | }
49 |
--------------------------------------------------------------------------------
/youtubeblog/schemas/blockContent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the schema definition for the rich text fields used for
3 | * for this blog studio. When you import it in schemas.js it can be
4 | * reused in other parts of the studio with:
5 | * {
6 | * name: 'someName',
7 | * title: 'Some title',
8 | * type: 'blockContent'
9 | * }
10 | */
11 | export default {
12 | title: 'Block Content',
13 | name: 'blockContent',
14 | type: 'array',
15 | of: [
16 | {
17 | title: 'Block',
18 | type: 'block',
19 | // Styles let you set what your user can mark up blocks with. These
20 | // correspond with HTML tags, but you can set any title or value
21 | // you want and decide how you want to deal with it where you want to
22 | // use your content.
23 | styles: [
24 | {title: 'Normal', value: 'normal'},
25 | {title: 'H1', value: 'h1'},
26 | {title: 'H2', value: 'h2'},
27 | {title: 'H3', value: 'h3'},
28 | {title: 'H4', value: 'h4'},
29 | {title: 'Quote', value: 'blockquote'},
30 | ],
31 | lists: [{title: 'Bullet', value: 'bullet'}],
32 | // Marks let you mark up inline text in the block editor.
33 | marks: {
34 | // Decorators usually describe a single property – e.g. a typographic
35 | // preference or highlighting by editors.
36 | decorators: [
37 | {title: 'Strong', value: 'strong'},
38 | {title: 'Emphasis', value: 'em'},
39 | ],
40 | // Annotations can be any object structure – e.g. a link or a footnote.
41 | annotations: [
42 | {
43 | title: 'URL',
44 | name: 'link',
45 | type: 'object',
46 | fields: [
47 | {
48 | title: 'URL',
49 | name: 'href',
50 | type: 'url',
51 | },
52 | ],
53 | },
54 | ],
55 | },
56 | },
57 | // You can add additional types here. Note that you can't use
58 | // primitive types such as 'string' and 'number' in the same array
59 | // as a block type.
60 | {
61 | type: 'image',
62 | options: {hotspot: true},
63 | },
64 | ],
65 | }
66 |
--------------------------------------------------------------------------------
/youtubeblog/schemas/category.js:
--------------------------------------------------------------------------------
1 | export default {
2 | name: 'category',
3 | title: 'Category',
4 | type: 'document',
5 | fields: [
6 | {
7 | name: 'title',
8 | title: 'Title',
9 | type: 'string',
10 | },
11 | {
12 | name: 'description',
13 | title: 'Description',
14 | type: 'text',
15 | },
16 | ],
17 | }
18 |
--------------------------------------------------------------------------------
/youtubeblog/schemas/post.js:
--------------------------------------------------------------------------------
1 | export default {
2 | name: 'post',
3 | title: 'Post',
4 | type: 'document',
5 | fields: [
6 | {
7 | name: 'title',
8 | title: 'Title',
9 | type: 'string',
10 | },
11 | {
12 | name: 'slug',
13 | title: 'Slug',
14 | type: 'slug',
15 | options: {
16 | source: 'title',
17 | maxLength: 96,
18 | },
19 | },
20 | {
21 | name: 'author',
22 | title: 'Author',
23 | type: 'reference',
24 | to: {type: 'author'},
25 | },
26 | {
27 | name: 'mainImage',
28 | title: 'Main image',
29 | type: 'image',
30 | options: {
31 | hotspot: true,
32 | },
33 | },
34 | {
35 | name: 'categories',
36 | title: 'Categories',
37 | type: 'array',
38 | of: [{type: 'reference', to: {type: 'category'}}],
39 | },
40 | {
41 | name: 'publishedAt',
42 | title: 'Published at',
43 | type: 'datetime',
44 | },
45 | {
46 | name: 'body',
47 | title: 'Body',
48 | type: 'blockContent',
49 | },
50 | ],
51 |
52 | preview: {
53 | select: {
54 | title: 'title',
55 | author: 'author.name',
56 | media: 'mainImage',
57 | },
58 | prepare(selection) {
59 | const {author} = selection
60 | return Object.assign({}, selection, {
61 | subtitle: author && `by ${author}`,
62 | })
63 | },
64 | },
65 | }
66 |
--------------------------------------------------------------------------------
/youtubeblog/schemas/schema.js:
--------------------------------------------------------------------------------
1 | // First, we must import the schema creator
2 | import createSchema from 'part:@sanity/base/schema-creator'
3 |
4 | // Then import schema types from any plugins that might expose them
5 | import schemaTypes from 'all:part:@sanity/base/schema-type'
6 |
7 | // We import object and document schemas
8 | import blockContent from './blockContent'
9 | import category from './category'
10 | import post from './post'
11 | import author from './author'
12 |
13 | // Then we give our schema to the builder and provide the result to Sanity
14 | export default createSchema({
15 | // We name our schema
16 | name: 'default',
17 | // Then proceed to concatenate our document type
18 | // to the ones provided by any plugins that are installed
19 | types: schemaTypes.concat([
20 | // The following are document types which will appear
21 | // in the studio.
22 | post,
23 | author,
24 | category,
25 | // When added to this list, object types can be used as
26 | // { type: 'typename' } in other document schemas
27 | blockContent,
28 | ]),
29 | })
30 |
--------------------------------------------------------------------------------
/youtubeblog/static/.gitkeep:
--------------------------------------------------------------------------------
1 | Files placed here will be served by the Sanity server under the `/static`-prefix
2 |
--------------------------------------------------------------------------------
/youtubeblog/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SankThomas/reactjs-sanity-blog/93c8143f87a0fce3c2c56dfde12348d549db37e0/youtubeblog/static/favicon.ico
--------------------------------------------------------------------------------
/youtubeblog/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | // Note: This config is only used to help editors like VS Code understand/resolve
3 | // parts, the actual transpilation is done by babel. Any compiler configuration in
4 | // here will be ignored.
5 | "include": ["./node_modules/@sanity/base/types/**/*.ts", "./**/*.ts", "./**/*.tsx"]
6 | }
7 |
--------------------------------------------------------------------------------