Skip to content

Commit 17897a7

Browse files
typescript code fixes
1 parent 725f5b2 commit 17897a7

25 files changed

+315
-258
lines changed

components/about-section-bucket.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
import React from 'react';
22
import parse from 'html-react-parser';
3-
import { BucketProps, Bucket } from "../typescript/about-section-bucket";
3+
import { Action,Image } from '../typescript/action';
4+
5+
type AdditionalParam = {
6+
title_h2?: string;
7+
title_h3?: string;
8+
description?: string;
9+
}
10+
11+
type Bucket = {
12+
title_h3: string;
13+
description: string;
14+
icon: Image;
15+
$: AdditionalParam;
16+
url: string;
17+
}
18+
19+
type BucketsList = {
20+
title_h3: string;
21+
description: string;
22+
url: string;
23+
call_to_action: Action;
24+
icon: Image;
25+
$: AdditionalParam;
26+
}
27+
28+
type BucketProps = {
29+
title_h2: string;
30+
buckets:[BucketsList];
31+
$: AdditionalParam;
32+
}
433

534
export default function AboutSectionBucket({ sectionWithBuckets }: {sectionWithBuckets:BucketProps}) {
635
function bucketContent(bucket: Bucket, index: number) {

components/archive-relative.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
import React from 'react';
22
import Link from 'next/link';
33
import parse from 'html-react-parser';
4-
import {BlogListProps} from '../typescript/archive-relative';
4+
5+
type AdditionalParam = {
6+
title: string;
7+
body: string;
8+
}
9+
10+
type Blog = {
11+
url: string;
12+
body: string;
13+
title: string;
14+
$: AdditionalParam;
15+
}
16+
17+
type BlogListProps = {
18+
blogs: [Blog];
19+
}
520

621
export default function ArchiveRelative({ blogs }: BlogListProps) {
722
return (

components/blog-banner.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
import React from 'react';
2-
import {BannerProps} from '../typescript/blog';
2+
3+
type AdditionalParam = {
4+
banner_title:string;
5+
banner_description: string;
6+
title: {};
7+
title_h2: string;
8+
body: string;
9+
date: string;
10+
}
11+
12+
type BannerProps = {
13+
banner_title:string;
14+
banner_description: string;
15+
bg_color: string;
16+
$: AdditionalParam;
17+
}
318

419
export default function BlogBanner({ blogBanner }: {blogBanner : BannerProps}) {
520
return (

components/blog-list.tsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,37 @@ import React from 'react';
22
import moment from 'moment';
33
import parse from 'html-react-parser';
44
import Link from 'next/link';
5-
import { BloglistProps } from "../typescript/blog";
5+
import { Image } from "../typescript/action";
6+
7+
type AdditionalParam = {
8+
banner_title:string;
9+
banner_description: string;
10+
title: {};
11+
title_h2: string;
12+
body: string;
13+
date: string;
14+
}
15+
16+
type Author = {
17+
title: string;
18+
$: AdditionalParam;
19+
}
20+
21+
22+
type BloglistProps = {
23+
body: string;
24+
url: string;
25+
featured_image: Image;
26+
title: string;
27+
date: string;
28+
author: [Author];
29+
$: AdditionalParam;
30+
}
631

732
function BlogList({ bloglist }: { bloglist: BloglistProps }) {
8-
let body = typeof bloglist.body === 'string' && bloglist.body.substr(0, 300);
9-
const stringLength = (body as string).lastIndexOf(' ');
10-
body = `${(body as string).substr(0, Math.min((body as string).length, stringLength))}...`;
33+
let body: string = bloglist.body && bloglist.body.substr(0, 300);
34+
const stringLength = body.lastIndexOf(' ');
35+
body = `${body.substr(0, Math.min(body.length, stringLength))}...`;
1136
return (
1237
<div className='blog-list'>
1338
{bloglist.featured_image && (

components/blog-section.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
11
import React from 'react';
22
import Link from 'next/link';
33
import parse from 'html-react-parser';
4-
import { FeaturedBlogProps } from "../typescript/blog";
4+
import { Image } from "../typescript/action";
5+
6+
type AdditionalParam = {
7+
banner_title:string;
8+
banner_description: string;
9+
title: {};
10+
title_h2: string;
11+
body: string;
12+
date: string;
13+
}
14+
15+
type Article = {
16+
href: string;
17+
title: string;
18+
$: AdditionalParam;
19+
}
20+
21+
type FeaturedBlog = {
22+
title: string;
23+
featured_image: Image;
24+
body: string;
25+
url: string;
26+
$: AdditionalParam;
27+
}
28+
29+
type FeaturedBlogData = {
30+
title_h2: string;
31+
view_articles: Article;
32+
featured_blogs: [FeaturedBlog]
33+
$: AdditionalParam;
34+
}
35+
36+
type FeaturedBlogProps = {
37+
fromBlog: FeaturedBlogData;
38+
}
539

640
export default function BlogSection(props: FeaturedBlogProps) {
741

components/card-section.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
import React from 'react';
22
import Link from 'next/link';
3-
import { CardProps } from "../typescript/card";
3+
import { Action } from "../typescript/action";
4+
5+
type AdditionalParam = {
6+
title_h3: string;
7+
description: string;
8+
}
9+
10+
type Card = {
11+
title_h3: string;
12+
description: string;
13+
call_to_action: Action;
14+
$: AdditionalParam;
15+
}
16+
17+
type CardProps = {
18+
cards: [Card]
19+
}
420

521
export default function CardSection({ cards }: CardProps) {
622
return (

components/footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function Footer({ footer, entries }: {footer: FooterProps, entrie
1010

1111
const [getFooter, setFooter] = useState(footer);
1212

13-
function buildNavigation(ent: Entry, ft: any) {
13+
function buildNavigation(ent: Entry, ft: FooterProps) {
1414
let newFooter = { ...ft };
1515
if (ent.length !== newFooter.navigation.link.length) {
1616
ent.forEach((entry) => {

components/header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import Tooltip from './tool-tip';
66
import { onEntryChange } from '../contentstack-sdk';
77
import { getHeaderRes } from '../helper';
88
import Skeleton from 'react-loading-skeleton';
9-
import { HeaderProps, Entry, Links } from "../typescript/layout";
9+
import { HeaderProps, Entry, NavLinks } from "../typescript/layout";
1010

1111
export default function Header({ header, entries }: {header: HeaderProps, entries: Entry}) {
1212

1313
const router = useRouter();
1414
const [getHeader, setHeader] = useState(header);
1515

16-
function buildNavigation(ent: Entry, hd: any) {
16+
function buildNavigation(ent: Entry, hd: HeaderProps) {
1717
let newHeader={...hd};
1818
if (ent.length!== newHeader.navigation_menu.length) {
1919
ent.forEach((entry) => {
2020
const hFound = newHeader?.navigation_menu.find(
21-
(navLink: Links) => navLink.label === entry.title
21+
(navLink: NavLinks) => navLink.label === entry.title
2222
);
2323
if (!hFound) {
2424
newHeader.navigation_menu?.push({

components/hero-banner.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
import React from 'react';
22
import Link from 'next/link';
3-
import { BannerProps } from "../typescript/banner";
3+
import { Image, Action } from "../typescript/action";
4+
5+
type AdditionalParam = {
6+
banner_title: string;
7+
banner_description: string;
8+
}
9+
10+
type Banner = {
11+
bg_color: string;
12+
text_color: string;
13+
banner_title: string;
14+
banner_description: string;
15+
call_to_action: Action;
16+
banner_image: Image;
17+
$: AdditionalParam;
18+
}
19+
20+
type BannerProps = {
21+
banner: Banner;
22+
}
423

524
export default function HeroBanner(props: BannerProps) {
625

components/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
22
import Header from './header';
33
import Footer from './footer';
44
import DevTools from './devtools';
5-
import { HeaderProps, FooterProps, PageProps, Posts, ChilderenProps, Entry, Links } from "../typescript/layout";
5+
import { HeaderProps, FooterProps, PageProps, Posts, ChilderenProps, Entry, NavLinks, Links } from "../typescript/layout";
66

77
export default function Layout({
88
header,
@@ -20,13 +20,13 @@ export default function Layout({
2020
blogPost && (jsonObj.blog_post = blogPost);
2121
blogList && (jsonObj.blog_post = blogList);
2222

23-
function buildNavigation(ent: Entry, hd: any, ft: any) {
23+
function buildNavigation(ent: Entry, hd: HeaderProps, ft: FooterProps) {
2424
let newHeader = { ...hd };
2525
let newFooter = { ...ft };
2626
if (ent.length !== newHeader.navigation_menu.length) {
2727
ent.forEach((entry) => {
2828
const hFound = newHeader?.navigation_menu.find(
29-
(navLink: Links) => navLink.label === entry.title
29+
(navLink: NavLinks) => navLink.label === entry.title
3030
);
3131
if (!hFound) {
3232
newHeader.navigation_menu?.push({

0 commit comments

Comments
 (0)