Skip to content

Permalinks generation unable to parse other date formats #2880

Open
@re-xyr

Description

@re-xyr
  • I confirm that this is an issue rather than a question.

Bug report

Current permalink generation from date frontmatter field is using a simple split on - characters. When using other formats of date (that is able to be parsed by Date), the permalink fails to generate. I noticed that this change was due to a flaw in the Date API (#2181). If so, please use a date library (e.g. dayjs) instead of rolling an error-prone parser.

The same problem is present in vuepress-next.

Steps to reproduce

Put this in a file:

---
date: Thu May 06 2021 18:10:16 GMT+0800 (中国标准时间)
permalink: /:year/:month/:day/:slug
---

What is expected?

Page is at /2021/05/06/....

What is actually happening?

Page is at /NaN/NaN/NaN/....

Other relevant information

  • Output of npx vuepress info in my VuePress project:
Environment Info:

  System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  Binaries:
    Node: 14.15.5 - /usr/local/bin/node
    Yarn: 1.13.0 - /usr/local/bin/yarn
    npm: 7.13.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 93.0.4549.4
    Edge: Not Found
    Firefox: 62.0.3
    Safari: 14.0.3
  npmPackages:
    @vuepress/core:  1.8.2 
    @vuepress/theme-default:  1.8.2 
    vuepress: ^1.8.2 => 1.8.2 
  npmGlobalPackages:
    vuepress: Not Found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions