Skip to content

Commit

Permalink
Add single blog post page
Browse files Browse the repository at this point in the history
  • Loading branch information
dv297 committed Sep 22, 2022
1 parent 5d60fc6 commit e02bc1d
Show file tree
Hide file tree
Showing 30 changed files with 12,346 additions and 23 deletions.
3 changes: 3 additions & 0 deletions blog/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@sanity/eslint-config-studio"
}
12 changes: 12 additions & 0 deletions blog/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Logs
/logs
*.log

# Coverage directory used by tools like istanbul
/coverage

# Dependency directories
node_modules

# Compiled sanity studio
/dist
11 changes: 11 additions & 0 deletions blog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Sanity Blogging Content Studio

Congratulations, you have now installed the Sanity Content Studio, an open source real-time content editing environment connected to the Sanity backend.

Now you can do the following things:

- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
- Check out the example frontend: [React/Next.js](https://github.com/sanity-io/tutorial-sanity-blog-react-next)
- [Read the blog post about this template](https://www.sanity.io/blog/build-your-own-blog-with-sanity-and-next-js?utm_source=readme)
- [Join the community Slack](https://slack.sanity.io/?utm_source=readme)
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)
8 changes: 8 additions & 0 deletions blog/config/.checksums
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"#": "Used by Sanity to keep track of configuration file checksums, do not delete or modify!",
"@sanity/default-layout": "bb034f391ba508a6ca8cd971967cbedeb131c4d19b17b28a0895f32db5d568ea",
"@sanity/default-login": "e2ed4e51e97331c0699ba7cf9f67cbf76f1c6a5f806d6eabf8259b2bcb5f1002",
"@sanity/form-builder": "b38478227ba5e22c91981da4b53436df22e48ff25238a55a973ed620be5068aa",
"@sanity/data-aspects": "d199e2c199b3e26cd28b68dc84d7fc01c9186bf5089580f2e2446994d36b3cb6",
"@sanity/vision": "da5b6ed712703ecd04bf4df560570c668aa95252c6bc1c41d6df1bda9b8b8f60"
}
3 changes: 3 additions & 0 deletions blog/config/@sanity/data-aspects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"listOptions": {}
}
6 changes: 6 additions & 0 deletions blog/config/@sanity/default-layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"toolSwitcher": {
"order": [],
"hidden": []
}
}
8 changes: 8 additions & 0 deletions blog/config/@sanity/default-login.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"providers": {
"mode": "append",
"redirectOnSingle": false,
"entries": []
},
"loginMethod": "dual"
}
5 changes: 5 additions & 0 deletions blog/config/@sanity/form-builder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"images": {
"directUploads": true
}
}
3 changes: 3 additions & 0 deletions blog/config/@sanity/vision.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"defaultApiVersion": "2021-10-21"
}
35 changes: 35 additions & 0 deletions blog/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "planner",
"private": true,
"version": "1.0.0",
"description": "",
"main": "package.json",
"author": "Daniel Vu <dev.daniel.vu@gmail.com>",
"license": "UNLICENSED",
"scripts": {
"start": "sanity start",
"build": "sanity build"
},
"keywords": [
"sanity"
],
"dependencies": {
"@sanity/base": "^2.33.3",
"@sanity/core": "^2.33.3",
"@sanity/default-layout": "^2.33.3",
"@sanity/default-login": "^2.33.3",
"@sanity/desk-tool": "^2.33.3",
"@sanity/eslint-config-studio": "^2.0.0",
"@sanity/vision": "^2.33.3",
"eslint": "^8.6.0",
"prop-types": "^15.7",
"react": "^17.0",
"react-dom": "^17.0",
"styled-components": "^5.2.0"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git@github.com:dv297/planner.git"
}
}
1 change: 1 addition & 0 deletions blog/plugins/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
User-specific packages can be placed here
29 changes: 29 additions & 0 deletions blog/sanity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"root": true,
"project": {
"name": "planner"
},
"api": {
"projectId": "vvbj94z0",
"dataset": "production"
},
"plugins": [
"@sanity/base",
"@sanity/default-layout",
"@sanity/default-login",
"@sanity/desk-tool"
],
"env": {
"development": {
"plugins": [
"@sanity/vision"
]
}
},
"parts": [
{
"name": "part:@sanity/base/schema",
"path": "./schemas/schema"
}
]
}
48 changes: 48 additions & 0 deletions blog/schemas/author.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export default {
name: 'author',
title: 'Author',
type: 'document',
fields: [
{
name: 'name',
title: 'Name',
type: 'string',
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'name',
maxLength: 96,
},
},
{
name: 'image',
title: 'Image',
type: 'image',
options: {
hotspot: true,
},
},
{
name: 'bio',
title: 'Bio',
type: 'array',
of: [
{
title: 'Block',
type: 'block',
styles: [{title: 'Normal', value: 'normal'}],
lists: [],
},
],
},
],
preview: {
select: {
title: 'name',
media: 'image',
},
},
}
65 changes: 65 additions & 0 deletions blog/schemas/blockContent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* This is the schema definition for the rich text fields used for
* for this blog studio. When you import it in schemas.js it can be
* reused in other parts of the studio with:
* {
* name: 'someName',
* title: 'Some title',
* type: 'blockContent'
* }
*/
export default {
title: 'Block Content',
name: 'blockContent',
type: 'array',
of: [
{
title: 'Block',
type: 'block',
// Styles let you set what your user can mark up blocks with. These
// correspond with HTML tags, but you can set any title or value
// you want and decide how you want to deal with it where you want to
// use your content.
styles: [
{title: 'Normal', value: 'normal'},
{title: 'H1', value: 'h1'},
{title: 'H2', value: 'h2'},
{title: 'H3', value: 'h3'},
{title: 'H4', value: 'h4'},
{title: 'Quote', value: 'blockquote'},
],
lists: [{title: 'Bullet', value: 'bullet'}],
// Marks let you mark up inline text in the block editor.
marks: {
// Decorators usually describe a single property – e.g. a typographic
// preference or highlighting by editors.
decorators: [
{title: 'Strong', value: 'strong'},
{title: 'Emphasis', value: 'em'},
],
// Annotations can be any object structure – e.g. a link or a footnote.
annotations: [
{
title: 'URL',
name: 'link',
type: 'object',
fields: [
{
title: 'URL',
name: 'href',
type: 'url',
},
],
},
],
},
},
// You can add additional types here. Note that you can't use
// primitive types such as 'string' and 'number' in the same array
// as a block type.
{
type: 'image',
options: {hotspot: true},
},
],
}
17 changes: 17 additions & 0 deletions blog/schemas/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
name: 'category',
title: 'Category',
type: 'document',
fields: [
{
name: 'title',
title: 'Title',
type: 'string',
},
{
name: 'description',
title: 'Description',
type: 'text',
},
],
}
65 changes: 65 additions & 0 deletions blog/schemas/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export default {
name: 'post',
title: 'Post',
type: 'document',
fields: [
{
name: 'title',
title: 'Title',
type: 'string',
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
maxLength: 96,
},
},
{
name: 'author',
title: 'Author',
type: 'reference',
to: {type: 'author'},
},
{
name: 'mainImage',
title: 'Main image',
type: 'image',
options: {
hotspot: true,
},
},
{
name: 'categories',
title: 'Categories',
type: 'array',
of: [{type: 'reference', to: {type: 'category'}}],
},
{
name: 'publishedAt',
title: 'Published at',
type: 'datetime',
},
{
name: 'body',
title: 'Body',
type: 'blockContent',
},
],

