Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

81
Visualizações
post.frontmatter.title.filter is not a function

I want to filter some posts from data.I try to use this code but it don't work.It run out post.frontmatter.title.filter is not a function

{posts.map((post, index) => (
 post.frontmatter.title.filter(name=>name.includes('J')).map(filterdtitle=>(
<li>{filterdtitle}</li>
))
))}

I get the data of posts by getStaticProps like this and then I pass the posts to the function.The posts include title.I can get by {post.frontmatter.title},it is working.

 const { data: frontmatter } = matter(markdownWithMeta)

    return {
      slug,
      frontmatter
    }
  })

I want to know that how make it work.Thank you

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I believe you need to rewrite your code like this.

  1. the title is a string, and the filter doesn't support string

  2. you added an extra step by using a filter and include in the same line for a title.


     {
      posts.filter((post, index) =>   
 post.frontmatter.title.includes('K')).map((k)=><li>{k.frontmatter.title}</li>)
        }
about 4 years ago · Juan Pablo Isaza Relatório

0

Looks like title is a string. filter() method is available only for array.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda