Skip to content

Commit 39b0f51

Browse files
committed
2 parents 6a0b7f4 + 13a2344 commit 39b0f51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+12762
-23
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { c as createExports, a as start } from './chunks/_@astrojs-ssr-adapter_CSmuO3pl.mjs';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const server = {};
2+
3+
export { server };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const onRequest = (_, next) => next();
2+
3+
export { onRequest };
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { b as createAstro, c as createComponent, m as maybeRenderHead, e as addAttribute, r as renderComponent, s as spreadAttributes, a as renderTemplate } from './astro/server_DdaBn-83.mjs';
2+
import { s as slugifyStr } from './postFilter_CqXOWmtw.mjs';
3+
import { a as getPath } from './getSortedPosts_BvTFy216.mjs';
4+
import { c as calculateReadingTime, f as formatReadingTime, $ as $$Datetime } from './Datetime_DGlCk07k.mjs';
5+
6+
const $$Astro = createAstro("https://jeoste.github.io/");
7+
const $$Card = createComponent(($$result, $$props, $$slots) => {
8+
const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
9+
Astro2.self = $$Card;
10+
const { variant = "h2", data, id, filePath, body } = Astro2.props;
11+
const { title, description, pubDatetime, modDatetime, timezone } = data;
12+
const readingTimeMinutes = calculateReadingTime(body || "");
13+
const readingTimeText = formatReadingTime(readingTimeMinutes);
14+
const headerProps = {
15+
style: { viewTransitionName: slugifyStr(title) },
16+
class: "text-lg font-medium decoration-dashed hover:underline"
17+
};
18+
return renderTemplate`${maybeRenderHead()}<li class="my-6"> <a${addAttribute(getPath(id, filePath), "href")} class="inline-block text-lg font-medium text-accent decoration-dashed underline-offset-4 focus-visible:no-underline focus-visible:underline-offset-0"> ${variant === "h2" ? renderTemplate`<h2${spreadAttributes(headerProps)}>${title}</h2>` : renderTemplate`<h3${spreadAttributes(headerProps)}>${title}</h3>`} </a> <div class="flex items-end space-x-2 opacity-80 text-skin-base/70"> ${renderComponent($$result, "Datetime", $$Datetime, { "pubDatetime": pubDatetime, "modDatetime": modDatetime, "timezone": timezone })} <span class="mx-2 text-sm italic">•</span> <span class="text-sm italic">${readingTimeText}</span> </div> <p>${description}</p> </li>`;
19+
}, "C:/GitHubPro/jeoste.github.io/src/components/Card.astro", void 0);
20+
21+
export { $$Card as $ };
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { b as createAstro, c as createComponent, m as maybeRenderHead, e as addAttribute, r as renderComponent, F as Fragment, a as renderTemplate } from './astro/server_DdaBn-83.mjs';
2+
import 'kleur/colors';
3+
import dayjs from 'dayjs';
4+
import utc from 'dayjs/plugin/utc.js';
5+
import timezone from 'dayjs/plugin/timezone.js';
6+
import relativeTime from 'dayjs/plugin/relativeTime.js';
7+
import { S as SITE } from './config_JJhEf13K.mjs';
8+
9+
function calculateReadingTime(content, wordsPerMinute = 200) {
10+
const words = content.trim().split(/\s+/).length;
11+
const readingTime = Math.ceil(words / wordsPerMinute);
12+
return readingTime;
13+
}
14+
function formatReadingTime(minutes) {
15+
if (minutes === 1) {
16+
return "1 min read time";
17+
}
18+
return `${minutes} min read time`;
19+
}
20+
21+
dayjs.extend(relativeTime);
22+
function getRelativeTime(date) {
23+
const dayjsDate = dayjs(date);
24+
const now = dayjs();
25+
const diffInYears = now.diff(dayjsDate, "year");
26+
const diffInMonths = now.diff(dayjsDate, "month");
27+
const diffInWeeks = now.diff(dayjsDate, "week");
28+
const diffInDays = now.diff(dayjsDate, "day");
29+
const diffInHours = now.diff(dayjsDate, "hour");
30+
const diffInMinutes = now.diff(dayjsDate, "minute");
31+
const isFuture = diffInYears < 0 || diffInMonths < 0 || diffInWeeks < 0 || diffInDays < 0 || diffInHours < 0 || diffInMinutes < 0;
32+
const absYears = Math.abs(diffInYears);
33+
const absMonths = Math.abs(diffInMonths);
34+
const absWeeks = Math.abs(diffInWeeks);
35+
const absDays = Math.abs(diffInDays);
36+
const absHours = Math.abs(diffInHours);
37+
const absMinutes = Math.abs(diffInMinutes);
38+
if (absYears >= 1) {
39+
const timeText = absYears === 1 ? "a year" : `${absYears} years`;
40+
return isFuture ? `in ${timeText}` : `${timeText} ago`;
41+
} else if (absMonths >= 1) {
42+
const timeText = absMonths === 1 ? "a month" : `${absMonths} months`;
43+
return isFuture ? `in ${timeText}` : `${timeText} ago`;
44+
} else if (absWeeks >= 1) {
45+
const timeText = absWeeks === 1 ? "a week" : `${absWeeks} weeks`;
46+
return isFuture ? `in ${timeText}` : `${timeText} ago`;
47+
} else if (absDays >= 1) {
48+
if (absDays === 1) {
49+
return isFuture ? "tomorrow" : "yesterday";
50+
} else {
51+
const timeText = `${absDays} days`;
52+
return isFuture ? `in ${timeText}` : `${timeText} ago`;
53+
}
54+
} else if (absHours >= 1) {
55+
const timeText = absHours === 1 ? "an hour" : `${absHours} hours`;
56+
return isFuture ? `in ${timeText}` : `${timeText} ago`;
57+
} else if (absMinutes >= 1) {
58+
const timeText = absMinutes === 1 ? "a minute" : `${absMinutes} minutes`;
59+
return isFuture ? `in ${timeText}` : `${timeText} ago`;
60+
} else {
61+
return isFuture ? "in a few seconds" : "a few seconds ago";
62+
}
63+
}
64+
65+
const $$Astro = createAstro("https://jeoste.github.io/");
66+
const $$Datetime = createComponent(($$result, $$props, $$slots) => {
67+
const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
68+
Astro2.self = $$Datetime;
69+
dayjs.extend(utc);
70+
dayjs.extend(timezone);
71+
dayjs.extend(relativeTime);
72+
const {
73+
pubDatetime,
74+
modDatetime,
75+
size = "sm",
76+
class: className = "",
77+
timezone: postTimezone,
78+
showRelative = true
79+
} = Astro2.props;
80+
const pubDate = dayjs(pubDatetime).tz(postTimezone || SITE.timezone);
81+
const modDate = modDatetime ? dayjs(modDatetime).tz(postTimezone || SITE.timezone) : null;
82+
const formatDate = (date) => date.format("D MMM, YYYY");
83+
const formatTime = (date) => date.format("hh:mm A");
84+
const pubRelativeDate = getRelativeTime(pubDatetime);
85+
const modRelativeDate = modDatetime ? getRelativeTime(modDatetime) : null;
86+
const shouldShowRelative = showRelative;
87+
const displayPubDate = shouldShowRelative ? pubRelativeDate : formatDate(pubDate);
88+
const displayModDate = modDatetime && shouldShowRelative ? modRelativeDate : modDatetime ? formatDate(modDate) : null;
89+
return renderTemplate`${maybeRenderHead()}<div${addAttribute(["flex items-end space-x-2 opacity-80", className], "class:list")}> <span${addAttribute(["text-sm italic", { "sm:text-base": size === "lg" }], "class:list")}> <span>Publication date:${" "}</span> <time${addAttribute(pubDate.toISOString(), "datetime")}${addAttribute(`${formatDate(pubDate)} | ${formatTime(pubDate)}`, "title")}> ${displayPubDate} </time> ${!shouldShowRelative && renderTemplate`${renderComponent($$result, "Fragment", Fragment, {}, { "default": ($$result2) => renderTemplate` <span aria-hidden="true"> | </span> <span class="sr-only">&nbsp;at&nbsp;</span> <span class="text-nowrap">${formatTime(pubDate)}</span> ` })}`} ${modDatetime && modDate && renderTemplate`${renderComponent($$result, "Fragment", Fragment, {}, { "default": ($$result2) => renderTemplate` <span class="mx-2">•</span> <span>Last update:${" "}</span> <time${addAttribute(modDate.toISOString(), "datetime")}${addAttribute(`${formatDate(modDate)} | ${formatTime(modDate)}`, "title")}> ${displayModDate} </time> ${!shouldShowRelative && renderTemplate`${renderComponent($$result2, "Fragment", Fragment, {}, { "default": ($$result3) => renderTemplate` <span aria-hidden="true"> | </span> <span class="sr-only">&nbsp;at&nbsp;</span> <span class="text-nowrap">${formatTime(modDate)}</span> ` })}`}` })}`} </span> </div>`;
90+
}, "C:/GitHubPro/jeoste.github.io/src/components/Datetime.astro", void 0);
91+
92+
export { $$Datetime as $, calculateReadingTime as c, formatReadingTime as f };

0 commit comments

Comments
 (0)