FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
OpenMark-Blog/src/lib/utils.ts at main · softpython2884/OpenMark-Blog · GitHub
softpython2884
/
OpenMark-Blog
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
OpenMark-Blog
/
src
/
lib
/
utils.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
20 lines (16 loc) · 665 Bytes
Breadcrumbs
OpenMark-Blog
/
src
/
lib
/
utils.ts
Copy path
File metadata and controls
20 lines (16 loc) · 665 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import
{
clsx
,
type
ClassValue
}
from
"clsx"
import
{
twMerge
}
from
"tailwind-merge"
export
function
cn
(
...
inputs
:
ClassValue
[
]
)
{
return
twMerge
(
clsx
(
inputs
)
)
}
export
function
calculateReadingTime
(
htmlContent
:
string
)
:
number
{
if
(
!
htmlContent
)
return
0
;
// Strip HTML tags to get plain text
const
text
=
htmlContent
.
replace
(
/
<
[
^
>
]
+
>
/
g
,
''
)
;
// Split by whitespace and filter out empty strings
const
wordCount
=
text
.
split
(
/
\s
+
/
)
.
filter
(
Boolean
)
.
length
;
// Average reading speed is around 200 words per minute.
const
rawReadingTime
=
wordCount
/
200
;
// Round to the nearest quarter minute
return
Math
.
round
(
rawReadingTime
*
4
)
/
4
;
}
Back
|
FazBrowse Home
|
New Git URL