@k34a/blog 0.0.18 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,166 +1,26 @@
1
1
  "use client";
2
- import { jsx as u, jsxs as y } from "react/jsx-runtime";
3
- import { Box as S, Stack as M, Title as R, Text as D, Flex as P, Badge as B } from "@mantine/core";
4
- import { IconHash as $ } from "@tabler/icons-react";
5
- import { BannerImage as q } from "./banner-image.js";
6
- import A from "./description.js";
7
- function C(e) {
8
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
9
- }
2
+ import { jsx as t, jsxs as c } from "react/jsx-runtime";
3
+ import { Box as o, Stack as g, Title as f, Text as s, Flex as h, Badge as u } from "@mantine/core";
4
+ import { IconHash as x } from "@tabler/icons-react";
5
+ import { BannerImage as D } from "./banner-image.js";
6
+ import w from "./description.js";
7
+ import { calculateReadingTime as y } from "../utils.js";
10
8
  function I(e) {
11
- if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
12
- var o = e.default;
13
- if (typeof o == "function") {
14
- var a = function r() {
15
- var n = !1;
16
- try {
17
- n = this instanceof r;
18
- } catch {
19
- }
20
- return n ? Reflect.construct(o, arguments, this.constructor) : o.apply(this, arguments);
21
- };
22
- a.prototype = o.prototype;
23
- } else a = {};
24
- return Object.defineProperty(a, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
25
- var n = Object.getOwnPropertyDescriptor(e, r);
26
- Object.defineProperty(a, r, n.get ? n : {
27
- enumerable: !0,
28
- get: function() {
29
- return e[r];
30
- }
31
- });
32
- }), a;
33
- }
34
- var l = { exports: {} };
35
- /*!
36
- * reading-time
37
- * Copyright (c) Nicolas Gryman <ngryman@gmail.com>
38
- * MIT Licensed
39
- */
40
- var x, w;
41
- function v() {
42
- if (w) return x;
43
- w = 1;
44
- function e(t, s) {
45
- return s.some(
46
- ([i, f]) => i <= t && t <= f
47
- );
48
- }
49
- function o(t) {
50
- if (typeof t != "string")
51
- return !1;
52
- const s = t.charCodeAt(0);
53
- return e(
54
- s,
55
- [
56
- // Hiragana (Katakana not included on purpose,
57
- // context: https://github.com/ngryman/reading-time/pull/35#issuecomment-853364526)
58
- // If you think Katakana should be included and have solid reasons, improvement is welcomed
59
- [12352, 12447],
60
- // CJK Unified ideographs
61
- [19968, 40959],
62
- // Hangul
63
- [44032, 55203],
64
- // CJK extensions
65
- [131072, 191456]
66
- ]
67
- );
68
- }
69
- function a(t) {
70
- return `
71
- \r `.includes(t);
72
- }
73
- function r(t) {
74
- if (typeof t != "string")
75
- return !1;
76
- const s = t.charCodeAt(0);
77
- return e(
78
- s,
79
- [
80
- [33, 47],
81
- [58, 64],
82
- [91, 96],
83
- [123, 126],
84
- // CJK Symbols and Punctuation
85
- [12288, 12351],
86
- // Full-width ASCII punctuation variants
87
- [65280, 65519]
88
- ]
89
- );
90
- }
91
- function n(t, s = {}) {
92
- let i = 0, f = 0, h = t.length - 1;
93
- const j = s.wordsPerMinute || 200, m = s.wordBound || a;
94
- for (; m(t[f]); ) f++;
95
- for (; m(t[h]); ) h--;
96
- const d = `${t}
97
- `;
98
- for (let c = f; c <= h; c++)
99
- if ((o(d[c]) || !m(d[c]) && (m(d[c + 1]) || o(d[c + 1]))) && i++, o(d[c]))
100
- for (; c <= h && (r(d[c + 1]) || m(d[c + 1])); )
101
- c++;
102
- const g = i / j, O = Math.round(g * 60 * 1e3);
103
- return {
104
- text: Math.ceil(g.toFixed(2)) + " min read",
105
- minutes: g,
106
- time: O,
107
- words: i
108
- };
109
- }
110
- return x = n, x;
111
- }
112
- const z = {}, E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
113
- __proto__: null,
114
- default: z
115
- }, Symbol.toStringTag, { value: "Module" })), T = /* @__PURE__ */ I(E);
116
- /*!
117
- * reading-time
118
- * Copyright (c) Nicolas Gryman <ngryman@gmail.com>
119
- * MIT Licensed
120
- */
121
- var p, _;
122
- function F() {
123
- if (_) return p;
124
- _ = 1;
125
- const e = v(), o = T.Transform, a = T;
126
- function r(n) {
127
- if (!(this instanceof r))
128
- return new r(n);
129
- o.call(this, { objectMode: !0 }), this.options = n || {}, this.stats = {
130
- minutes: 0,
131
- time: 0,
132
- words: 0
133
- };
134
- }
135
- return a.inherits(r, o), r.prototype._transform = function(n, t, s) {
136
- const i = e(n.toString(t), this.options);
137
- this.stats.minutes += i.minutes, this.stats.time += i.time, this.stats.words += i.words, s();
138
- }, r.prototype._flush = function(n) {
139
- this.stats.text = Math.ceil(this.stats.minutes.toFixed(2)) + " min read", this.push(this.stats), n();
140
- }, p = r, p;
141
- }
142
- var b;
143
- function U() {
144
- return b || (b = 1, l.exports.default = l.exports = v(), l.exports.readingTimeStream = F()), l.exports;
145
- }
146
- var W = U();
147
- const k = /* @__PURE__ */ C(W);
148
- function Q(e) {
149
- const o = new Date(e.created_at), a = new Date(e.updated_at), r = (i) => i.toLocaleDateString("en-US", {
9
+ const a = new Date(e.created_at), r = new Date(e.updated_at), n = (i) => i.toLocaleDateString("en-US", {
150
10
  year: "numeric",
151
11
  month: "long",
152
12
  day: "numeric"
153
- }), n = e.description.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim(), t = k(n), s = a.getTime() !== o.getTime();
154
- return /* @__PURE__ */ u(S, { maw: 800, mx: "auto", px: "sm", py: "lg", children: /* @__PURE__ */ y(M, { gap: "md", children: [
155
- /* @__PURE__ */ u(R, { order: 1, children: e.title }),
156
- /* @__PURE__ */ y(D, { size: "sm", c: "dimmed", children: [
157
- t.text,
13
+ }), m = e.description.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim(), d = y(m), l = n(r) !== n(a);
14
+ return /* @__PURE__ */ t(o, { maw: 800, mx: "auto", px: "sm", py: "lg", children: /* @__PURE__ */ c(g, { gap: "md", children: [
15
+ /* @__PURE__ */ t(f, { order: 1, children: e.title }),
16
+ /* @__PURE__ */ c(s, { size: "sm", c: "dimmed", children: [
17
+ d.text,
158
18
  " · Written on ",
159
- r(o),
160
- s && ` · Updated on ${r(a)}`
19
+ n(a),
20
+ l && ` · Updated on ${n(r)}`
161
21
  ] }),
162
- e.banner_image && /* @__PURE__ */ u(
163
- q,
22
+ e.banner_image && /* @__PURE__ */ t(
23
+ D,
164
24
  {
165
25
  id: e.id,
166
26
  src: e.banner_image,
@@ -168,21 +28,21 @@ function Q(e) {
168
28
  config: e.config
169
29
  }
170
30
  ),
171
- /* @__PURE__ */ u(
172
- A,
31
+ /* @__PURE__ */ t(
32
+ w,
173
33
  {
174
34
  articleId: e.id,
175
35
  html: e.description,
176
36
  config: e.config
177
37
  }
178
38
  ),
179
- /* @__PURE__ */ u(P, { wrap: "wrap", gap: "md", align: "center", mb: "lg", children: e.tags.map((i) => /* @__PURE__ */ u("a", { href: i.href, children: /* @__PURE__ */ u(
180
- B,
39
+ /* @__PURE__ */ t(h, { wrap: "wrap", gap: "md", align: "center", mb: "lg", children: e.tags.map((i) => /* @__PURE__ */ t("a", { href: i.href, children: /* @__PURE__ */ t(
40
+ u,
181
41
  {
182
42
  size: "md",
183
43
  color: "sky.5",
184
44
  variant: "outline",
185
- leftSection: /* @__PURE__ */ u($, { size: 14 }),
45
+ leftSection: /* @__PURE__ */ t(x, { size: 14 }),
186
46
  style: { cursor: "pointer" },
187
47
  children: i.name
188
48
  }
@@ -190,5 +50,5 @@ function Q(e) {
190
50
  ] }) });
191
51
  }
192
52
  export {
193
- Q as default
53
+ I as default
194
54
  };
@@ -1,2 +1,7 @@
1
1
  export declare function applyImageFullPaths(html: string, getImageFullPath: (src: string) => string): string;
2
2
  export declare function resolveImageForArticle(hostname: string, id: string, imageName: string): string;
3
+ export declare function calculateReadingTime(text: string): {
4
+ minutes: number;
5
+ text: string;
6
+ words: number;
7
+ };
@@ -77,7 +77,7 @@ var g;
77
77
  (function(e) {
78
78
  e[e.Legacy = 0] = "Legacy", e[e.Strict = 1] = "Strict", e[e.Attribute = 2] = "Attribute";
79
79
  })(g || (g = {}));
80
- class du {
80
+ class nu {
81
81
  constructor(u, t, a) {
82
82
  this.decodeTree = u, this.emitCodePoint = t, this.errors = a, this.state = h.EntityStart, this.consumed = 1, this.result = 0, this.treeIndex = 0, this.excess = 1, this.decodeMode = g.Strict;
83
83
  }
@@ -204,14 +204,14 @@ class du {
204
204
  const { decodeTree: a } = this;
205
205
  let i = a[this.treeIndex], s = (i & w.VALUE_LENGTH) >> 14;
206
206
  for (; t < u.length; t++, this.excess++) {
207
- const d = u.charCodeAt(t);
208
- if (this.treeIndex = nu(a, i, this.treeIndex + Math.max(1, s), d), this.treeIndex < 0)
207
+ const n = u.charCodeAt(t);
208
+ if (this.treeIndex = du(a, i, this.treeIndex + Math.max(1, s), n), this.treeIndex < 0)
209
209
  return this.result === 0 || // If we are parsing an attribute
210
210
  this.decodeMode === g.Attribute && // We shouldn't have consumed any characters after the entity,
211
211
  (s === 0 || // And there should be no invalid characters.
212
- ru(d)) ? 0 : this.emitNotTerminatedNamedEntity();
212
+ ru(n)) ? 0 : this.emitNotTerminatedNamedEntity();
213
213
  if (i = a[this.treeIndex], s = (i & w.VALUE_LENGTH) >> 14, s !== 0) {
214
- if (d === x.SEMI)
214
+ if (n === x.SEMI)
215
215
  return this.emitNamedEntityData(this.treeIndex, s, this.consumed + this.excess);
216
216
  this.decodeMode !== g.Strict && (this.result = this.treeIndex, this.consumed += this.excess, this.excess = 0);
217
217
  }
@@ -265,7 +265,7 @@ class du {
265
265
  }
266
266
  }
267
267
  }
268
- function nu(e, u, t, a) {
268
+ function du(e, u, t, a) {
269
269
  const i = (u & w.BRANCH_LENGTH) >> 7, s = u & w.JUMP_TABLE;
270
270
  if (i === 0)
271
271
  return s !== 0 && a === s ? t : -1;
@@ -273,11 +273,11 @@ function nu(e, u, t, a) {
273
273
  const l = a - s;
274
274
  return l < 0 || l >= i ? -1 : e[t + l] - 1;
275
275
  }
276
- let d = t, b = d + i - 1;
277
- for (; d <= b; ) {
278
- const l = d + b >>> 1, S = e[l];
276
+ let n = t, b = n + i - 1;
277
+ for (; n <= b; ) {
278
+ const l = n + b >>> 1, S = e[l];
279
279
  if (S < a)
280
- d = l + 1;
280
+ n = l + 1;
281
281
  else if (S > a)
282
282
  b = l - 1;
283
283
  else
@@ -337,7 +337,7 @@ const o = {
337
337
  };
338
338
  class bu {
339
339
  constructor({ xmlMode: u = !1, decodeEntities: t = !0 }, a) {
340
- this.cbs = a, this.state = c.Text, this.buffer = "", this.sectionStart = 0, this.index = 0, this.entityStart = 0, this.baseState = c.Text, this.isSpecial = !1, this.running = !0, this.offset = 0, this.currentSequence = void 0, this.sequenceIndex = 0, this.xmlMode = u, this.decodeEntities = t, this.entityDecoder = new du(u ? eu : uu, (i, s) => this.emitCodePoint(i, s));
340
+ this.cbs = a, this.state = c.Text, this.buffer = "", this.sectionStart = 0, this.index = 0, this.entityStart = 0, this.baseState = c.Text, this.isSpecial = !1, this.running = !0, this.offset = 0, this.currentSequence = void 0, this.sequenceIndex = 0, this.xmlMode = u, this.decodeEntities = t, this.entityDecoder = new nu(u ? eu : uu, (i, s) => this.emitCodePoint(i, s));
341
341
  }
342
342
  reset() {
343
343
  this.state = c.Text, this.buffer = "", this.sectionStart = 0, this.index = 0, this.baseState = c.Text, this.currentSequence = void 0, this.running = !0, this.offset = 0;
@@ -748,8 +748,8 @@ const E = /* @__PURE__ */ new Set([
748
748
  ]), hu = /\s|\//;
749
749
  class xu {
750
750
  constructor(u, t = {}) {
751
- var a, i, s, d, b, l;
752
- this.options = t, this.startIndex = 0, this.endIndex = 0, this.openTagStart = 0, this.tagname = "", this.attribname = "", this.attribvalue = "", this.attribs = null, this.stack = [], this.buffers = [], this.bufferOffset = 0, this.writeIndex = 0, this.ended = !1, this.cbs = u ?? {}, this.htmlMode = !this.options.xmlMode, this.lowerCaseTagNames = (a = t.lowerCaseTags) !== null && a !== void 0 ? a : this.htmlMode, this.lowerCaseAttributeNames = (i = t.lowerCaseAttributeNames) !== null && i !== void 0 ? i : this.htmlMode, this.recognizeSelfClosing = (s = t.recognizeSelfClosing) !== null && s !== void 0 ? s : !this.htmlMode, this.tokenizer = new ((d = t.Tokenizer) !== null && d !== void 0 ? d : bu)(this.options, this), this.foreignContext = [!this.htmlMode], (l = (b = this.cbs).onparserinit) === null || l === void 0 || l.call(b, this);
751
+ var a, i, s, n, b, l;
752
+ this.options = t, this.startIndex = 0, this.endIndex = 0, this.openTagStart = 0, this.tagname = "", this.attribname = "", this.attribvalue = "", this.attribs = null, this.stack = [], this.buffers = [], this.bufferOffset = 0, this.writeIndex = 0, this.ended = !1, this.cbs = u ?? {}, this.htmlMode = !this.options.xmlMode, this.lowerCaseTagNames = (a = t.lowerCaseTags) !== null && a !== void 0 ? a : this.htmlMode, this.lowerCaseAttributeNames = (i = t.lowerCaseAttributeNames) !== null && i !== void 0 ? i : this.htmlMode, this.recognizeSelfClosing = (s = t.recognizeSelfClosing) !== null && s !== void 0 ? s : !this.htmlMode, this.tokenizer = new ((n = t.Tokenizer) !== null && n !== void 0 ? n : bu)(this.options, this), this.foreignContext = [!this.htmlMode], (l = (b = this.cbs).onparserinit) === null || l === void 0 || l.call(b, this);
753
753
  }
754
754
  // Tokenizer event handlers
755
755
  /** @internal */
@@ -779,9 +779,9 @@ class xu {
779
779
  emitOpenTag(u) {
780
780
  var t, a, i, s;
781
781
  this.openTagStart = this.startIndex, this.tagname = u;
782
- const d = this.htmlMode && ou.get(u);
783
- if (d)
784
- for (; this.stack.length > 0 && d.has(this.stack[0]); ) {
782
+ const n = this.htmlMode && ou.get(u);
783
+ if (n)
784
+ for (; this.stack.length > 0 && n.has(this.stack[0]); ) {
785
785
  const b = this.stack.shift();
786
786
  (a = (t = this.cbs).onclosetag) === null || a === void 0 || a.call(t, b, !0);
787
787
  }
@@ -797,11 +797,11 @@ class xu {
797
797
  }
798
798
  /** @internal */
799
799
  onclosetag(u, t) {
800
- var a, i, s, d, b, l, S, I;
800
+ var a, i, s, n, b, l, S, I;
801
801
  this.endIndex = t;
802
802
  let m = this.getSlice(u, t);
803
803
  if (this.lowerCaseTagNames && (m = m.toLowerCase()), this.htmlMode && (C.has(m) || G.has(m)) && this.foreignContext.shift(), this.isVoidElement(m))
804
- this.htmlMode && m === "br" && ((d = (s = this.cbs).onopentagname) === null || d === void 0 || d.call(s, "br"), (l = (b = this.cbs).onopentag) === null || l === void 0 || l.call(b, "br", {}, !0), (I = (S = this.cbs).onclosetag) === null || I === void 0 || I.call(S, "br", !1));
804
+ this.htmlMode && m === "br" && ((n = (s = this.cbs).onopentagname) === null || n === void 0 || n.call(s, "br"), (l = (b = this.cbs).onopentag) === null || l === void 0 || l.call(b, "br", {}, !0), (I = (S = this.cbs).onclosetag) === null || I === void 0 || I.call(S, "br", !1));
805
805
  else {
806
806
  const T = this.stack.indexOf(m);
807
807
  if (T !== -1)
@@ -868,15 +868,15 @@ class xu {
868
868
  }
869
869
  /** @internal */
870
870
  oncomment(u, t, a) {
871
- var i, s, d, b;
872
- this.endIndex = t, (s = (i = this.cbs).oncomment) === null || s === void 0 || s.call(i, this.getSlice(u, t - a)), (b = (d = this.cbs).oncommentend) === null || b === void 0 || b.call(d), this.startIndex = t + 1;
871
+ var i, s, n, b;
872
+ this.endIndex = t, (s = (i = this.cbs).oncomment) === null || s === void 0 || s.call(i, this.getSlice(u, t - a)), (b = (n = this.cbs).oncommentend) === null || b === void 0 || b.call(n), this.startIndex = t + 1;
873
873
  }
874
874
  /** @internal */
875
875
  oncdata(u, t, a) {
876
- var i, s, d, b, l, S, I, m, T, y;
876
+ var i, s, n, b, l, S, I, m, T, y;
877
877
  this.endIndex = t;
878
878
  const N = this.getSlice(u, t - a);
879
- !this.htmlMode || this.options.recognizeCDATA ? ((s = (i = this.cbs).oncdatastart) === null || s === void 0 || s.call(i), (b = (d = this.cbs).ontext) === null || b === void 0 || b.call(d, N), (S = (l = this.cbs).oncdataend) === null || S === void 0 || S.call(l)) : ((m = (I = this.cbs).oncomment) === null || m === void 0 || m.call(I, `[CDATA[${N}]]`), (y = (T = this.cbs).oncommentend) === null || y === void 0 || y.call(T)), this.startIndex = t + 1;
879
+ !this.htmlMode || this.options.recognizeCDATA ? ((s = (i = this.cbs).oncdatastart) === null || s === void 0 || s.call(i), (b = (n = this.cbs).ontext) === null || b === void 0 || b.call(n, N), (S = (l = this.cbs).oncdataend) === null || S === void 0 || S.call(l)) : ((m = (I = this.cbs).oncomment) === null || m === void 0 || m.call(I, `[CDATA[${N}]]`), (y = (T = this.cbs).oncommentend) === null || y === void 0 || y.call(T)), this.startIndex = t + 1;
880
880
  }
881
881
  /** @internal */
882
882
  onend() {
@@ -974,14 +974,14 @@ class xu {
974
974
  this.end(u);
975
975
  }
976
976
  }
977
- var n;
977
+ var d;
978
978
  (function(e) {
979
979
  e.Root = "root", e.Text = "text", e.Directive = "directive", e.Comment = "comment", e.Script = "script", e.Style = "style", e.Tag = "tag", e.CDATA = "cdata", e.Doctype = "doctype";
980
- })(n || (n = {}));
980
+ })(d || (d = {}));
981
981
  function mu(e) {
982
- return e.type === n.Tag || e.type === n.Script || e.type === n.Style;
982
+ return e.type === d.Tag || e.type === d.Script || e.type === d.Style;
983
983
  }
984
- const gu = n.Root, pu = n.Text, Su = n.Directive, Au = n.Comment, wu = n.Script, yu = n.Style, Iu = n.Tag, Tu = n.CDATA, Eu = n.Doctype;
984
+ const gu = d.Root, pu = d.Text, Su = d.Directive, Au = d.Comment, wu = d.Script, yu = d.Style, Iu = d.Tag, Tu = d.CDATA, Eu = d.Doctype;
985
985
  class z {
986
986
  constructor() {
987
987
  this.parent = null, this.prev = null, this.next = null, this.startIndex = null, this.endIndex = null;
@@ -1047,7 +1047,7 @@ class _ extends z {
1047
1047
  }
1048
1048
  class L extends _ {
1049
1049
  constructor() {
1050
- super(...arguments), this.type = n.Text;
1050
+ super(...arguments), this.type = d.Text;
1051
1051
  }
1052
1052
  get nodeType() {
1053
1053
  return 3;
@@ -1055,7 +1055,7 @@ class L extends _ {
1055
1055
  }
1056
1056
  class j extends _ {
1057
1057
  constructor() {
1058
- super(...arguments), this.type = n.Comment;
1058
+ super(...arguments), this.type = d.Comment;
1059
1059
  }
1060
1060
  get nodeType() {
1061
1061
  return 8;
@@ -1063,13 +1063,13 @@ class j extends _ {
1063
1063
  }
1064
1064
  class Q extends _ {
1065
1065
  constructor(u, t) {
1066
- super(t), this.name = u, this.type = n.Directive;
1066
+ super(t), this.name = u, this.type = d.Directive;
1067
1067
  }
1068
1068
  get nodeType() {
1069
1069
  return 1;
1070
1070
  }
1071
1071
  }
1072
- class R extends z {
1072
+ class M extends z {
1073
1073
  /**
1074
1074
  * @param children Children of the node. Only certain node types can have children.
1075
1075
  */
@@ -1097,29 +1097,29 @@ class R extends z {
1097
1097
  this.children = u;
1098
1098
  }
1099
1099
  }
1100
- class W extends R {
1100
+ class W extends M {
1101
1101
  constructor() {
1102
- super(...arguments), this.type = n.CDATA;
1102
+ super(...arguments), this.type = d.CDATA;
1103
1103
  }
1104
1104
  get nodeType() {
1105
1105
  return 4;
1106
1106
  }
1107
1107
  }
1108
- class B extends R {
1108
+ class B extends M {
1109
1109
  constructor() {
1110
- super(...arguments), this.type = n.Root;
1110
+ super(...arguments), this.type = d.Root;
1111
1111
  }
1112
1112
  get nodeType() {
1113
1113
  return 9;
1114
1114
  }
1115
1115
  }
1116
- class Z extends R {
1116
+ class Z extends M {
1117
1117
  /**
1118
1118
  * @param name Name of the tag, eg. `div`, `span`.
1119
1119
  * @param attribs Object mapping attribute names to attribute values.
1120
1120
  * @param children Children of the node.
1121
1121
  */
1122
- constructor(u, t, a = [], i = u === "script" ? n.Script : u === "style" ? n.Style : n.Tag) {
1122
+ constructor(u, t, a = [], i = u === "script" ? d.Script : u === "style" ? d.Style : d.Tag) {
1123
1123
  super(a), this.name = u, this.attribs = t, this.type = i;
1124
1124
  }
1125
1125
  get nodeType() {
@@ -1152,19 +1152,19 @@ function X(e) {
1152
1152
  return mu(e);
1153
1153
  }
1154
1154
  function Nu(e) {
1155
- return e.type === n.CDATA;
1155
+ return e.type === d.CDATA;
1156
1156
  }
1157
1157
  function vu(e) {
1158
- return e.type === n.Text;
1158
+ return e.type === d.Text;
1159
1159
  }
1160
1160
  function qu(e) {
1161
- return e.type === n.Comment;
1161
+ return e.type === d.Comment;
1162
1162
  }
1163
1163
  function ku(e) {
1164
- return e.type === n.Directive;
1164
+ return e.type === d.Directive;
1165
1165
  }
1166
1166
  function Du(e) {
1167
- return e.type === n.Root;
1167
+ return e.type === d.Root;
1168
1168
  }
1169
1169
  function Lu(e) {
1170
1170
  return Object.prototype.hasOwnProperty.call(e, "children");
@@ -1231,12 +1231,12 @@ class Bu {
1231
1231
  this.options.withEndIndices && (u.endIndex = this.parser.endIndex), this.elementCB && this.elementCB(u);
1232
1232
  }
1233
1233
  onopentag(u, t) {
1234
- const a = this.options.xmlMode ? n.Tag : void 0, i = new Z(u, t, void 0, a);
1234
+ const a = this.options.xmlMode ? d.Tag : void 0, i = new Z(u, t, void 0, a);
1235
1235
  this.addNode(i), this.tagStack.push(i);
1236
1236
  }
1237
1237
  ontext(u) {
1238
1238
  const { lastNode: t } = this;
1239
- if (t && t.type === n.Text)
1239
+ if (t && t.type === d.Text)
1240
1240
  t.data += u, this.options.withEndIndices && (t.endIndex = this.parser.endIndex);
1241
1241
  else {
1242
1242
  const a = new L(u);
@@ -1244,7 +1244,7 @@ class Bu {
1244
1244
  }
1245
1245
  }
1246
1246
  oncomment(u) {
1247
- if (this.lastNode && this.lastNode.type === n.Comment) {
1247
+ if (this.lastNode && this.lastNode.type === d.Comment) {
1248
1248
  this.lastNode.data += u;
1249
1249
  return;
1250
1250
  }
@@ -1282,7 +1282,7 @@ const H = /["&'<>$\x80-\uFFFF]/g, _u = /* @__PURE__ */ new Map([
1282
1282
  [39, "&apos;"],
1283
1283
  [60, "&lt;"],
1284
1284
  [62, "&gt;"]
1285
- ]), Ru = (
1285
+ ]), Mu = (
1286
1286
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1287
1287
  String.prototype.codePointAt != null ? (e, u) => e.codePointAt(u) : (
1288
1288
  // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
@@ -1292,20 +1292,20 @@ const H = /["&'<>$\x80-\uFFFF]/g, _u = /* @__PURE__ */ new Map([
1292
1292
  function Y(e) {
1293
1293
  let u = "", t = 0, a;
1294
1294
  for (; (a = H.exec(e)) !== null; ) {
1295
- const i = a.index, s = e.charCodeAt(i), d = _u.get(s);
1296
- d !== void 0 ? (u += e.substring(t, i) + d, t = i + 1) : (u += `${e.substring(t, i)}&#x${Ru(e, i).toString(16)};`, t = H.lastIndex += +((s & 64512) === 55296));
1295
+ const i = a.index, s = e.charCodeAt(i), n = _u.get(s);
1296
+ n !== void 0 ? (u += e.substring(t, i) + n, t = i + 1) : (u += `${e.substring(t, i)}&#x${Mu(e, i).toString(16)};`, t = H.lastIndex += +((s & 64512) === 55296));
1297
1297
  }
1298
1298
  return u + e.substr(t);
1299
1299
  }
1300
1300
  function K(e, u) {
1301
1301
  return function(a) {
1302
- let i, s = 0, d = "";
1302
+ let i, s = 0, n = "";
1303
1303
  for (; i = e.exec(a); )
1304
- s !== i.index && (d += a.substring(s, i.index)), d += u.get(i[0].charCodeAt(0)), s = i.index + 1;
1305
- return d + a.substring(s);
1304
+ s !== i.index && (n += a.substring(s, i.index)), n += u.get(i[0].charCodeAt(0)), s = i.index + 1;
1305
+ return n + a.substring(s);
1306
1306
  };
1307
1307
  }
1308
- const Mu = K(/["&\u00A0]/g, /* @__PURE__ */ new Map([
1308
+ const Ru = K(/["&\u00A0]/g, /* @__PURE__ */ new Map([
1309
1309
  [34, "&quot;"],
1310
1310
  [38, "&amp;"],
1311
1311
  [160, "&nbsp;"]
@@ -1429,11 +1429,11 @@ function Gu(e, u) {
1429
1429
  var t;
1430
1430
  if (!e)
1431
1431
  return;
1432
- const a = ((t = u.encodeEntities) !== null && t !== void 0 ? t : u.decodeEntities) === !1 ? Cu : u.xmlMode || u.encodeEntities !== "utf8" ? Y : Mu;
1432
+ const a = ((t = u.encodeEntities) !== null && t !== void 0 ? t : u.decodeEntities) === !1 ? Cu : u.xmlMode || u.encodeEntities !== "utf8" ? Y : Ru;
1433
1433
  return Object.keys(e).map((i) => {
1434
- var s, d;
1434
+ var s, n;
1435
1435
  const b = (s = e[i]) !== null && s !== void 0 ? s : "";
1436
- return u.xmlMode === "foreign" && (i = (d = Pu.get(i)) !== null && d !== void 0 ? d : i), !u.emptyAttrs && !u.xmlMode && b === "" ? i : `${i}="${a(b)}"`;
1436
+ return u.xmlMode === "foreign" && (i = (n = Pu.get(i)) !== null && n !== void 0 ? n : i), !u.emptyAttrs && !u.xmlMode && b === "" ? i : `${i}="${a(b)}"`;
1437
1437
  }).join(" ");
1438
1438
  }
1439
1439
  const $ = /* @__PURE__ */ new Set([
@@ -1457,7 +1457,7 @@ const $ = /* @__PURE__ */ new Set([
1457
1457
  "track",
1458
1458
  "wbr"
1459
1459
  ]);
1460
- function M(e, u = {}) {
1460
+ function R(e, u = {}) {
1461
1461
  const t = "length" in e ? e : [e];
1462
1462
  let a = "";
1463
1463
  for (let i = 0; i < t.length; i++)
@@ -1467,7 +1467,7 @@ function M(e, u = {}) {
1467
1467
  function Fu(e, u) {
1468
1468
  switch (e.type) {
1469
1469
  case gu:
1470
- return M(e.children, u);
1470
+ return R(e.children, u);
1471
1471
  // @ts-expect-error We don't use `Doctype` yet
1472
1472
  case Eu:
1473
1473
  case Su:
@@ -1506,7 +1506,7 @@ function zu(e, u) {
1506
1506
  ) : (
1507
1507
  // User explicitly asked for self-closing tags, even in HTML mode
1508
1508
  u.selfClosingTags && $.has(e.name)
1509
- )) ? (u.xmlMode || (a += " "), a += "/>") : (a += ">", e.children.length > 0 && (a += M(e.children, u)), (u.xmlMode || !$.has(e.name)) && (a += `</${e.name}>`)), a;
1509
+ )) ? (u.xmlMode || (a += " "), a += "/>") : (a += ">", e.children.length > 0 && (a += R(e.children, u)), (u.xmlMode || !$.has(e.name)) && (a += `</${e.name}>`)), a;
1510
1510
  }
1511
1511
  function ju(e) {
1512
1512
  return `<${e.data}>`;
@@ -1549,12 +1549,21 @@ function Yu(e, u) {
1549
1549
  const s = i.attribs?.src;
1550
1550
  s && (i.attribs.src = u(s));
1551
1551
  }
1552
- return M(t);
1552
+ return R(t);
1553
1553
  }
1554
1554
  function Ku(e, u, t) {
1555
1555
  return t.startsWith("http") ? t : t.startsWith("articles/") ? `https://${e}/storage/v1/object/public/content/${t}` : `https://${e}/storage/v1/object/public/content/articles/${u}/${t.trim()}`;
1556
1556
  }
1557
+ function u0(e) {
1558
+ const u = e.trim().split(/\s+/).length, a = Math.max(1, Math.ceil(u / 200));
1559
+ return {
1560
+ minutes: a,
1561
+ text: `${a} min read`,
1562
+ words: u
1563
+ };
1564
+ }
1557
1565
  export {
1558
1566
  Yu as applyImageFullPaths,
1567
+ u0 as calculateReadingTime,
1559
1568
  Ku as resolveImageForArticle
1560
1569
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@k34a/blog",
3
3
  "description": "Create and share articles with your audience.",
4
4
  "private": false,
5
- "version": "0.0.18",
5
+ "version": "0.0.20",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {
@@ -56,7 +56,6 @@
56
56
  ],
57
57
  "dependencies": {
58
58
  "dom-serializer": "^2.0.0",
59
- "htmlparser2": "^10.0.0",
60
- "reading-time": "^1.5.0"
59
+ "htmlparser2": "^10.0.0"
61
60
  }
62
61
  }