1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-26 00:29:45 +02:00

Some design updates (#70)

* Auth page styles improved

* styles updated

* upd bundles
This commit is contained in:
Peter Savchenko 2019-03-13 12:25:43 +03:00 committed by GitHub
parent 7c7c0d62d9
commit c7219f8943
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 288 additions and 48 deletions

33
src/utils/urlify.js Normal file
View file

@ -0,0 +1,33 @@
const translateString = require('./translation');
/**
* Convert text to URL-like string
* Example: "What is <mark>clean data</mark>" -> "what-is-clean-data"
*
* @param {string} string - source string with HTML
* @returns {string} alias-like string
*/
module.exports = function urlify(string) {
// strip tags
string = string.replace(/(<([^>]+)>)/ig, '');
// remove nbsp
string = string.replace(/&nbsp;/g, ' ');
// remove all symbols except chars
string = string.replace(/[^a-zA-Z0-9А-Яа-яЁё ]/g, ' ');
// remove whitespaces
string = string.replace(/ +/g, ' ').trim();
// lowercase
string = string.toLowerCase();
// join words with hyphens
string = string.split(' ').join('-');
// translate
string = translateString(string);
return string;
};