preview: {
select: {
title: 'title',
author: 'author.name',
media: 'mainImage',
},
prepare(selection) {
const {author} = selection
return Object.assign({}, selection, {
subtitle: author && `by ${author}`,
})
},
},
}
29 changes: 29 additions & 0 deletions blog/schemas/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// First, we must import the schema creator
import createSchema from 'part:@sanity/base/schema-creator'

// Then import schema types from any plugins that might expose them
import schemaTypes from 'all:part:@sanity/base/schema-type'

// We import object and document schemas
import blockContent from './blockContent'
import category from './category'
import post from './post'
import author from './author'

// Then we give our schema to the builder and provide the result to Sanity
export default createSchema({
// We name our schema
name: 'default',
// Then proceed to concatenate our document type
// to the ones provided by any plugins that are installed
types: schemaTypes.concat([
// The following are document types which will appear
// in the studio.
post,
author,
category,
// When added to this list, object types can be used as
// { type: 'typename' } in other document schemas
blockContent,
]),
})
1 change: 1 addition & 0 deletions blog/static/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Files placed here will be served by the Sanity server under the `/static`-prefix
Binary file added blog/static/favicon.ico
Binary file not shown.
6 changes: 6 additions & 0 deletions blog/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
// Note: This config is only used to help editors like VS Code understand/resolve
// parts, the actual transpilation is done by babel. Any compiler configuration in
// here will be ignored.
"include": ["./node_modules/@sanity/base/types/**/*.ts", "./**/*.ts", "./**/*.tsx"]
}
Loading

0 comments on commit e02bc1d

Please sign in to comment.