feat: feed feature, typescript, remove google, fix errs & warns
publish / Build-and-publish (push) Successful in 13m32s
publish / Build-and-publish (push) Successful in 13m32s
This commit is contained in:
1 parent
2c42ecae5f
commit
8a10d127c1
55 files changed
+1887
-587
No files matched your search
@@ -1,8 +1,6 @@
|
||||
import { Link, graphql, useStaticQuery } from 'gatsby'
|
||||
import React from 'react'
|
||||
import kebabCase from 'lodash/kebabCase'
|
||||
import { Link, graphql, useStaticQuery, PageProps } from 'gatsby'
|
||||
import * as React from 'react'
|
||||
import { useFlexSearch } from 'react-use-flexsearch'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import Layout from '../components/layout'
|
||||
import Seo from '../components/seo'
|
||||
@@ -17,7 +15,19 @@ import {
|
||||
import Post from './postpreview'
|
||||
import { SideBar } from './sidebar'
|
||||
|
||||
const BlogSearchTemplate = ({ location, pageContext }) => {
|
||||
import type { PageContext, PostNode, SearchPost } from '../types'
|
||||
|
||||
interface SearchData {
|
||||
localSearchBlog: {
|
||||
index: string
|
||||
store: Record<string, unknown>
|
||||
}
|
||||
}
|
||||
|
||||
const BlogSearchTemplate: React.FC<PageProps<SearchData, PageContext>> = ({
|
||||
location,
|
||||
pageContext
|
||||
}) => {
|
||||
const queryData = useStaticQuery(graphql`
|
||||
query {
|
||||
localSearchBlog {
|
||||
@@ -34,12 +44,12 @@ const BlogSearchTemplate = ({ location, pageContext }) => {
|
||||
query,
|
||||
queryData.localSearchBlog.index,
|
||||
queryData.localSearchBlog.store
|
||||
)
|
||||
const postsJSX = []
|
||||
) as SearchPost[]
|
||||
const postsJSX: React.ReactElement[] = []
|
||||
|
||||
if (query) {
|
||||
posts.forEach((post, i) => {
|
||||
const _post = {
|
||||
const _post: PostNode = {
|
||||
id: post.id,
|
||||
html: post.html,
|
||||
fields: {
|
||||
@@ -48,7 +58,7 @@ const BlogSearchTemplate = ({ location, pageContext }) => {
|
||||
frontmatter: {
|
||||
title: post.title,
|
||||
date: post.date,
|
||||
previewImg: post.previewImg
|
||||
previewImg: post.previewImg as PostNode['frontmatter']['previewImg']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user