Skip to content

Commit

Permalink
Merge pull request #137 from ChtiJS/fix/types
Browse files Browse the repository at this point in the history
fix(lint): fix linting
  • Loading branch information
nfroidure authored Nov 21, 2023
2 parents 89af397 + c3f472c commit 15116fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/pages/conferences/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import useSWR from 'swr';
import lunr from 'lunr';
import lunr, { type Index } from 'lunr';
import { join as pathJoin } from 'path';
import Layout from '../../layouts/main';
import ContentBlock from '../../components/contentBlock';
Expand Down Expand Up @@ -70,7 +70,7 @@ const BlogEntries = ({
pagesCount,
}: Props) => {
const [search, setSearch] = useState('');
const [searchIndex, setSearchIndex] = useState<any>();
const [searchIndex, setSearchIndex] = useState<Index>();
const [searchResults, setSearchResults] = useState<
{ id: string; title: string; description: string }[]
>([]);
Expand All @@ -92,11 +92,7 @@ const BlogEntries = ({
if (searchIndex && search) {
setSearchResults(
(
searchIndex.search(search) as {
ref: string;
score: number;
metadata: Record<string, unknown>;
}[]
searchIndex.search(search)
).map((result) => ({
result,
id: result.ref,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ const hyperlinkMap: NodeToElementMapper<MarkdownLinkNode> = (context, node) => {
);
};

const elementsMapping: Record<MarkdownNodeType, NodeToElementMapper<any>> = {
const elementsMapping = {
root: rootMap,
paragraph: paragraphMap,
heading: headingMap,
Expand All @@ -371,7 +371,7 @@ const elementsMapping: Record<MarkdownNodeType, NodeToElementMapper<any>> = {
bold: boldMap,
strong: boldMap,
html: htmlMap,
};
} as const;

export function parseMarkdown(input: string): MarkdownNode {
return unified().use(remarkParse).parse(input) as unknown as MarkdownNode;
Expand All @@ -386,7 +386,7 @@ export function renderMarkdown<T extends MappingContext>(
}

if (elementsMapping[node.type]) {
return elementsMapping[node.type](context, node);
return elementsMapping[node.type as 'root'](context, node as MarkdownRootNode);
}

console.warn(`Unrecognized Markdown element:`, node);
Expand Down

0 comments on commit 15116fa

Please sign in to comment.