meteor-sitemaps icon indicating copy to clipboard operation
meteor-sitemaps copied to clipboard

Cannot read property 'find' of undefined

Open stephane-r opened this issue 7 years ago • 1 comments

Yop,

I would like add your module on my Meteor App, but /sitemap.xml return this error :

TypeError: Cannot read property 'find' of undefined
   at imports/startup/server/sitemaps.js:10:17
   at packages/gadicohen_sitemaps.js:120:15 

I use latest Meteor version (5).

My sitemaps.js (server) :

import { Meteor } from 'meteor/meteor';
import { sitemaps } from 'meteor/gadicohen:sitemaps';
import { Post } from '../../api/Post.js';

sitemaps.config('rootUrl', 'https://stephane-richin.fr/');

sitemaps.add('/sitemap.xml', () => {

  const postsUrls = [];
  const posts = Post.find({ 'draft': false }).fetch();

  _.each(posts, function (page) {

    postsUrls.push({
      page: `/blog/${page.slug}`,
      lastmod: new Date()
    });

  });

  const staticPages = [
    { page: '/', lastmod: new Date() },
    { page: '/blog', lastmod: new Date() },
    { page: '/a-propos', lastmod: new Date() },
    { page: '/contact', lastmod: new Date() }
  ];

  const urls = [...staticPages, ...postsUrls];

  // required: page
  // optional: lastmod, changefreq, priority, xhtmlLinks, images, videos
  return urls;

});

Do you have any idea ?

Thank you :)

stephane-r avatar Jun 07 '17 09:06 stephane-r

I think this package hasn't been updated since Meteor 1.3 enabled imports. Same issue here

joncursi avatar Jun 14 '17 21:06 joncursi