fedwiki / wiki-server

Federated Wiki client and server in Node.js
Other
153 stars 35 forks source link

ignore sitemap pages with null date in xml conversion #116

Closed WardCunningham closed 8 years ago

WardCunningham commented 8 years ago

This guard protects against pages with no date, probably with no journal at all. I have such pages in my test site and get this error on startup.

 RangeError: Invalid time value
  at Date.toISOString (native)
  at /Users/ward/test-restful-plugins/node_modules/wiki/node_modules/wiki-server/lib/sitemap.js:121:32
  at arrayEach (/Users/ward/test-restful-plugins/node_modules/wiki/node_modules/wiki-server/node_modules/lodash/index.js:1289:13)
  at Function.<anonymous> (/Users/ward/test-restful-plugins/node_modules/wiki/node_modules/wiki-server/node_modules/lodash/index.js:3345:13)
  at xmlSitemapSave (/Users/ward/test-restful-plugins/node_modules/wiki/node_modules/wiki-server/lib/sitemap.js:115:7)
  at serial (/Users/ward/test-restful-plugins/node_modules/wiki/node_modules/wiki-server/lib/sitemap.js:169:14)
  at /Users/ward/test-restful-plugins/node_modules/wiki/node_modules/wiki-server/lib/sitemap.js:209:16
  at doNTCallback0 (node.js:407:9)
  at process._tickCallback (node.js:336:13)
paul90 commented 8 years ago

Rather than excluding pages without a date from the sitemap, I wonder if they should be included but without a date (lastmod is optional)?

      if isNaN(Date.parse(page.date)) == false
        date = new Date(page.date)
        result["lastmod"] = date.toISOString().substring(0,10)
WardCunningham commented 8 years ago

Sure. We're dealing with it in the json sitemap.

In the json, everything is optional. But when fields are present, they should make sense. This is the ideal anyway.