ekoeryanto / vuepress-plugin-sitemap

Sitemap generator plugin for vuepress.
MIT License
93 stars 19 forks source link

RangeError: Invalid time value. Version 2.3.1 #42

Open yinhuanyi opened 2 years ago

yinhuanyi commented 2 years ago

when I build vuepress,error occured. error vuepress-plugin-sitemap apply generated failed. RangeError: Invalid time value at Date.toISOString () at dateFormatter (/Users/Robby/Yinhuanyi_Project/WebStorm/vuepress-blog/node_modules/vuepress-plugin-sitemap/index.js:24:60) at /Users/Robby/Yinhuanyi_Project/WebStorm/vuepress-blog/node_modules/vuepress-plugin-sitemap/index.js:69:13 at Array.forEach () at generated (/Users/Robby/Yinhuanyi_Project/WebStorm/vuepress-blog/node_modules/vuepress-plugin-sitemap/index.js:56:13) at AsyncOption.asyncApply (/Users/Robby/Yinhuanyi_Project/WebStorm/vuepress-blog/node_modules/@vuepress/core/lib/node/plugin-api/abstract/AsyncOption.js:33:21) at PluginAPI.applyAsyncOption (/Users/Robby/Yinhuanyi_Project/WebStorm/vuepress-blog/node_modules/@vuepress/core/lib/node/plugi

anisabboud commented 1 year ago

To fix this bug, need to change line 69 from page.lastUpdated -> page.lastUpdatedTimestamp.

https://github.com/ekoeryanto/vuepress-plugin-sitemap/blob/f3648c3c3011e06b4a075b31fecda6a658318403/index.js#L68-L70

Explanation

    lastUpdated: '21.5.2023, 23:13:40',  // Cannot be parsed by new Date(...) -> Invalid time value error
    lastUpdatedTimestamp: 1684700020000  // Can be parsed new Date(...) ✓