Skip to content

Commit 6fcccc0

Browse files
committed
Add doc comment
1 parent 9e1bf19 commit 6fcccc0

File tree

12 files changed

+62
-58
lines changed

12 files changed

+62
-58
lines changed

pages/blog/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Blog = ( { headerFooter, postsData } ) => {
2323
<Layout headerFooter={ headerFooter || {} } seo={ null }>
2424
<h1>Blog</h1>
2525
<Posts posts={ postsData?.posts_data ?? [] }/>
26-
<Pagination pagesCount={ postsData?.page_count } postName="blog"/>
26+
<Pagination pagesCount={ postsData?.page_count ?? 0 } postName="blog"/>
2727
</Layout>
2828
);
2929
};

pages/blog/page/[pageNo].js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const Page = ( { headerFooter, postsData } ) => {
2828
<Layout headerFooter={ headerFooter || {} } seo={ null }>
2929
<h1>Blog</h1>
3030
<Posts posts={ postsData?.posts_data ?? [] }/>
31-
<Pagination pagesCount={ postsData?.page_count } postName="blog"/>
31+
<Pagination pagesCount={ postsData?.page_count ?? 0 } postName="blog"/>
3232
</Layout>
3333
);
3434
};
@@ -45,7 +45,7 @@ export async function getStaticProps( { params } ) {
4545
const defaultProps = {
4646
props: {
4747
headerFooter: headerFooterData?.data ?? {},
48-
postsData: postsData ?? {},
48+
postsData: postsData || {},
4949
},
5050
/**
5151
* Revalidate means that if a new request comes to server, then every 1 sec it will check

src/components/layout/footer/index.js

+25-24
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ import { getIconComponentByName } from '../../../utils/icons-map';
77
/**
88
* External Dependencies.
99
*/
10-
import {isEmpty, isArray} from 'lodash';
10+
import { isEmpty, isArray } from 'lodash';
1111
import Link from 'next/link';
1212
import { useEffect, useState } from 'react';
1313

14-
const Footer = ({footer}) => {
14+
const Footer = ( { footer } ) => {
1515

1616
const { copyrightText, footerMenuItems, sidebarOne, sidebarTwo, socialLinks } = footer || {};
17-
const [isMounted, setMount] = useState(false);
17+
const [ isMounted, setMount ] = useState( false );
1818

1919

20-
useEffect(() => {
21-
setMount(true);
22-
}, []);
20+
useEffect( () => {
21+
setMount( true );
22+
}, [] );
2323

2424
return (
2525
<footer className="footer bg-blue-500 p-6">
@@ -28,45 +28,46 @@ const Footer = ({footer}) => {
2828

2929
{ isMounted ? (
3030
<>
31-
{/*Widget One*/}
31+
{/*Widget One*/ }
3232
<div className="my-1 px-1 w-full overflow-hidden sm:w-full lg:w-1/2 xl:w-1/3">
33-
<div dangerouslySetInnerHTML={{ __html: sanitize( sidebarOne ) }}/>
33+
<div dangerouslySetInnerHTML={ { __html: sanitize( sidebarOne ) } }/>
3434
</div>
35-
{/*Widget Two*/}
35+
{/*Widget Two*/ }
3636
<div className="my-1 px-1 w-full overflow-hidden sm:w-full lg:w-1/2 xl:w-1/3">
37-
<div dangerouslySetInnerHTML={{ __html: sanitize( sidebarTwo ) }}/>
37+
<div dangerouslySetInnerHTML={ { __html: sanitize( sidebarTwo ) } }/>
3838
</div>
3939
</>
40-
) : null}
40+
) : null }
4141

42-
{/* Footer Menus*/}
42+
{/* Footer Menus*/ }
4343
<div className="my-1 px-1 w-full overflow-hidden sm:w-full lg:w-1/2 xl:w-1/3">
44-
{ !isEmpty( footerMenuItems ) && isArray( footerMenuItems ) ? (
44+
{ ! isEmpty( footerMenuItems ) && isArray( footerMenuItems ) ? (
4545
<ul>
4646
{ footerMenuItems.map( menuItem => (
47-
<li key={menuItem?.ID}>
47+
<li key={ menuItem?.ID }>
4848
<Link href={ getPathNameFromUrl( menuItem?.url ?? '' ) || '/' }>
49-
<a>{menuItem?.title}</a>
49+
<a>{ menuItem?.title }</a>
5050
</Link>
5151
</li>
52-
)) }
52+
) ) }
5353
</ul>
54-
) : null }
54+
) : null }
5555
</div>
5656
</div>
5757
<div className="mb-8 mt-8 w-full flex flex-wrap">
58-
{/*Copyright Text*/}
58+
{/*Copyright Text*/ }
5959
<div className="w-full md:w-1/2 lg:w-1/4 text-white">
6060
{ copyrightText ? copyrightText : '© Codeytek Academy 2021' }
6161
</div>
6262
<div className="w-full lg:w-3/4 flex justify-end">
63-
{ !isEmpty( socialLinks ) && isArray( socialLinks ) ? (
63+
{ ! isEmpty( socialLinks ) && isArray( socialLinks ) ? (
6464
<ul className="flex item-center mb-0">
6565
{ socialLinks.map( socialLink => (
66-
<li key={socialLink?.iconName} className="no-dots-list mb-0 flex items-center">
67-
<a href={ socialLink?.iconUrl || '/' } target="_blank" title={socialLink?.iconName} className="ml-2 inline-block">
66+
<li key={ socialLink?.iconName } className="no-dots-list mb-0 flex items-center">
67+
<a href={ socialLink?.iconUrl || '/' } target="_blank"
68+
title={ socialLink?.iconName } className="ml-2 inline-block">
6869
{ getIconComponentByName( socialLink?.iconName ) }
69-
<span className="sr-only">{socialLink?.iconName}</span>
70+
<span className="sr-only">{ socialLink?.iconName }</span>
7071
</a>
7172
</li>
7273
) ) }
@@ -76,7 +77,7 @@ const Footer = ({footer}) => {
7677
</div>
7778
</div>
7879
</footer>
79-
)
80-
}
80+
);
81+
};
8182

8283
export default Footer;

src/components/layout/header/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const Header = ( { header } ) => {
4848
className={ `${ isMenuVisible ? 'max-h-full' : 'h-0' } overflow-hidden w-full lg:h-full block flex-grow lg:flex lg:items-center lg:w-auto` }>
4949
<div className="text-sm font-medium uppercase lg:flex-grow">
5050
{ ! isEmpty( headerMenuItems ) && headerMenuItems.length ? headerMenuItems.map( menuItem => (
51-
<Link key={ menuItem?.ID } href={ getPathNameFromUrl( menuItem?.url ?? '' ) || '/' }>
51+
<Link key={ menuItem?.ID }
52+
href={ getPathNameFromUrl( menuItem?.url ?? '' ) || '/' }>
5253
<a className="block mt-4 lg:inline-block lg:mt-0 hover:text-brand-royal-blue duration-500 mr-10"
5354
dangerouslySetInnerHTML={ { __html: menuItem.title } }/>
5455
</Link>
@@ -76,7 +77,8 @@ const Header = ( { header } ) => {
7677
<a className="flex mt-4 lg:inline-block lg:mt-0 text-black hover:text-black mr-10">
7778
<span className="flex flex-row items-center lg:flex-col">
7879
<Bag className="mr-1 lg:mr-0"/>
79-
<span className="ml-1">Bag{ cart?.totalQty ? `(${cart?.totalQty})` : null }</span>
80+
<span
81+
className="ml-1">Bag{ cart?.totalQty ? `(${ cart?.totalQty })` : null }</span>
8082
</span>
8183
</a>
8284
</Link>

src/components/pagination/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Pagination = ( { pagesCount, postName } ) => {
1212
}
1313

1414
const router = useRouter();
15-
const currentPageNo = parseInt( router?.query?.pageNo ) || 1;
15+
const currentPageNo = parseInt( router?.query?.pageNo ?? 1 ) || 1;
1616

1717
const paginationLinks = createPaginationLinks( currentPageNo, pagesCount );
1818

src/components/pagination/next.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import {isEmpty} from 'lodash';
1+
import { isEmpty } from 'lodash';
22
import Link from 'next/link';
3-
const Next = ( {currentPageNo, pagesCount, postName} ) => {
3+
4+
const Next = ( { currentPageNo, pagesCount, postName } ) => {
45

56
if ( ! currentPageNo || ! pagesCount || isEmpty( postName ) ) {
67
return null;
78
}
89

9-
// If you are on the last page, dont show next link.
10+
// If you are on the last page, don't show next link.
1011
if ( pagesCount < currentPageNo + 1 ) {
1112
return null;
1213
}
1314

14-
const paginationLink = `/${postName}/page/${currentPageNo + 1}/`;
15+
const paginationLink = `/${ postName }/page/${ currentPageNo + 1 }/`;
1516

1617
return (
17-
<Link href={paginationLink}>
18+
<Link href={ paginationLink }>
1819
<a className="border border-gray-300 px-3 py-2 ml-4 transition duration-500 ease-in-out hover:bg-gray-500 hover:text-white">Next</a>
1920
</Link>
2021
);

src/components/pagination/previous.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {isEmpty} from 'lodash';
1+
import { isEmpty } from 'lodash';
22
import Link from 'next/link';
33

4-
const Previous = ( {currentPageNo, postName} ) => {
4+
const Previous = ( { currentPageNo, postName } ) => {
55

66
if ( ! currentPageNo || isEmpty( postName ) ) {
77
return null;
@@ -12,10 +12,10 @@ const Previous = ( {currentPageNo, postName} ) => {
1212
return null;
1313
}
1414

15-
const paginationLink = `/${postName}/page/${currentPageNo - 1}/`;
15+
const paginationLink = `/${ postName }/page/${ currentPageNo - 1 }/`;
1616

1717
return (
18-
<Link href={paginationLink}>
18+
<Link href={ paginationLink }>
1919
<a className="border border-gray-300 px-3 py-2 mr-4 transition duration-500 ease-in-out hover:bg-gray-500 hover:text-white">Previous</a>
2020
</Link>
2121
);

src/components/posts/post.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ const Post = ( { post } ) => {
2020
<div className="mb-8">
2121
<Link href={ `/blog/${ post?.slug }/` }>
2222
<a>
23-
<figure className="overflow-hidden mb-4">
24-
<Image
25-
sourceUrl={ post?.attachment_image?.img_src?.[ 0 ] ?? '' }
26-
title={ post?.title ?? '' }
27-
width="400"
28-
height="225"
29-
layout="fill"
30-
containerClassNames="w-96 sm:-w-600px md:w-400px h-56 sm:h-338px md:h-225px"
31-
/>
32-
</figure>
23+
<figure className="overflow-hidden mb-4">
24+
<Image
25+
sourceUrl={ post?.attachment_image?.img_src?.[ 0 ] ?? '' }
26+
title={ post?.title ?? '' }
27+
width="400"
28+
height="225"
29+
layout="fill"
30+
containerClassNames="w-96 sm:-w-600px md:w-400px h-56 sm:h-338px md:h-225px"
31+
/>
32+
</figure>
3333
</a>
3434
</Link>
3535
<PostMeta date={ post?.date ?? '' } authorName={ post?.meta?.author_name ?? '' }/>

src/utils/constants/endpoints.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
export const HEADER_FOOTER_ENDPOINT = `${ process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL }/wp-json/rae/v1/header-footer?header_location_id=hcms-menu-header&footer_location_id=hcms-menu-footer`;
2-
export const GET_POSTS_ENDPOINT = `${process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL}/wp-json/rae/v1/posts`;
3-
export const GET_POST_ENDPOINT = `${process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL}/wp-json/wp/v2/posts`;
4-
export const GET_PAGES_ENDPOINT = `${process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL}/wp-json/wp/v2/pages`;
2+
export const GET_POSTS_ENDPOINT = `${ process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL }/wp-json/rae/v1/posts`;
3+
export const GET_POST_ENDPOINT = `${ process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL }/wp-json/wp/v2/posts`;
4+
export const GET_PAGES_ENDPOINT = `${ process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL }/wp-json/wp/v2/pages`;
55

66
/**
77
* Cart
88
* @type {string}
99
*/
10-
export const CART_ENDPOINT = `${process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL}/wp-json/rae/v1/cart/items/`;
10+
export const CART_ENDPOINT = `${ process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL }/wp-json/rae/v1/cart/items/`;
1111

1212
// Countries and States
13-
export const WOOCOMMERCE_COUNTRIES_ENDPOINT = `${process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL}/wp-json/rae/v1/wc/countries/`;
14-
export const WOOCOMMERCE_STATES_ENDPOINT = `${process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL}/wp-json/rae/v1/wc/states`;
13+
export const WOOCOMMERCE_COUNTRIES_ENDPOINT = `${ process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL }/wp-json/rae/v1/wc/countries/`;
14+
export const WOOCOMMERCE_STATES_ENDPOINT = `${ process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL }/wp-json/rae/v1/wc/states`;

src/utils/constants/posts.js

Whitespace-only changes.

src/utils/pagination.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const createPaginationLinks = ( currentPage, totalPages ) => {
4646
* Push the '...' at the beginning of the array
4747
* only if the difference of between the 1st and 2nd index item is greater than 1.
4848
*/
49-
if ( 1 < paginationArray[0] - 1 ) {
49+
if ( 1 < paginationArray[ 0 ] - 1 ) {
5050
paginationArray.unshift( '...' );
5151
countOfDotItems += 1;
5252
}
@@ -56,7 +56,7 @@ export const createPaginationLinks = ( currentPage, totalPages ) => {
5656
* only if the difference of between the last and 2nd last item is greater than 2.
5757
* We remove the count of dot items from the array to get the actual indexes, while checking the condition.
5858
*/
59-
if ( 2 < totalPages - paginationArray[paginationArray.length - ( 2 - countOfDotItems )] ) {
59+
if ( 2 < totalPages - paginationArray[ paginationArray.length - ( 2 - countOfDotItems ) ] ) {
6060
paginationArray.push( '...' );
6161
}
6262

src/utils/slug.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const isCustomPageUri = ( uri ) => {
1515
'/blog/',
1616
'/checkout/',
1717
'/cart/',
18-
'/thank-you/'
18+
'/thank-you/',
1919
];
2020

2121
return pagesToExclude.includes( uri );

0 commit comments

Comments
 (0)