Skip to content

Commit a57abce

Browse files
2 parents 6202c60 + 226d3ee commit a57abce

File tree

5 files changed

+54
-40
lines changed

5 files changed

+54
-40
lines changed

pages/[[...slug]].tsx

+19-13
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,24 @@ export const getStaticProps: GetStaticProps = async (context) => {
9393
}
9494

9595
const [page, header, footer] = await Promise.all([
96-
fetchPage(cleanSlug, config.apiKey, context.locale, config.pageTypes).catch(
97-
() => {
96+
fetchPage(cleanSlug, config.apiKey, context.locale, config.pageTypes)
97+
.then(({ author, ...page }) => page)
98+
.catch(() => {
9899
errorPage = true
99100
return {}
100-
}
101-
),
102-
fetchPage('header', config.apiKey, context.locale).catch(() => {
103-
errorHeader = true
104-
return {}
105-
}),
106-
fetchPage('footer', config.apiKey, context.locale).catch(() => {
107-
errorFooter = true
108-
return {}
109-
}),
101+
}),
102+
fetchPage('header', config.apiKey, context.locale)
103+
.then(({ author, ...page }) => page)
104+
.catch(() => {
105+
errorHeader = true
106+
return {}
107+
}),
108+
fetchPage('footer', config.apiKey, context.locale)
109+
.then(({ author, ...page }) => page)
110+
.catch(() => {
111+
errorFooter = true
112+
return {}
113+
}),
110114
])
111115

112116
return {
@@ -127,7 +131,9 @@ export const getStaticPaths: GetStaticPaths = async (context) => {
127131
return { paths: [], fallback: true }
128132
}
129133

130-
const allPages = await fetchPages(config.apiKey)
134+
const allPages = await fetchPages(config.apiKey, {
135+
types: ['page', 'pokemon'],
136+
})
131137

132138
const paths = allPages
133139
.map((page) =>

pages/blog/index.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@ export const getStaticProps: GetStaticProps = async (context) => {
118118
sort: '-publishedAt',
119119
})
120120

121-
header = await fetchPage('header', config.apiKey, context.locale).catch(
122-
() => {
121+
header = await fetchPage('header', config.apiKey, context.locale)
122+
.then(({ author, ...page }) => page)
123+
.catch(() => {
123124
errorHeader = true
124125
return {}
125-
}
126-
)
126+
})
127127

128-
footer = await fetchPage('footer', config.apiKey, context.locale).catch(
129-
() => {
128+
footer = await fetchPage('footer', config.apiKey, context.locale)
129+
.then(({ author, ...page }) => page)
130+
.catch(() => {
130131
errorFooter = true
131132
return {}
132-
}
133-
)
133+
})
134134

135135
return { props: { posts, tags, header, footer, errorHeader, errorFooter } }
136136
} catch {

pages/blog/post/[[...slug]].tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,18 @@ export const getStaticProps: GetStaticProps = async (context) => {
112112
errorPage = true
113113
return {}
114114
}),
115-
fetchPage('header', config.apiKey, context.locale).catch(() => {
116-
errorHeader = true
117-
return {}
118-
}),
119-
fetchPage('footer', config.apiKey, context.locale).catch(() => {
120-
errorFooter = true
121-
return {}
122-
}),
115+
fetchPage('header', config.apiKey, context.locale)
116+
.then(({ author, ...page }) => page)
117+
.catch(() => {
118+
errorHeader = true
119+
return {}
120+
}),
121+
fetchPage('footer', config.apiKey, context.locale)
122+
.then(({ author, ...page }) => page)
123+
.catch(() => {
124+
errorFooter = true
125+
return {}
126+
}),
123127
])
124128

125129
return {

pages/blog/tag/[tag].tsx

+14-10
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ const Page: React.FC<PageProps> = ({
7474

7575
<div className="flex flex-wrap items-center">
7676
{allTags?.map((tag) => (
77-
<TagListItem tag={tag} key={tag} />
78-
))}
77+
<TagListItem tag={tag} key={tag} />
78+
))}
7979
</div>
8080

8181
<hr className="mt-6 mb-10 dark:border-gray-600" />
@@ -129,14 +129,18 @@ export const getStaticProps: GetStaticProps = async (context) => {
129129
sort: '-publishedAt',
130130
}),
131131
fetchTags(process.env.API_KEY),
132-
fetchPage('header', config.apiKey, context.locale).catch(() => {
133-
errorHeader = true
134-
return {}
135-
}),
136-
fetchPage('footer', config.apiKey, context.locale).catch(() => {
137-
errorFooter = true
138-
return {}
139-
}),
132+
fetchPage('header', config.apiKey, context.locale)
133+
.then(({ author, ...page }) => page)
134+
.catch(() => {
135+
errorHeader = true
136+
return {}
137+
}),
138+
fetchPage('footer', config.apiKey, context.locale)
139+
.then(({ author, ...page }) => page)
140+
.catch(() => {
141+
errorFooter = true
142+
return {}
143+
}),
140144
])
141145

142146
return {

react-bricks/pageTypes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const pageTypes: types.IPageType[] = [
5050
defaultStatus: types.PageStatus.Published,
5151
getDefaultContent: () => [],
5252
isEntity: true,
53-
excludedBlockTypes: ['pokemon'],
53+
allowedBlockTypes: ['header', 'footer'],
5454
},
5555
]
5656

0 commit comments

Comments
 (0)