initial commit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
export function excerpt(body: string, length = 160): string {
|
||||
const plain = body
|
||||
.replace(/```[\s\S]*?```/g, ' ')
|
||||
.replace(/!\[.*?\]\([^)]*\)/g, ' ')
|
||||
.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
|
||||
.replace(/[#>*_`~]/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
|
||||
return plain.length > length ? `${plain.slice(0, length).trimEnd()}…` : plain;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export function slugify(text: string): string {
|
||||
return text
|
||||
.toLocaleLowerCase('tr-TR')
|
||||
.replace(/ğ/g, 'g')
|
||||
.replace(/ü/g, 'u')
|
||||
.replace(/ş/g, 's')
|
||||
.replace(/ı/g, 'i')
|
||||
.replace(/ö/g, 'o')
|
||||
.replace(/ç/g, 'c')
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/(^-|-$)/g, '');
|
||||
}
|
||||
Reference in New Issue
Block a user