Skip to content

Commit f8f90bc

Browse files
committed
fix: Remove 'any' types by centralizing type definitions
1 parent 2dd1d24 commit f8f90bc

File tree

26 files changed

+351
-147
lines changed

26 files changed

+351
-147
lines changed

components/DocTable.tsx

Lines changed: 70 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@ import React from 'react';
33
import Link from 'next/link';
44
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
55

6+
interface Author {
7+
name: string;
8+
photo?: string;
9+
}
10+
611
interface DocTableProps {
712
frontmatter: {
8-
Specification: string;
9-
Published: string;
10-
authors: string[];
11-
Metaschema: string;
13+
Specification?: string;
14+
Published?: string;
15+
authors?: (string | Author)[];
16+
Metaschema?: string;
1217
};
1318
}
1419

1520
const DocTable = ({ frontmatter }: DocTableProps) => {
21+
const authors = frontmatter.authors ?? [];
22+
const getAuthorName = (author: string | Author): string =>
23+
typeof author === 'string' ? author : author.name;
24+
1625
return (
1726
<Card className='w-full overflow-hidden py-0 border-2 border-primary shadow-lg gap-0'>
1827
<CardHeader className='bg-primary text-primary-foreground p-2 rounded-none'>
@@ -22,63 +31,71 @@ const DocTable = ({ frontmatter }: DocTableProps) => {
2231
</CardHeader>
2332
<CardContent className='p-0'>
2433
<div className='bg-[#e2e8f0] dark:bg-[#0f172a]'>
25-
<div className='border-b border-border'>
26-
<div className='flex'>
27-
<div className='w-1/3 p-4 font-semibold text-base text-[#334155] dark:text-slate-300'>
28-
Specification
29-
</div>
30-
<div className='w-2/3 p-4'>
31-
<Link
32-
href={frontmatter.Specification}
33-
className='text-primary hover:underline dark:text-blue-400'
34-
target='_blank'
35-
rel='noopener noreferrer'
36-
>
37-
{frontmatter.Specification}
38-
</Link>
34+
{frontmatter.Specification && (
35+
<div className='border-b border-border'>
36+
<div className='flex'>
37+
<div className='w-1/3 p-4 font-semibold text-base text-[#334155] dark:text-slate-300'>
38+
Specification
39+
</div>
40+
<div className='w-2/3 p-4'>
41+
<Link
42+
href={frontmatter.Specification}
43+
className='text-primary hover:underline dark:text-blue-400'
44+
target='_blank'
45+
rel='noopener noreferrer'
46+
>
47+
{frontmatter.Specification}
48+
</Link>
49+
</div>
3950
</div>
4051
</div>
41-
</div>
42-
<div className='border-b border-border'>
43-
<div className='flex'>
44-
<div className='w-1/3 p-4 font-semibold text-base text-[#334155] dark:text-slate-300'>
45-
Published
52+
)}
53+
{frontmatter.Published && (
54+
<div className='border-b border-border'>
55+
<div className='flex'>
56+
<div className='w-1/3 p-4 font-semibold text-base text-[#334155] dark:text-slate-300'>
57+
Published
58+
</div>
59+
<div className='w-2/3 p-4'>{frontmatter.Published}</div>
4660
</div>
47-
<div className='w-2/3 p-4'>{frontmatter.Published}</div>
4861
</div>
49-
</div>
50-
<div className='border-b border-border'>
51-
<div className='flex'>
52-
<div className='w-1/3 p-4 font-semibold text-base text-[#334155] dark:text-slate-300'>
53-
Authors
54-
</div>
55-
<div className='w-2/3 p-4'>
56-
{frontmatter.authors.map((author: string, index: number) => (
57-
<span key={index}>
58-
{author}
59-
{index < frontmatter.authors.length - 1 ? ', ' : ''}
60-
</span>
61-
))}
62+
)}
63+
{authors.length > 0 && (
64+
<div className='border-b border-border'>
65+
<div className='flex'>
66+
<div className='w-1/3 p-4 font-semibold text-base text-[#334155] dark:text-slate-300'>
67+
Authors
68+
</div>
69+
<div className='w-2/3 p-4'>
70+
{authors.map((author, index: number) => (
71+
<span key={index}>
72+
{getAuthorName(author)}
73+
{index < authors.length - 1 ? ', ' : ''}
74+
</span>
75+
))}
76+
</div>
6277
</div>
6378
</div>
64-
</div>
65-
<div>
66-
<div className='flex'>
67-
<div className='w-1/3 p-4 font-semibold text-base text-[#334155] dark:text-slate-300'>
68-
Metaschema
69-
</div>
70-
<div className='w-2/3 p-4'>
71-
<Link
72-
href={frontmatter.Metaschema}
73-
className='text-primary hover:underline dark:text-blue-400'
74-
target='_blank'
75-
rel='noopener noreferrer'
76-
>
77-
{frontmatter.Metaschema}
78-
</Link>
79+
)}
80+
{frontmatter.Metaschema && (
81+
<div>
82+
<div className='flex'>
83+
<div className='w-1/3 p-4 font-semibold text-base text-[#334155] dark:text-slate-300'>
84+
Metaschema
85+
</div>
86+
<div className='w-2/3 p-4'>
87+
<Link
88+
href={frontmatter.Metaschema}
89+
className='text-primary hover:underline dark:text-blue-400'
90+
target='_blank'
91+
rel='noopener noreferrer'
92+
>
93+
{frontmatter.Metaschema}
94+
</Link>
95+
</div>
7996
</div>
8097
</div>
81-
</div>
98+
)}
8299
</div>
83100
</CardContent>
84101
</Card>

pages/[slug].page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ import { Headline1 } from '~/components/Headlines';
88
import { SectionContext } from '~/context';
99
import { DocsHelp } from '~/components/DocsHelp';
1010
import NextPrevButton from '~/components/NavigationButtons';
11+
import type { Frontmatter } from '~/types/common';
1112

1213
export async function getStaticPaths() {
1314
return getStaticMarkdownPaths('pages');
1415
}
15-
export async function getStaticProps(args: any) {
16+
export async function getStaticProps(args: { params?: { slug: string } }) {
1617
return getStaticMarkdownProps(args, 'pages');
1718
}
1819

1920
export default function StaticMarkdownPage({
2021
frontmatter,
2122
content,
2223
}: {
23-
frontmatter: any;
24-
content: any;
24+
frontmatter: Frontmatter;
25+
content: string;
2526
}) {
2627
const fileRenderType = '_md';
2728
const newTitle = 'JSON Schema - ' + frontmatter.title;

pages/ambassadors/index.page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function getStaticProps() {
2626
export default function ambassadorPages({
2727
ambassadorData,
2828
}: {
29-
ambassadorData: any;
29+
ambassadorData: string;
3030
}) {
3131
return (
3232
<SectionContext.Provider value='ambassador'>

pages/draft-05/index.page.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import DocTable from '~/components/DocTable';
88
import { Headline1 } from '~/components/Headlines';
99
import { DocsHelp } from '~/components/DocsHelp';
1010
import NextPrevButton from '~/components/NavigationButtons';
11+
import { Frontmatter } from '~/types/common';
1112

1213
export async function getStaticProps() {
1314
const index = fs.readFileSync('pages/draft-05/index.md', 'utf-8');
@@ -27,12 +28,23 @@ export async function getStaticProps() {
2728
};
2829
}
2930

31+
interface DraftFrontmatter extends Frontmatter {
32+
Specification?: string;
33+
Published?: string;
34+
Metaschema?: string;
35+
}
36+
37+
interface BlocksData {
38+
index: string;
39+
body: string;
40+
}
41+
3042
export default function ImplementationsPages({
3143
blocks,
3244
frontmatter,
3345
}: {
34-
blocks: any;
35-
frontmatter: any;
46+
blocks: BlocksData;
47+
frontmatter: DraftFrontmatter;
3648
}) {
3749
const fileRenderType = 'indexmd';
3850
return (

pages/draft-06/[slug].page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,27 @@ import getStaticMarkdownProps from '~/lib/getStaticMarkdownProps';
77
import { Headline1 } from '~/components/Headlines';
88
import { SectionContext } from '~/context';
99
import { DocsHelp } from '~/components/DocsHelp';
10+
import { Frontmatter } from '~/types/common';
1011

1112
export async function getStaticPaths() {
1213
return getStaticMarkdownPaths('pages/draft-06');
1314
}
14-
export async function getStaticProps(args: any) {
15+
export async function getStaticProps(args: { params?: { slug: string } }) {
1516
return getStaticMarkdownProps(args, 'pages/draft-06');
1617
}
1718

1819
export default function StaticMarkdownPage({
1920
frontmatter,
2021
content,
2122
}: {
22-
frontmatter: any;
23-
content: any;
23+
frontmatter: Frontmatter;
24+
content: string;
2425
}) {
2526
const fileRenderType = '_md';
2627
const newTitle = 'JSON Schema - ' + frontmatter.title;
2728

2829
return (
29-
<SectionContext.Provider value={frontmatter.section || null}>
30+
<SectionContext.Provider value={frontmatter.section ?? null}>
3031
<Head>
3132
<title>{newTitle}</title>
3233
</Head>

pages/draft-06/index.page.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import DocTable from '~/components/DocTable';
88
import { Headline1 } from '~/components/Headlines';
99
import { DocsHelp } from '~/components/DocsHelp';
1010
import NextPrevButton from '~/components/NavigationButtons';
11+
import { Frontmatter } from '~/types/common';
1112

1213
export async function getStaticProps() {
1314
const index = fs.readFileSync('pages/draft-06/index.md', 'utf-8');
@@ -25,12 +26,22 @@ export async function getStaticProps() {
2526
};
2627
}
2728

29+
interface DraftFrontmatter extends Frontmatter {
30+
Specification?: string;
31+
Published?: string;
32+
Metaschema?: string;
33+
}
34+
35+
interface BlocksData {
36+
index: string;
37+
}
38+
2839
export default function ImplementationsPages({
2940
blocks,
3041
frontmatter,
3142
}: {
32-
blocks: any;
33-
frontmatter: any;
43+
blocks: BlocksData;
44+
frontmatter: DraftFrontmatter;
3445
}) {
3546
const fileRenderType = 'indexmd';
3647
return (

pages/draft-07/[slug].page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,27 @@ import getStaticMarkdownProps from '~/lib/getStaticMarkdownProps';
77
import { Headline1 } from '~/components/Headlines';
88
import { SectionContext } from '~/context';
99
import { DocsHelp } from '~/components/DocsHelp';
10+
import { Frontmatter } from '~/types/common';
1011

1112
export async function getStaticPaths() {
1213
return getStaticMarkdownPaths('pages/draft-07');
1314
}
14-
export async function getStaticProps(args: any) {
15+
export async function getStaticProps(args: { params?: { slug: string } }) {
1516
return getStaticMarkdownProps(args, 'pages/draft-07');
1617
}
1718

1819
export default function StaticMarkdownPage({
1920
frontmatter,
2021
content,
2122
}: {
22-
frontmatter: any;
23-
content: any;
23+
frontmatter: Frontmatter;
24+
content: string;
2425
}) {
2526
const fileRenderType = '_md';
2627
const newTitle = 'JSON Schema - ' + frontmatter.title;
2728

2829
return (
29-
<SectionContext.Provider value={frontmatter.section || null}>
30+
<SectionContext.Provider value={frontmatter.section ?? null}>
3031
<Head>
3132
<title>{newTitle}</title>
3233
</Head>

pages/draft-07/index.page.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import DocTable from '~/components/DocTable';
88
import { Headline1 } from '~/components/Headlines';
99
import { DocsHelp } from '~/components/DocsHelp';
1010
import NextPrevButton from '~/components/NavigationButtons';
11+
import { Frontmatter } from '~/types/common';
1112

1213
export async function getStaticProps() {
1314
const index = fs.readFileSync('pages/draft-07/index.md', 'utf-8');
@@ -25,12 +26,22 @@ export async function getStaticProps() {
2526
};
2627
}
2728

29+
interface DraftFrontmatter extends Frontmatter {
30+
Specification?: string;
31+
Published?: string;
32+
Metaschema?: string;
33+
}
34+
35+
interface BlocksData {
36+
index: string;
37+
}
38+
2839
export default function ImplementationsPages({
2940
blocks,
3041
frontmatter,
3142
}: {
32-
blocks: any;
33-
frontmatter: any;
43+
blocks: BlocksData;
44+
frontmatter: DraftFrontmatter;
3445
}) {
3546
const fileRenderType = 'indexmd';
3647
return (

pages/draft/2019-09/[slug].page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,27 @@ import getStaticMarkdownProps from '~/lib/getStaticMarkdownProps';
77
import { Headline1 } from '~/components/Headlines';
88
import { SectionContext } from '~/context';
99
import { DocsHelp } from '~/components/DocsHelp';
10+
import { Frontmatter } from '~/types/common';
1011

1112
export async function getStaticPaths() {
1213
return getStaticMarkdownPaths('pages/draft/2019-09');
1314
}
14-
export async function getStaticProps(args: any) {
15+
export async function getStaticProps(args: { params?: { slug: string } }) {
1516
return getStaticMarkdownProps(args, 'pages/draft/2019-09');
1617
}
1718

1819
export default function StaticMarkdownPage({
1920
frontmatter,
2021
content,
2122
}: {
22-
frontmatter: any;
23-
content: any;
23+
frontmatter: Frontmatter;
24+
content: string;
2425
}) {
2526
const fileRenderType = '_md';
2627
const newTitle = 'JSON Schema - ' + frontmatter.title;
2728

2829
return (
29-
<SectionContext.Provider value={frontmatter.section || null}>
30+
<SectionContext.Provider value={frontmatter.section ?? null}>
3031
<Head>
3132
<title>{newTitle}</title>
3233
</Head>

0 commit comments

Comments
 (0)