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:
parent
7c7c0d62d9
commit
c7219f8943
20 changed files with 288 additions and 48 deletions
33
src/utils/urlify.js
Normal file
33
src/utils/urlify.js
Normal 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(/ /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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue