From 1f0814389cdcba811ba432dd0f3e40e95c9f3988 Mon Sep 17 00:00:00 2001 From: Nyoman Sunima Date: Wed, 2 Aug 2023 16:59:14 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=8F=80=20update:=20add=20the=20series?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/studio/schemas/documents/blog.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/studio/schemas/documents/blog.ts b/apps/studio/schemas/documents/blog.ts index 62890b2..6aefbe2 100644 --- a/apps/studio/schemas/documents/blog.ts +++ b/apps/studio/schemas/documents/blog.ts @@ -56,6 +56,12 @@ export default defineType({ type: 'array', of: [{ type: 'string' }], }), + defineField({ + title: 'Series', + name: 'series', + type: 'reference', + to: [{ type: 'series' }], + }), defineField({ title: 'Content', name: 'content', From e3f466a7fc0e9531236c3ddc1e8bd2a1ab2636ce Mon Sep 17 00:00:00 2001 From: Nyoman Sunima Date: Wed, 2 Aug 2023 16:59:44 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=9A=9C=20chore:=20add=20the=20series?= =?UTF-8?q?=20docus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/studio/schemas/documents/series.ts | 41 +++++++++++++++++++++++++ apps/studio/schemas/index.ts | 2 ++ 2 files changed, 43 insertions(+) create mode 100644 apps/studio/schemas/documents/series.ts diff --git a/apps/studio/schemas/documents/series.ts b/apps/studio/schemas/documents/series.ts new file mode 100644 index 0000000..69178ed --- /dev/null +++ b/apps/studio/schemas/documents/series.ts @@ -0,0 +1,41 @@ +import { Calendar } from 'react-iconly' +import { defineField, defineType } from 'sanity' + +export default defineType({ + title: 'Blog Series', + name: 'series', + type: 'document', + icon: Calendar, + fields: [ + defineField({ + title: 'Image', + name: 'thumbnail', + type: 'image', + }), + defineField({ + title: 'SLUG', + name: 'slug', + type: 'slug', + options: { + source: 'title', + }, + }), + defineField({ + title: 'Title', + name: 'title', + type: 'string', + }), + defineField({ + title: 'Description', + name: 'desc', + type: 'text', + }), + ], + preview: { + select: { + media: 'thumbnail', + title: 'title', + subtitle: 'slug.current', + }, + }, +}) diff --git a/apps/studio/schemas/index.ts b/apps/studio/schemas/index.ts index f7df8c7..48df5ff 100644 --- a/apps/studio/schemas/index.ts +++ b/apps/studio/schemas/index.ts @@ -4,6 +4,7 @@ import faq from './documents/faq' import page from './documents/page' import product from './documents/product' import project from './documents/project' +import series from './documents/series' import timeline from './documents/timeline' import bio from './objects/content/bio' @@ -16,4 +17,5 @@ export const schemaTypes = [ faq, app, product, + series, ] From 61dbb96aa4585ff73dc94098e13f147c41ad741e Mon Sep 17 00:00:00 2001 From: Nyoman Sunima Date: Wed, 2 Aug 2023 17:00:37 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=94=A5=20update:=20add=20the=20type?= =?UTF-8?q?=20and=20query=20to=20fetch=20series?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/lib/queries.ts | 27 +++++++++++++++++++++++++++ apps/web/types/content.d.ts | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/apps/web/lib/queries.ts b/apps/web/lib/queries.ts index 7f9a6ef..c0c6b0a 100644 --- a/apps/web/lib/queries.ts +++ b/apps/web/lib/queries.ts @@ -93,6 +93,12 @@ export const blogQuery = ` featured, "isIncoming": "Incoming" in tags[], }, + "series": *[_type == "series"]{ + "slug": slug.current, + "thumbnail": thumbnail.asset -> url, + title, + desc, + }, "latest": *[_type == "blog"] | order(_updatedAt desc){ "slug": slug.current, title, @@ -138,3 +144,24 @@ export const productsQuery = ` } } ` + +export const loadSeriesDetail = ` + { + "detail": *[_type == "series" && slug.current == $slug][0]{ + title, + desc, + "thumbnail": thumbnail.asset -> url, + "slug": slug.current, + "totalContent": count(*[_type == "blog" && references(^._id)]) + }, + "contents": *[_type == "blog" && references(*[_type == "series" && slug.current == $slug][0]._id)] | order(_createdAt desc){ + "slug": slug.current, + title, + "thumbnail": thumbnail.asset -> url, + "tag": tags[0], + _createdAt, + featured, + "isIncoming": "Incoming" in tags[], + } + } +` diff --git a/apps/web/types/content.d.ts b/apps/web/types/content.d.ts index 2c91076..7c513b0 100644 --- a/apps/web/types/content.d.ts +++ b/apps/web/types/content.d.ts @@ -8,6 +8,24 @@ export interface BlogPost { isIncoming: boolean } +export interface BlogSeries { + thumbnail: string + title: string + slug: string + desc: string +} + +export interface BlogSeriesDetail { + detail: { + thumbnail: string + title: string + slug: string + desc: string + totalContent: number + } + contents: BlogPost[] +} + export interface BlogDetail { post: { slug: string From 145575f81b3d37d0d89f3cece7f9c359e00314e7 Mon Sep 17 00:00:00 2001 From: Nyoman Sunima Date: Wed, 2 Aug 2023 17:01:03 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=8F=80=20chore:=20add=20the=20series?= =?UTF-8?q?=20sections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/pages/blog/index.vue | 19 +++++-- apps/web/pages/blog/series/[slug].vue | 79 +++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 apps/web/pages/blog/series/[slug].vue diff --git a/apps/web/pages/blog/index.vue b/apps/web/pages/blog/index.vue index e4d634b..fb3f2d5 100644 --- a/apps/web/pages/blog/index.vue +++ b/apps/web/pages/blog/index.vue @@ -1,8 +1,8 @@