-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cta, blog snippet and blog components
- Loading branch information
1 parent
c137f4c
commit b7055e1
Showing
4 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React from 'react'; | ||
import { AmplienceContentItem } from '~/amplience-client'; | ||
import AmplienceContent from '../wrapper/amplience-content'; | ||
import CallToAction from '../call-to-action/call-to-action'; | ||
import NextHead from 'next/head'; | ||
import { AmplienceImage } from '../image/image.types'; | ||
import { getImageURL } from '../image/image.utils'; | ||
|
||
export type BlogSnippetProps = { | ||
image: AmplienceContentItem; | ||
title: string; | ||
blogdate: string; | ||
author: string; | ||
category: string[]; | ||
description: string; | ||
cta: any; | ||
tags: any[]; | ||
keywords: string; | ||
}; | ||
|
||
const buildCTAUrl = (cta: any) => { | ||
switch (cta.type) { | ||
case 'URL': | ||
return cta.value; | ||
case 'Category ID': | ||
return `/category/${cta.value}`; | ||
case 'Product SKU': | ||
return `/product/${cta.value}`; | ||
case 'Page ID': | ||
return `/${cta.value}`; | ||
default: | ||
return '#'; | ||
} | ||
}; | ||
|
||
const BlogSnippet = ({ | ||
image, | ||
title, | ||
blogdate, | ||
author, | ||
category, | ||
description, | ||
cta, | ||
keywords, | ||
}: BlogSnippetProps) => { | ||
return ( | ||
<> | ||
<NextHead> | ||
<title>{title || 'Amplience Retail Storefront Website'}</title> | ||
<meta name="description" content={description} /> | ||
<meta property="og:title" content={title || 'Amplience Retail Storefront Website'} /> | ||
<meta property="og:description" content={description} /> | ||
<meta name="keywords" content={keywords} /> | ||
<meta property="og:image" content={getImageURL(image.image as AmplienceImage)} /> | ||
<meta name="twitter:card" content="summary_large_image" /> | ||
<meta name="twitter:site" content="@amplience" /> | ||
<meta name="twitter:creator" content="@amplience" /> | ||
<meta name="twitter:title" content={title || 'Amplience Retail Storefront Website'} /> | ||
<meta name="twitter:description" content={description} /> | ||
<meta name="twitter:image" content={getImageURL(image.image as AmplienceImage)} /> | ||
</NextHead> | ||
<div className="amp-dc-banner js_dc_banner"> | ||
<div className="amp-dc-banner-wrapper"> | ||
<div className="amp-dc-banner-pic-wrap"> | ||
<AmplienceContent content={image} /> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div className="amp-dc-snippet-info-wrap"> | ||
{category?.length ? <small>{category.join(', ')}</small> : null} | ||
{title ? <h1 className="mb-8 text-3xl font-black lg:text-5xl">{title}</h1> : null} | ||
<div className="amp-dc-snippet-info-wrap__description"> | ||
{author ? <h4 className="mb-2 text-gray-500">{author}</h4> : null} | ||
{blogdate ? <h4 className="mb-2 text-gray-500">{blogdate}</h4> : null} | ||
</div> | ||
|
||
{description ? <h2>{description}</h2> : null} | ||
|
||
{cta ? ( | ||
<CallToAction | ||
key={cta?.label} | ||
href={buildCTAUrl(cta)} | ||
style={{ marginTop: '15px !important', marginRight: '15px !important' }} | ||
variant={'contained'} | ||
> | ||
{cta?.label} | ||
</CallToAction> | ||
) : null} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default BlogSnippet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { AmplienceContentItem } from '~/amplience-client'; | ||
import AmplienceContent from '../wrapper/amplience-content'; | ||
|
||
export interface BlogProps { | ||
snippet: AmplienceContentItem; | ||
contentTypes?: AmplienceContentItem[]; | ||
content: AmplienceContentItem; | ||
} | ||
|
||
const Blog = ({ snippet, content, contentTypes = [] }: BlogProps) => { | ||
const Blog = ( | ||
<div> | ||
<div> | ||
<AmplienceContent content={snippet} /> | ||
</div> | ||
<div | ||
style={{ | ||
maxWidth: '100%', | ||
margin: 'auto', | ||
}} | ||
> | ||
<AmplienceContent content={content} /> | ||
{contentTypes.map((item: any, index: number) => ( | ||
<div key={index}> | ||
<AmplienceContent content={item} /> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
|
||
return Blog; | ||
}; | ||
|
||
export default Blog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
import clsx from 'clsx'; | ||
import Link from 'next/link'; | ||
|
||
interface CallToActionProps extends PropsWithChildren { | ||
href: string; | ||
className?: string; | ||
style?: React.CSSProperties; | ||
variant?: 'outlined' | 'contained'; | ||
} | ||
|
||
const CallToAction = ({ | ||
children, | ||
href, | ||
className, | ||
variant = 'outlined', | ||
...other | ||
}: CallToActionProps) => { | ||
return href ? ( | ||
<Link | ||
href={href} | ||
className={clsx( | ||
`font mt-4 rounded bg-[#333] px-3.5 py-2.5 text-xs font-bold text-[#eee] no-underline hover:bg-[#eee] hover:text-[#333] hover:no-underline`, | ||
{ | ||
['font mt-4 rounded bg-[#eee] px-3.5 py-2.5 text-xs font-bold text-[#333] no-underline hover:bg-[#333] hover:text-[#eee] hover:no-underline']: | ||
variant === 'contained', | ||
}, | ||
className, | ||
)} | ||
{...other} | ||
> | ||
{children} | ||
</Link> | ||
) : null; | ||
}; | ||
|
||
export default CallToAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters