Skip to content

Commit

Permalink
Add estimated reading time feature and improve styling
Browse files Browse the repository at this point in the history
  • Loading branch information
angristan committed Jan 18, 2025
1 parent cddddb6 commit 178647f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Larafeed is a simple feed reader.
- Support is partial, but works with [Reeder classic](https://reederapp.com/classic/) at least
- Google Reader API is available at `/api/reader` and Fever API at `/api/fever`, both with username+password
- Telegram notications on user registration and login failures
- Estimated reading time for each entry

### Screenshots

Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@
"recharts": "^2.15.0",
"typescript": "^5.0.2",
"vite": "^6.0"
},
"dependencies": {
"reading-time-estimator": "^1.11.0"
}
}
1 change: 1 addition & 0 deletions resources/js/Pages/Reader/CurrentEntryPane.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

.entry h1 {
margin: 0 !important;
margin-bottom: 1rem !important;
}

.entryContent {
Expand Down
14 changes: 10 additions & 4 deletions resources/js/Pages/Reader/CurrentEntryPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import utc from 'dayjs/plugin/utc';
import { useEffect, useRef, useState } from 'react';
import { readingTime } from 'reading-time-estimator';

dayjs.extend(relativeTime);
dayjs.extend(utc);
Expand Down Expand Up @@ -351,11 +352,16 @@ export default function CurrentEntryPane({
</Title>
<Flex justify={'space-between'}>
<Text size="sm" c="dimmed">
{currententry.author}
</Text>
<Text size="sm" c="dimmed">
{dayjs.utc(currententry.published_at).fromNow()}
{readingTime(currententry.content ?? '').text}
</Text>
<Flex>
<Text size="sm" c="dimmed">
{currententry.author} {' - '}{' '}
{dayjs
.utc(currententry.published_at)
.fromNow()}
</Text>
</Flex>
</Flex>
{value === 'content' ? (
<div
Expand Down

0 comments on commit 178647f

Please sign in to comment.