Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tech-Science Blog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Muhammad Butt
Tech-Science Blog
Commits
3eb1d876
Commit
3eb1d876
authored
5 years ago
by
Saif Ali
Browse files
Options
Downloads
Patches
Plain Diff
dynamic slug creation
parent
51e46ea2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#3168
failed
5 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
First version code
+0
-1
0 additions, 1 deletion
First version code
assets/slugify.js
+14
-0
14 additions, 0 deletions
assets/slugify.js
with
14 additions
and
1 deletion
First version code
@
82657a9f
Subproject commit 82657a9fee126b00afb9da3dab9a1fe4f1361fe9
This diff is collapsed.
Click to expand it.
assets/slugify.js
0 → 100644
+
14
−
0
View file @
3eb1d876
const
titleInput
=
document
.
querySelector
(
'
input[name=title]
'
);
const
slugInput
=
document
.
querySelector
(
'
input[name=slug]
'
);
const
slugify
=
(
val
)
=>
{
return
val
.
toString
().
toLowerCase
().
trim
()
.
replace
(
/&/g
,
'
-and-
'
)
// Replace & with 'and'
.
replace
(
/
[\s\W
-
]
+/g
,
'
-
'
)
// Replace spaces, non-word characters and dashes with a single dash (-)
};
titleInput
.
addEventListener
(
'
keyup
'
,
(
e
)
=>
{
slugInput
.
setAttribute
(
'
value
'
,
slugify
(
titleInput
.
value
));
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment