Automatically removes leading and trailing spaces from tags because tags
are often entered with a space after each comma. This uses .trim() in func.render_tags() to remove when rendering as well as .map(str => str.trim()) when a post or post edit is submitted so they are also stored without spaces.
This commit is contained in:
@@ -44,7 +44,7 @@ export function render_tags(tags) {
|
||||
}
|
||||
else {
|
||||
for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag
|
||||
string += `<a href="/tag/${tags[tag_index]}">${tags[tag_index]}</a>` // Adds the tag to the string as a HTML href
|
||||
string += `<a href="/tag/${tags[tag_index].trim()}">${tags[tag_index].trim()}</a>` // Adds the tag to the string as a HTML href
|
||||
if (tag_index < tags.length - 1) { // If there are more tags, then insert a comma
|
||||
string += ", ";
|
||||
}
|
||||
|
Reference in New Issue
Block a user