@vuepress/shared-utils
Advanced tools
Comparing version 1.5.3 to 1.5.4
@@ -10,2 +10,24 @@ "use strict"; | ||
} | ||
function toUtcTime(date) { | ||
let year = 1970; | ||
let month = 0; | ||
let day = 1; | ||
if (typeof date === 'string') { | ||
const [yearStr, monthStr, dayStr] = date.split('-'); | ||
year = parseInt(yearStr, 10); | ||
month = parseInt(monthStr, 10) - 1; | ||
day = parseInt(dayStr, 10); | ||
} | ||
else if (date instanceof Date) { | ||
// If `date` is an instance of Date, | ||
// it's because it was parsed from the frontmatter | ||
// by js-yaml, which always assumes UTC | ||
return date.getTime(); | ||
} | ||
return Date.UTC(year, month, day); | ||
} | ||
function addTzOffset(utc) { | ||
const utcDate = new Date(utc); | ||
return new Date(utc + utcDate.getTimezoneOffset() * 60 * 1000); | ||
} | ||
module.exports = function getPermalink({ pattern, slug, date, regularPath, localePath = '/' }) { | ||
@@ -16,3 +38,3 @@ if (!pattern) { | ||
slug = encodeURI(slug); | ||
const d = new Date(date); | ||
const d = addTzOffset(toUtcTime(date)); | ||
const year = d.getFullYear(); | ||
@@ -19,0 +41,0 @@ const iMonth = d.getMonth() + 1; |
"use strict"; | ||
// string.js slugify drops non ascii chars so we have to | ||
// use a custom implementation here | ||
const diacritics_1 = require("diacritics"); | ||
// eslint-disable-next-line no-control-regex | ||
const rControl = /[\u0000-\u001f]/g; | ||
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’–—<>,.?/]+/g; | ||
const rCombining = /[\u0300-\u036F]/g; | ||
module.exports = function slugify(str) { | ||
return diacritics_1.remove(str) | ||
// Split accented characters into components | ||
return str.normalize('NFKD') | ||
// Remove accents | ||
.replace(rCombining, '') | ||
// Remove control characters | ||
@@ -11,0 +14,0 @@ .replace(rControl, '') |
{ | ||
"name": "@vuepress/shared-utils", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"description": "shared-utils for vuepress", | ||
@@ -34,3 +34,2 @@ "keywords": [ | ||
"chalk": "^2.3.2", | ||
"diacritics": "^1.3.0", | ||
"escape-html": "^1.0.3", | ||
@@ -51,3 +50,3 @@ "fs-extra": "^7.0.1", | ||
}, | ||
"gitHead": "94dfb757224173c2a2bfdeece6ca690e85036757" | ||
"gitHead": "98086ad620d4ba51f08497acddad8ffc1fc1273c" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44688
9
73
1197
- Removeddiacritics@^1.3.0
- Removeddiacritics@1.3.0(transitive)