Skip to content

Commit

Permalink
read time and nav hover
Browse files Browse the repository at this point in the history
  • Loading branch information
Reed Nelson committed Aug 11, 2023
1 parent a1bbb2b commit 34857c1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/layouts/BlogSingle.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import similerItems from "@/lib/utils/similarItems";
import { humanize, markdownify, slugify } from "@/lib/utils/textConverter";
import { Image } from "@astrojs/image/components";
import {
FaRegClock,
FaRegCalendarAlt,
FaRegFolder,
FaRegUserCircle,
} from "react-icons/fa/index.js";
Expand Down Expand Up @@ -46,7 +46,7 @@ const { title, description, author, categories, image, date, tags } = post.data;
{humanize(author)}
</li>
<li class="mr-4 inline-block">
<FaRegClock className={"mr-2 -mt-1 inline-block"} />
<FaRegCalendarAlt className={"mr-2 -mt-1 inline-block"} />
{dateFormat(date)}
</li>
<li class="mr-4 inline-block">
Expand Down
13 changes: 9 additions & 4 deletions src/layouts/components/BlogCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import config from "@/config/config.json";
import { humanize, plainify, slugify } from "@/lib/utils/textConverter";
import { Image } from "@astrojs/image/components";
import { FaRegFolder, FaRegUserCircle } from "react-icons/fa/index.js";
import { FaRegFolder, FaRegClock } from "react-icons/fa/index.js";
import readingTime from "@/lib/utils/readingTime";
const {
summary_length,
Expand Down Expand Up @@ -31,12 +32,12 @@ const { title, image, description, author, categories } = data.data;
</a>
</h4>
<ul class="mb-4">
<li class="mr-4 inline-block">
<!-- <li class="mr-4 inline-block">
<FaRegUserCircle className={"mr-2 -mt-1 inline-block"} />
{humanize(author)}
</li>
</li> -->
<li class="mr-4 inline-block">
<FaRegFolder className={"mr-2 -mt-1 inline-block"} />
<FaRegFolder className={"mr-1 -mt-1 inline-block"} />
{
categories.map((category: string, index: number) => (
<a href={`/blog/categories/${slugify(category)}`}>
Expand All @@ -46,6 +47,10 @@ const { title, image, description, author, categories } = data.data;
))
}
</li>
<li class="mr-4 inline-block ">
<FaRegClock className={"mr-1 -mt-1 inline-block"} />
{readingTime(data.body)}
</li>
</ul>
<!-- <p class="mb-6">{plainify(data.body?.slice(0, Number(summary_length)))}</p> -->
<p class="mb-6">{description}</p>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/ThemeSwitcher.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { className }: { className?: string } = Astro.props;

{
theme_switcher && (
<div class={`theme-switcher ${className}`}>
<div class={`theme-switcher a ${className}`}>
<input id="theme-switcher" data-theme-switcher type="checkbox" />
<label for="theme-switcher">
<span class="sr-only">theme switcher</span>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/partials/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const { pathname } = Astro.url;
{
settings.search && (
<a
class="mr-5 inline-block border-r border-border pr-5 text-xl text-dark hover:text-primary dark:border-darkmode-border dark:text-white"
class="mr-5 inline-block border-border text-xl text-dark hover:text-primary dark:border-darkmode-border dark:text-white"
href="/search"
aria-label="search"
>
Expand Down
12 changes: 4 additions & 8 deletions src/lib/utils/readingTime.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// content reading
const readingTime = (content: string): string => {
const WPS = 275 / 60;
const WPS = 200 / 60;

let images = 0;
const regex = /\w/;
Expand All @@ -26,14 +26,10 @@ const readingTime = (content: string): string => {

const minutes = Math.ceil(((words - imageAdjust) / WPS + imageSecs) / 60);

if (minutes < 10) {
if (minutes < 2) {
return "0" + minutes + ` Min read`;
} else {
return "0" + minutes + ` Mins read`;
}
if (minutes < 2) {
return minutes + ` min`;
} else {
return minutes + ` Mins read`;
return minutes + ` mins`;
}
};

Expand Down
4 changes: 4 additions & 0 deletions src/styles/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ a:hover {
@apply scale-105;
@apply opacity-60;
}

.a:hover {
@apply opacity-60;
}

0 comments on commit 34857c1

Please sign in to comment.