0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 18:02:42 +00:00

Improve link text generation

This commit is contained in:
G.Ambatte
2025-01-06 23:54:05 +13:00
parent bf0614026d
commit a6b7ed4dd2

View File

@@ -56,11 +56,19 @@ const HeaderNav = React.forwardRef(({}, pagesRef)=>{
const HeaderNavItem = ({ link, text, depth, className })=>{
const trimString = (text, prefixLength = 0)=>{
const maxLength = MAX_TEXT_LENGTH - prefixLength;
if(text.trim().length > maxLength){
return `${text.trim().slice(0, maxLength)}...`;
let output = text;
if(text.indexOf('\n')){
output = text.split('\n')[0];
}
return text.trim();
output = output.trim();
const maxLength = MAX_TEXT_LENGTH - prefixLength;
if(output.length > maxLength){
return `${output.slice(0, maxLength).trim()}...`;
}
return output;
};
return <li>