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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user