1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-08 23:15:28 +02:00

Changed uri parsing

This commit is contained in:
DorofeevMark 2018-12-25 18:39:44 +03:00
parent 4509235409
commit 65c4d85eff
5 changed files with 18 additions and 11 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,6 @@
const Model = require('../models/page');
const Alias = require('../models/alias');
const aliasTypes = require('../constants/aliasTypes');
const md5 = require('../utils/md5');
/**
* @class Pages
@ -60,9 +59,8 @@ class Pages {
const alias = new Alias({
id: updatedPage._id,
type: aliasTypes.PAGE,
hash: md5(updatedPage.uri)
});
type: aliasTypes.PAGE
}, updatedPage.uri);
alias.save();
@ -129,9 +127,8 @@ class Pages {
const alias = new Alias({
id: updatedPage._id,
type: aliasTypes.PAGE,
hash: md5(updatedPage.uri)
});
type: aliasTypes.PAGE
}, updatedPage.uri);
alias.save();
}

View file

@ -3,7 +3,7 @@
--color-text-second: #7B7E89;
--color-line-gray: #E8E8EB;
--color-link-active: #388AE5;
--color-gray-border: rgba(201, 201, 204, 0.48);
--color-gray-border: rgba(var(--color-line-gray), 0.48);
/**
* Site layout sizes

View file

@ -39,14 +39,18 @@ class Alias {
* @constructor
*
* @param {AliasData} data
* @param {string} aliasName - alias of entity
*/
constructor(data = {}) {
constructor(data = {}, aliasName) {
if (data === null) {
data = {};
}
if (data._id) {
this._id = data._id;
}
if (aliasName) {
this.hash = md5(aliasName);
}
this.data = data;
}

View file

@ -84,7 +84,13 @@ class Page {
this.body = body || this.body;
this.title = this.extractTitleFromBody();
this.uri = uri || translateString(this.title.toLowerCase()).split(' ').join('-');
this.uri = uri || translateString(this.title
.replace(/ /g, ' ')
.replace(/-/g, ' ')
.trim()
.toLowerCase()
.split(' ')
.join('-'));
this._parent = parent || this._parent;
}