Skip to content

Commit

Permalink
chore($core): using hash-sum to generate page's hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Nov 29, 2018
1 parent 1a897cb commit 8a4b5e8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/@vuepress/core/lib/prepare/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@
*/

const { inferDate, DATE_RE } = require('../util/index')
const { extractHeaders, fs, path, fileToPath, parseFrontmatter, getPermalink, inferTitle, slugify } = require('@vuepress/shared-utils')
const {
fs,
path,
hash,
slugify,
inferTitle,
fileToPath,
getPermalink,
extractHeaders,
parseFrontmatter
} = require('@vuepress/shared-utils')

/**
* Expose Page class.
Expand Down Expand Up @@ -50,7 +60,7 @@ module.exports = class Page {
this.regularPath = encodeURI(permalink)
}

this.key = 'v-' + Math.random().toString(16).slice(2)
this.key = 'v-' + hash(`${this._filePath}${this.regularPath}`)
// Using regularPath first, would be override by permalink later.
this.path = this.regularPath
}
Expand Down

0 comments on commit 8a4b5e8

Please sign in to comment.