1

我有以下功能,我试图在“标题”和“摘要”中搜索在搜索栏中输入的内容。但是,这会引发一个错误,即此处不允许使用 'const'。

import { frontMatter as blogs1 } from './blog/*.mdx';
const filteredBlogPosts = blogs1
    .sort(
      (a, b) =>
        Number(new Date(b.publishedAt)) - Number(new Date(a.publishedAt))
    )
    .filter((frontMatter) =>
      const concat = frontMatter.summary + frontMatter.title, #Error. How to search for both title and summary for entered search value?
      concat.toLowerCase().includes(searchValue.toLowerCase()),
    );

导入的 blogs1 具有这样的内容 - 如何使 MDX 文件的内容部分也可搜索?至少对于标题和摘要,我有一个键值对。但是如何使这个 MDX 文件内容中的文本(下面示例中的“目录”之后的任何内容)也可搜索?

---
title: 'abc def ghi'
publishedAt: '2020-09-06'
summary: "xyz mnk."
image: '/static/images/chapter18/1.png'
---

## Table of Contents

1.  [Introduction](#introduction)
2.  [Alphabet and xyz](#comparing-alphabet-and-xyz)
3.  [ABC](#abc)

# Introduction

This is an attempt at something.<br/>

![Test](/static/images/chapter18/2.png)<br/>
4

0 回答 0