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

Blog #67

Draft
wants to merge 50 commits into
base: main
Choose a base branch
from
Draft

Blog #67

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a5a9d98
Update author.ts
cdedreuille Jun 13, 2024
bcbd163
Update author.ts
cdedreuille Jun 13, 2024
93be4f7
Add first fetch
cdedreuille Jun 13, 2024
25f03c9
Fetch data for single blog post
cdedreuille Jun 13, 2024
e2f6569
Make url work
cdedreuille Jun 13, 2024
f146c42
Slightly improve look and feel of blog posts
cdedreuille Jun 13, 2024
ed9e892
Improve blog homepage
cdedreuille Jun 13, 2024
2ac7036
Update page.tsx
cdedreuille Jun 13, 2024
4fb8cdc
Merge branch 'main' into blog
cdedreuille Jun 21, 2024
97aef0f
Update package-lock.json
cdedreuille Jun 21, 2024
0dda0d4
Start improving content
cdedreuille Jun 21, 2024
703d474
Merge branch 'main' into blog
cdedreuille Jun 26, 2024
2342d17
Update versions
cdedreuille Jun 26, 2024
1f6bf20
Fix imports
cdedreuille Jun 26, 2024
b3b32e7
Update layout.tsx
cdedreuille Jun 26, 2024
7cfb15c
Merge branch 'main' into blog
cdedreuille Jun 26, 2024
dcc469b
Finish working on syntax highlighting
cdedreuille Jun 26, 2024
f1b1b7b
Update page.tsx
cdedreuille Jun 26, 2024
f400e1f
Add image support for blog post
cdedreuille Jun 26, 2024
dba7346
Add copy + share + newsletter form
cdedreuille Jun 26, 2024
5f13b2f
Continue
cdedreuille Jun 26, 2024
b18adf8
Merge branch 'main' into blog
cdedreuille Jun 30, 2024
7211c20
Add route
cdedreuille Jun 30, 2024
1dcea3a
Update CMS
cdedreuille Jun 30, 2024
3a04a3a
Update
cdedreuille Jul 1, 2024
46b1398
Update layout.tsx
cdedreuille Jul 1, 2024
351e3cd
Update page.tsx
cdedreuille Jul 1, 2024
060925c
Update image
cdedreuille Jul 1, 2024
01f99e3
Improve styling
cdedreuille Jul 1, 2024
1ed3461
Updates
cdedreuille Jul 1, 2024
633b1b8
Updating post footer
cdedreuille Jul 1, 2024
b842bd0
Update page.tsx
cdedreuille Jul 1, 2024
23167d5
Update page.tsx
cdedreuille Jul 1, 2024
7e40b84
Merge branch 'main' into blog
cdedreuille Jul 2, 2024
fd806db
Update package-lock.json
cdedreuille Jul 2, 2024
c2841aa
Add video + quote support
cdedreuille Jul 2, 2024
72c7493
Update body.tsx
cdedreuille Jul 2, 2024
5f6422d
Finish coding search
cdedreuille Jul 2, 2024
33eb0fc
Start adding rss
cdedreuille Jul 2, 2024
e006c7a
First pass on RSS feed
cdedreuille Jul 2, 2024
fd48394
Update route.ts
cdedreuille Jul 2, 2024
4453b94
Add caption for images
cdedreuille Jul 2, 2024
5b9ad58
Add tags
cdedreuille Jul 2, 2024
9541de0
Update blockContent.tsx
cdedreuille Jul 2, 2024
f8055de
Add Youtube module
cdedreuille Jul 2, 2024
d5dbba9
Update blockContent.tsx
cdedreuille Jul 2, 2024
bcf048f
Update blockContent.tsx
cdedreuille Jul 2, 2024
9c14a30
Update blockContent.tsx
cdedreuille Jul 3, 2024
65be10d
Update blog posts
cdedreuille Jul 3, 2024
d8310ea
Improve link block preview
cdedreuille Jul 3, 2024
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
6 changes: 4 additions & 2 deletions apps/cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
"sanity"
],
"dependencies": {
"@sanity/vision": "^3.46.0",
"@sanity/vision": "^3.48.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sanity": "^3.46.0",
"react-player": "^2.16.0",
"sanity": "^3.48.0",
"sanity-plugin-media": "^2.2.5",
"styled-components": "^6.1.8"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion apps/cms/sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {visionTool} from '@sanity/vision'
import {schemaTypes} from './schemaTypes'
import {codeInput} from '@sanity/code-input'
import {media} from 'sanity-plugin-media'

export default defineConfig({
name: 'default',
Expand All @@ -10,7 +12,7 @@ export default defineConfig({
projectId: '2fn86m3z',
dataset: 'production',

plugins: [structureTool(), visionTool()],
plugins: [structureTool(), visionTool(), codeInput(), media()],

schema: {
types: schemaTypes,
Expand Down
5 changes: 5 additions & 0 deletions apps/cms/schemaTypes/author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export default defineType({
},
],
}),
defineField({
name: 'twitter',
title: 'Twitter',
type: 'string',
}),
],
preview: {
select: {
Expand Down
67 changes: 0 additions & 67 deletions apps/cms/schemaTypes/blockContent.ts

This file was deleted.

242 changes: 242 additions & 0 deletions apps/cms/schemaTypes/blockContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
import SanityImageUrlBuilder from '@sanity/image-url'
import {defineType, defineArrayMember, defineField, PreviewProps} from 'sanity'
import {PlayIcon, TwitterIcon, ImageIcon, DocumentIcon, LinkIcon} from '@sanity/icons'
import {Flex, Text, Box} from '@sanity/ui'
import YouTubePlayer from 'react-player/youtube'

const imageUrlBuilder = SanityImageUrlBuilder({
projectId: '2fn86m3z',
dataset: 'production',
})

export function YouTubePreview(props: PreviewProps) {
const {title: url} = props

return (
<Flex padding={3} align="center" justify="center">
{typeof url === 'string' ? <YouTubePlayer url={url} /> : <Text>Add a YouTube URL</Text>}
</Flex>
)
}

export function ImagePreview({image, large, caption}: any) {
const url = image ? imageUrlBuilder.image(image).width(600).url() : ''

return (
<Flex padding={3} direction="column">
{url ? (
<img src={url} alt="" style={{width: '100%'}} />
) : (
<Box style={{backgroundColor: 'rgba(82, 104, 252, 0.06)', height: 200, borderRadius: 4}} />
)}
<div
style={{
paddingTop: '1rem',
}}
>
<span
style={{
display: 'inline-block',
fontFamily:
'Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue","Liberation Sans",Helvetica,Arial,system-ui,sans-serif',
fontWeight: 400,
fontSize: '0.8125rem',
letterSpacing: '0',
}}
>
{large ? 'Large' : 'Fit'} - {caption ? caption : 'No caption'}
</span>
</div>
</Flex>
)
}

export default defineType({
title: 'Block Content',
name: 'blockContent',
type: 'array',
of: [
defineArrayMember({
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'},
{title: 'Numbered', value: 'number'},
],
// 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'},
{title: 'Code', value: 'code'},
],
// 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.
defineArrayMember({
type: 'code',
name: 'code',
title: 'Code',
}),
defineArrayMember({
type: 'object',
name: 'image-block',
title: 'Image',
icon: ImageIcon,
components: {
preview: ImagePreview,
},
fields: [
{
type: 'image',
name: 'image',
title: 'Image',
},
{
type: 'boolean',
name: 'large',
title: 'Is large?',
initialValue: false,
},
{
type: 'string',
name: 'caption',
title: 'Caption',
},
],
preview: {
select: {
image: 'image',
large: 'large',
caption: 'caption',
},
},
}),
defineArrayMember({
type: 'object',
name: 'tweet',
title: 'Tweet',
icon: TwitterIcon,
fields: [
{
type: 'string',
name: 'tweetId',
title: 'Tweet ID',
},
],
}),
defineArrayMember({
type: 'object',
name: 'video',
title: 'Video',
icon: PlayIcon,
fields: [
{
type: 'file',
name: 'videoFile',
title: 'Video File',
},
{
type: 'string',
name: 'caption',
title: 'Caption',
},
],
}),
defineArrayMember({
name: 'youtube',
type: 'object',
title: 'YouTube',
icon: PlayIcon,
fields: [
defineField({
name: 'url',
type: 'url',
title: 'YouTube video URL',
}),
],
preview: {
select: {title: 'url'},
},
components: {
preview: YouTubePreview,
},
}),
defineArrayMember({
name: 'post-block',
type: 'object',
title: 'Post',
icon: DocumentIcon,
fields: [
defineField({
name: 'post',
type: 'reference',
title: 'Post',
to: [{type: 'post'}],
}),
],
preview: {
select: {
title: 'post.title',
subtitle: 'post.subtitle',
media: 'post.mainImage',
},
},
}),
defineArrayMember({
name: 'link-block',
type: 'object',
title: 'Link',
icon: LinkIcon,
fields: [
defineField({
name: 'url',
type: 'url',
title: 'Url',
}),
],
preview: {
select: {
title: 'url',
},
prepare({title}) {
return {
title,
subtitle: 'We will show a preview of the link in the blog post.',
}
},
},
}),
],
})
19 changes: 0 additions & 19 deletions apps/cms/schemaTypes/category.ts

This file was deleted.

4 changes: 2 additions & 2 deletions apps/cms/schemaTypes/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import blockContent from './blockContent'
import category from './category'
import tag from './tag'
import post from './post'
import author from './author'

export const schemaTypes = [post, author, category, blockContent]
export const schemaTypes = [post, author, tag, blockContent]
Loading