Skip to content

Commit 347eea8

Browse files
authored
feat: Attempt to read blog contents from prismic (#33)
1 parent 6cb0583 commit 347eea8

File tree

4 files changed

+194
-31
lines changed

4 files changed

+194
-31
lines changed

app/blog/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { createClient } from '@/lib/prismic';
23
import blogYaml from '@/content/blog.json';
34
import type { BlogPost } from '@/content/blog.json';
45
import Image from 'next/image';
@@ -7,7 +8,13 @@ import ArrowIcon from '@/components/icons/arrow-icon';
78
export const fetchCache = 'force-no-store';
89
export const revalidate = 0;
910

10-
const BlogPage = () => {
11+
const BlogPage = async () => {
12+
try {
13+
const client = createClient();
14+
const { data } = await client.getSingle('blog');
15+
console.log(data);
16+
} catch {}
17+
1118
return (
1219
<div className="mx-auto max-w-7xl py-16 px-4 sm:px-6 lg:px-8">
1320
<div className="mb-12">

app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Home = async (): Promise<ReactElement> => {
3838
description={
3939
//data.hero_description
4040
// Temporary change until we can change it in Prismic
41-
`The Open Visualization Collaboration Space “OpenVis” is a forum within the OpenJS Foundation to neutrally govern a comprehensive and growing suite of widely adopted visualization libraries targeting TypeScript, JavaScript, WebGPU and WebGL.
41+
`The Open Visualization Collaboration Space “OpenVis” is a forum within the OpenJS Foundation to neutrally govern a growing suite of widely adopted visualization libraries targeting TypeScript, JavaScript, WebGPU, WebGL and WebAssembly.
4242
`
4343
}
4444
actions={data.hero_actions}

customtypes/blog/index.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"format": "custom",
3+
"id": "blog",
4+
"label": "Blog",
5+
"repeatable": true,
6+
"status": true,
7+
"json": {
8+
"Main": {
9+
"uid": {
10+
"config": {
11+
"label": "UID"
12+
},
13+
"type": "UID"
14+
},
15+
"entries": {
16+
"type": "Group",
17+
"config": {
18+
"label": "entries",
19+
"repeat": true,
20+
"fields": {
21+
"title": {
22+
"type": "Text",
23+
"config": {
24+
"label": "title",
25+
"placeholder": ""
26+
}
27+
},
28+
"blurb": {
29+
"type": "Text",
30+
"config": {
31+
"label": "blurb",
32+
"placeholder": ""
33+
}
34+
},
35+
"url": {
36+
"type": "Link",
37+
"config": {
38+
"label": "url",
39+
"placeholder": "",
40+
"select": null
41+
}
42+
},
43+
"imageurl": {
44+
"type": "Link",
45+
"config": {
46+
"label": "imageUrl",
47+
"placeholder": "",
48+
"select": null
49+
}
50+
},
51+
"date": {
52+
"type": "Date",
53+
"config": {
54+
"label": "date",
55+
"placeholder": ""
56+
}
57+
},
58+
"publication": {
59+
"type": "Text",
60+
"config": {
61+
"label": "publication",
62+
"placeholder": ""
63+
}
64+
}
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}

prismicio-types.d.ts

Lines changed: 115 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,99 @@ import type * as prismic from '@prismicio/client';
44

55
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };
66

7+
/**
8+
* Item in *Blog → entries*
9+
*/
10+
export interface BlogDocumentDataEntriesItem {
11+
/**
12+
* title field in *Blog → entries*
13+
*
14+
* - **Field Type**: Text
15+
* - **Placeholder**: *None*
16+
* - **API ID Path**: blog.entries[].title
17+
* - **Documentation**: https://prismic.io/docs/field#key-text
18+
*/
19+
title: prismic.KeyTextField;
20+
21+
/**
22+
* blurb field in *Blog → entries*
23+
*
24+
* - **Field Type**: Text
25+
* - **Placeholder**: *None*
26+
* - **API ID Path**: blog.entries[].blurb
27+
* - **Documentation**: https://prismic.io/docs/field#key-text
28+
*/
29+
blurb: prismic.KeyTextField;
30+
31+
/**
32+
* url field in *Blog → entries*
33+
*
34+
* - **Field Type**: Link
35+
* - **Placeholder**: *None*
36+
* - **API ID Path**: blog.entries[].url
37+
* - **Documentation**: https://prismic.io/docs/field#link-content-relationship
38+
*/
39+
url: prismic.LinkField;
40+
41+
/**
42+
* imageUrl field in *Blog → entries*
43+
*
44+
* - **Field Type**: Link
45+
* - **Placeholder**: *None*
46+
* - **API ID Path**: blog.entries[].imageurl
47+
* - **Documentation**: https://prismic.io/docs/field#link-content-relationship
48+
*/
49+
imageurl: prismic.LinkField;
50+
51+
/**
52+
* date field in *Blog → entries*
53+
*
54+
* - **Field Type**: Date
55+
* - **Placeholder**: *None*
56+
* - **API ID Path**: blog.entries[].date
57+
* - **Documentation**: https://prismic.io/docs/field#date
58+
*/
59+
date: prismic.DateField;
60+
61+
/**
62+
* publication field in *Blog → entries*
63+
*
64+
* - **Field Type**: Text
65+
* - **Placeholder**: *None*
66+
* - **API ID Path**: blog.entries[].publication
67+
* - **Documentation**: https://prismic.io/docs/field#key-text
68+
*/
69+
publication: prismic.KeyTextField;
70+
}
71+
72+
/**
73+
* Content for Blog documents
74+
*/
75+
interface BlogDocumentData {
76+
/**
77+
* entries field in *Blog*
78+
*
79+
* - **Field Type**: Group
80+
* - **Placeholder**: *None*
81+
* - **API ID Path**: blog.entries[]
82+
* - **Tab**: Main
83+
* - **Documentation**: https://prismic.io/docs/field#group
84+
*/
85+
entries: prismic.GroupField<Simplify<BlogDocumentDataEntriesItem>>;
86+
}
87+
88+
/**
89+
* Blog document from Prismic
90+
*
91+
* - **API ID**: `blog`
92+
* - **Repeatable**: `true`
93+
* - **Documentation**: https://prismic.io/docs/custom-types
94+
*
95+
* @typeParam Lang - Language API ID of the document.
96+
*/
97+
export type BlogDocument<Lang extends string = string> =
98+
prismic.PrismicDocumentWithUID<Simplify<BlogDocumentData>, 'blog', Lang>;
99+
7100
/**
8101
* Item in *Home → Hero Actions*
9102
*/
@@ -234,8 +327,6 @@ export interface HomeDocumentDataSummitsItem {
234327
additional_participants_number: prismic.KeyTextField;
235328
}
236329

237-
type HomeDocumentDataSlices7Slice = never;
238-
239330
/**
240331
* Content for Home documents
241332
*/
@@ -260,8 +351,7 @@ interface HomeDocumentData {
260351
* - **Tab**: Main
261352
* - **Documentation**: https://prismic.io/docs/field#key-text
262353
*/
263-
description: prismic.KeyTextField
264-
/**
354+
description: prismic.KeyTextField /**
265355
* Hero Title field in *Home*
266356
*
267357
* - **Field Type**: Text
@@ -303,8 +393,7 @@ interface HomeDocumentData {
303393
* - **Tab**: Hero
304394
* - **Documentation**: https://prismic.io/docs/field#group
305395
*/
306-
focus_areas: prismic.GroupField<Simplify<HomeDocumentDataFocusAreasItem>>
307-
/**
396+
focus_areas: prismic.GroupField<Simplify<HomeDocumentDataFocusAreasItem>> /**
308397
* Collaborators field in *Home*
309398
*
310399
* - **Field Type**: Group
@@ -315,8 +404,7 @@ interface HomeDocumentData {
315404
*/;
316405
collaborators: prismic.GroupField<
317406
Simplify<HomeDocumentDataCollaboratorsItem>
318-
>
319-
/**
407+
> /**
320408
* About Title field in *Home*
321409
*
322410
* - **Field Type**: Text
@@ -380,8 +468,7 @@ interface HomeDocumentData {
380468
* - **Tab**: About
381469
* - **Documentation**: https://prismic.io/docs/field#image
382470
*/
383-
about_image: prismic.ImageField<never>
384-
/**
471+
about_image: prismic.ImageField<never> /**
385472
* Projects Title field in *Home*
386473
*
387474
* - **Field Type**: Text
@@ -434,8 +521,7 @@ interface HomeDocumentData {
434521
* - **Tab**: Projects
435522
* - **Documentation**: https://prismic.io/docs/field#group
436523
*/
437-
projects: prismic.GroupField<Simplify<HomeDocumentDataProjectsItem>>
438-
/**
524+
projects: prismic.GroupField<Simplify<HomeDocumentDataProjectsItem>> /**
439525
* Community Title field in *Home*
440526
*
441527
* - **Field Type**: Text
@@ -479,8 +565,7 @@ interface HomeDocumentData {
479565
*/
480566
community_outlinks: prismic.GroupField<
481567
Simplify<HomeDocumentDataCommunityOutlinksItem>
482-
>
483-
/**
568+
> /**
484569
* Callout Title field in *Home*
485570
*
486571
* - **Field Type**: Text
@@ -556,8 +641,7 @@ interface HomeDocumentData {
556641
* - **Tab**: Callout
557642
* - **Documentation**: https://prismic.io/docs/field#boolean
558643
*/
559-
callout_active: prismic.BooleanField
560-
/**
644+
callout_active: prismic.BooleanField /**
561645
* Section Title field in *Home*
562646
*
563647
* - **Field Type**: Text
@@ -589,17 +673,6 @@ interface HomeDocumentData {
589673
* - **Documentation**: https://prismic.io/docs/field#group
590674
*/
591675
summits: prismic.GroupField<Simplify<HomeDocumentDataSummitsItem>>;
592-
593-
/**
594-
* Slice Zone field in *Home*
595-
*
596-
* - **Field Type**: Slice Zone
597-
* - **Placeholder**: *None*
598-
* - **API ID Path**: home.slices7[]
599-
* - **Tab**: Summits
600-
* - **Documentation**: https://prismic.io/docs/field#slices
601-
*/
602-
slices7: prismic.SliceZone<HomeDocumentDataSlices7Slice>;
603676
}
604677

605678
/**
@@ -671,7 +744,7 @@ export type SettingsDocument<Lang extends string = string> =
671744
Lang
672745
>;
673746

674-
export type AllDocumentTypes = HomeDocument | SettingsDocument;
747+
export type AllDocumentTypes = BlogDocument | HomeDocument | SettingsDocument;
675748

676749
declare module '@prismicio/client' {
677750
interface CreateClient {
@@ -681,8 +754,22 @@ declare module '@prismicio/client' {
681754
): prismic.Client<AllDocumentTypes>;
682755
}
683756

757+
interface CreateWriteClient {
758+
(
759+
repositoryNameOrEndpoint: string,
760+
options: prismic.WriteClientConfig
761+
): prismic.WriteClient<AllDocumentTypes>;
762+
}
763+
764+
interface CreateMigration {
765+
(): prismic.Migration<AllDocumentTypes>;
766+
}
767+
684768
namespace Content {
685769
export type {
770+
BlogDocument,
771+
BlogDocumentData,
772+
BlogDocumentDataEntriesItem,
686773
HomeDocument,
687774
HomeDocumentData,
688775
HomeDocumentDataHeroActionsItem,
@@ -691,7 +778,6 @@ declare module '@prismicio/client' {
691778
HomeDocumentDataProjectsItem,
692779
HomeDocumentDataCommunityOutlinksItem,
693780
HomeDocumentDataSummitsItem,
694-
HomeDocumentDataSlices7Slice,
695781
SettingsDocument,
696782
SettingsDocumentData,
697783
SettingsDocumentDataNavigationItem,

0 commit comments

Comments
 (0)