fix: render loading spinner if no hash
This commit is contained in:
@@ -4,7 +4,7 @@ import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphq
|
|||||||
import type { PageArgs, LangParams, UriParams } from "@/types/params"
|
import type { PageArgs, LangParams, UriParams } from "@/types/params"
|
||||||
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
|
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
|
||||||
import ContentstackLivePreview from "@contentstack/live-preview-utils"
|
import ContentstackLivePreview from "@contentstack/live-preview-utils"
|
||||||
import LoadingPreview from "@/components/Current/LoadingPreview"
|
import LoadingSpinner from "@/components/Current/LoadingSpinner"
|
||||||
import ContentPage from "@/components/Current/ContentPage"
|
import ContentPage from "@/components/Current/ContentPage"
|
||||||
|
|
||||||
export default async function CurrentContentPage({
|
export default async function CurrentContentPage({
|
||||||
@@ -14,8 +14,8 @@ export default async function CurrentContentPage({
|
|||||||
try {
|
try {
|
||||||
ContentstackLivePreview.setConfigFromParams(searchParams)
|
ContentstackLivePreview.setConfigFromParams(searchParams)
|
||||||
|
|
||||||
if (!searchParams.uri) {
|
if (!searchParams.uri || !searchParams["live_preview"]) {
|
||||||
return <LoadingPreview />
|
return <LoadingSpinner />
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await previewRequest<GetCurrentBlockPageData>(
|
const response = await previewRequest<GetCurrentBlockPageData>(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import Puffs from "./Asides/Puffs"
|
import Puffs from "./Asides/Puffs"
|
||||||
|
import Contact from "./Asides/Contacts"
|
||||||
|
|
||||||
import { AsideTypenameEnum } from "@/types/requests/utils/typename"
|
import { AsideTypenameEnum } from "@/types/requests/utils/typename"
|
||||||
import type { AsideProps } from "@/types/components/current/aside"
|
import type { AsideProps } from "@/types/components/current/aside"
|
||||||
@@ -14,7 +15,9 @@ export default function Aside({ blocks }: AsideProps) {
|
|||||||
const type = block.__typename
|
const type = block.__typename
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AsideTypenameEnum.CurrentBlocksPageAsideContact:
|
case AsideTypenameEnum.CurrentBlocksPageAsideContact:
|
||||||
return null
|
return block.contact.contactConnection.edges.map((contact) => (
|
||||||
|
<Contact key={`contact-${idx}`} {...contact.node} />
|
||||||
|
))
|
||||||
case AsideTypenameEnum.CurrentBlocksPageAsidePuff:
|
case AsideTypenameEnum.CurrentBlocksPageAsidePuff:
|
||||||
return <Puffs key={`block-${idx}`} puffs={block.puff.puffConnection.edges} />
|
return <Puffs key={`block-${idx}`} puffs={block.puff.puffConnection.edges} />
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
.title {
|
.title {
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
font-family: BrandonText-Bold,Arial,Helvetica,sans-serif;
|
||||||
|
font-size: 1.375rem;
|
||||||
|
line-height: 1.1em;
|
||||||
|
text-transform: uppercase;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: normal;
|
color: #483729;
|
||||||
margin-top: 2rem;
|
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
text-decoration: none;
|
margin-top: 2rem;
|
||||||
text-transform: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ul {
|
.ul {
|
||||||
@@ -60,6 +61,6 @@
|
|||||||
|
|
||||||
@media screen and (min-width: 950px) {
|
@media screen and (min-width: 950px) {
|
||||||
.title {
|
.title {
|
||||||
font-size: 1.375rem;
|
font-size: 1.625rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import styles from "./loading.module.css"
|
import styles from "./loading.module.css"
|
||||||
|
|
||||||
export default function LoadingPreview() {
|
export default function LoadingSpinner() {
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={styles.spinner}>
|
<div className={styles.spinner}>
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 70px;
|
gap: 70px;
|
||||||
grid-template-columns: 2fr 1fr;
|
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
max-width: 1200px;
|
max-width: 1200px;
|
||||||
padding: 20px 10px 5px;
|
padding: 20px 10px 5px;
|
||||||
@@ -15,6 +14,7 @@
|
|||||||
@media screen and (min-width: 740px) {
|
@media screen and (min-width: 740px) {
|
||||||
.section {
|
.section {
|
||||||
padding: 30px 30px 15px;
|
padding: 30px 30px 15px;
|
||||||
|
grid-template-columns: 2fr 1fr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
types/components/current/asides/contact.ts
Normal file
3
types/components/current/asides/contact.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import type { ContactNode } from "@/types/requests/asides/contact"
|
||||||
|
|
||||||
|
export type ContactProps = ContactNode
|
||||||
@@ -1,23 +1,25 @@
|
|||||||
import type { Edges } from "../utils/edges"
|
import type { Edges } from "../utils/edges"
|
||||||
|
|
||||||
|
export type ContactNode = {
|
||||||
|
mailing_address: {
|
||||||
|
city: string
|
||||||
|
country: string
|
||||||
|
name: string
|
||||||
|
street: string
|
||||||
|
zip: string
|
||||||
|
}
|
||||||
|
phone: string
|
||||||
|
title: string
|
||||||
|
visiting_address: {
|
||||||
|
city: string
|
||||||
|
country: string
|
||||||
|
street: string
|
||||||
|
zip: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type Contact = {
|
export type Contact = {
|
||||||
contact: {
|
contact: {
|
||||||
contactConnection: Edges<{
|
contactConnection: Edges<ContactNode>
|
||||||
mailing_address: {
|
|
||||||
city: string
|
|
||||||
country: string
|
|
||||||
name: string
|
|
||||||
street: string
|
|
||||||
zip: string
|
|
||||||
}
|
|
||||||
phone: string
|
|
||||||
title: string
|
|
||||||
visiting_address: {
|
|
||||||
city: string
|
|
||||||
country: string
|
|
||||||
street: string
|
|
||||||
zip: string
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user