Skip to content

Can't create atom1 feed because of: url.replace is not defined #169

@RenatoCesarF

Description

@RenatoCesarF

Here's my code:

  const files = fs.readdirSync(path.join('posts'));
    
  files.map((filename) => {
    const slug = filename.replace('.md', '');
    const markdownWithMeta = fs.readFileSync(path.join('posts', filename), 'utf-8');
    const {data, content} = matter(markdownWithMeta);
    const maximumExcerptSize = 80
    if(data.excerpt.length > maximumExcerptSize){
        data.excerpt = data.excerpt.substr(0, maximumExcerptSize) + '...';
    } 
    const url = `${baseUrl}/${slug}`;
    const item: Item = {
      title: data.title,
      image: data.cover_image,
      link: url.toString(),
      date: new Date(),
      id: slug,
      description: data.excerpt,
      content:  data.content,
      author: [data.author],
      contributor: [author],
    }
    feed.addItem(item);
  });

All the others feeds functions work except for atom1() that returns:
error - TypeError: url.replace is not a function

My first ideas was that some url paramter was in another format, so I transformed it to string, but the error continues.

If I remove the add item code the error desapears

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions