You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Idea: a script with button/keystroke for "turn note title into share-alias". Also make it apply when changing a note's status to Shared, but it only acts if #shareAlias is missing/empty. In case of duplicate append something.
Changing the friendly URL should not be done automatically by the system, because the user might not be aware that changing the title will also affect the URL. Generally once a page is published it's a good idea to keep the URL the same in order not to break any hard links (inside the application, or bookmarked by viewers of the site).
The shareAlias would continue to be able to be changed by a deliberate act by the user, the same way it is now (which could be the user executing the putative titleToShareAlias function).
The user guide has this example under Apply bulk actions >> Other:
To alter attributes of a note based on another attribute, such as setting the #shareAlias label to the title of the note:
note.setLabel("shareAlias", note.title)
From which I concocted the script below. I haven't figured out how to apply it though. It has no effect when used in bulk actions and I don't understand how to turn a script into a widget.
/**
* Converts a string into a human-friendly kebab-case URL fragment.
* Removes or replaces special characters, trims, and lowercases.
* Example: "Title with: special %^&* chars" -> "title-with-special-chars"
*
* @param str - The input string to convert
* @returns The kebab-case URL fragment
*/
function toKebab(str) {
return str
.normalize("NFKD") // Normalize unicode
.replace(/[\u0300-\u036f]/g, '') // Remove diacritics/accents
.replace(/[^\w\s-]/g, '') // Remove non-word, non-space, non-hyphen
.trim() // Trim leading/trailing whitespace
.replace(/[-\s]+/g, '-') // Replace spaces and hyphens with single hyphen
.toLowerCase();
}
console.log(toKebab(api.note.title)); // debug
api.note.setLabel("shareAlias", toKebab(api.note.title)); // #shareAlias=title-with-special-chars
Describe feature
Idea: a script with button/keystroke for "turn note title into share-alias". Also make it apply when changing a note's status to Shared, but it only acts if
#shareAlias
is missing/empty. In case of duplicate append something.Changing the friendly URL should not be done automatically by the system, because the user might not be aware that changing the title will also affect the URL. Generally once a page is published it's a good idea to keep the URL the same in order not to break any hard links (inside the application, or bookmarked by viewers of the site).
The shareAlias would continue to be able to be changed by a deliberate act by the user, the same way it is now (which could be the user executing the putative titleToShareAlias function).
Originally posted by @maphew in TriliumNext/Docs#117 (comment)
The text was updated successfully, but these errors were encountered: