@k34a/blog 0.0.3 → 0.0.5
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.
- package/dist/components/articles/banner-image.d.ts +9 -0
- package/dist/components/articles/banner-image.js +27 -0
- package/dist/components/articles/description.d.ts +8 -0
- package/dist/components/articles/description.js +18 -0
- package/dist/components/articles/index.d.ts +11 -0
- package/dist/components/articles/index.js +49 -0
- package/dist/components/filter-search-sort.d.ts +9 -0
- package/dist/components/filter-search-sort.js +200 -0
- package/dist/components/types.d.ts +4 -0
- package/dist/components/types.js +1 -0
- package/dist/components/utils.d.ts +2 -0
- package/dist/components/utils.js +1560 -0
- package/dist/main.d.ts +4 -2
- package/dist/main.js +8 -4
- package/package.json +6 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { Box as r, Image as a } from "@mantine/core";
|
|
4
|
+
import { getImageForArticle as o } from "../utils.js";
|
|
5
|
+
const s = (e) => {
|
|
6
|
+
const i = o(
|
|
7
|
+
e.config.supabaseHost,
|
|
8
|
+
e.id,
|
|
9
|
+
e.src
|
|
10
|
+
);
|
|
11
|
+
return /* @__PURE__ */ t(r, { pos: "relative", h: { base: 260, lg: "100%" }, children: /* @__PURE__ */ t(
|
|
12
|
+
a,
|
|
13
|
+
{
|
|
14
|
+
src: i,
|
|
15
|
+
alt: e.title,
|
|
16
|
+
width: 1e3,
|
|
17
|
+
height: 1e3,
|
|
18
|
+
style: {
|
|
19
|
+
maxWidth: "100%",
|
|
20
|
+
height: "auto"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
) });
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
s as BannerImage
|
|
27
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { Typography as i } from "@mantine/core";
|
|
4
|
+
import { applyImageFullPaths as l, getImageForArticle as n } from "../utils.js";
|
|
5
|
+
function s(t) {
|
|
6
|
+
const r = l(
|
|
7
|
+
t.html,
|
|
8
|
+
(o) => n(
|
|
9
|
+
t.config.supabaseHost,
|
|
10
|
+
t.articleId,
|
|
11
|
+
`content/${o}`
|
|
12
|
+
)
|
|
13
|
+
);
|
|
14
|
+
return /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e("div", { dangerouslySetInnerHTML: { __html: r } }) });
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
s as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComponentsConfig } from '../types';
|
|
2
|
+
type Props = {
|
|
3
|
+
config: ComponentsConfig;
|
|
4
|
+
title: string;
|
|
5
|
+
banner_image?: string;
|
|
6
|
+
id: string;
|
|
7
|
+
description: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
};
|
|
10
|
+
export default function Article(props: Props): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
3
|
+
import { Box as r, Stack as c, Title as a, Flex as l, Anchor as m, Badge as o } from "@mantine/core";
|
|
4
|
+
import { IconHash as g } from "@tabler/icons-react";
|
|
5
|
+
import { BannerImage as d } from "./banner-image.js";
|
|
6
|
+
import f from "./description.js";
|
|
7
|
+
async function b(i) {
|
|
8
|
+
return /* @__PURE__ */ e(r, { maw: 800, mx: "auto", px: "sm", py: "lg", children: /* @__PURE__ */ t(c, { gap: "md", children: [
|
|
9
|
+
/* @__PURE__ */ e(a, { order: 1, children: i.title }),
|
|
10
|
+
i.banner_image && /* @__PURE__ */ e(
|
|
11
|
+
d,
|
|
12
|
+
{
|
|
13
|
+
id: i.id,
|
|
14
|
+
src: i.banner_image,
|
|
15
|
+
title: i.title,
|
|
16
|
+
config: i.config
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
/* @__PURE__ */ e(
|
|
20
|
+
f,
|
|
21
|
+
{
|
|
22
|
+
articleId: i.id,
|
|
23
|
+
html: i.description,
|
|
24
|
+
config: i.config
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
/* @__PURE__ */ e(l, { wrap: "wrap", gap: "md", align: "center", mb: "lg", children: i.tags.map((n) => /* @__PURE__ */ e(
|
|
28
|
+
m,
|
|
29
|
+
{
|
|
30
|
+
href: `/${i.config.listingPage}?tags=${n}`,
|
|
31
|
+
children: /* @__PURE__ */ e(
|
|
32
|
+
o,
|
|
33
|
+
{
|
|
34
|
+
size: "md",
|
|
35
|
+
color: "sky.5",
|
|
36
|
+
variant: "outline",
|
|
37
|
+
leftSection: /* @__PURE__ */ e(g, { size: 14 }),
|
|
38
|
+
style: { cursor: "pointer" },
|
|
39
|
+
children: n
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
},
|
|
43
|
+
n
|
|
44
|
+
)) })
|
|
45
|
+
] }) });
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
b as default
|
|
49
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { articleQuerySchema } from '../services/search-params';
|
|
3
|
+
type FilterProps = z.infer<typeof articleQuerySchema>;
|
|
4
|
+
export interface Props extends FilterProps {
|
|
5
|
+
availableTags: string[];
|
|
6
|
+
navigate: (query: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export default function FilterSearchSortArticles(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as t, jsxs as w } from "react/jsx-runtime";
|
|
3
|
+
import { Group as A, TextInput as z, Popover as h, Indicator as T, ActionIcon as F, Stack as k, MultiSelect as I, Button as R } from "@mantine/core";
|
|
4
|
+
import { IconSearch as B, IconFilter as j, IconSelector as x, IconCheck as L } from "@tabler/icons-react";
|
|
5
|
+
import { useRef as y, useEffect as C, useMemo as O, useState as b, useCallback as _ } from "react";
|
|
6
|
+
import "../services/search-params.js";
|
|
7
|
+
function Z(r) {
|
|
8
|
+
const s = y(r);
|
|
9
|
+
return C(() => {
|
|
10
|
+
s.current = r;
|
|
11
|
+
}), O(() => ((...o) => s.current?.(...o)), []);
|
|
12
|
+
}
|
|
13
|
+
function D(r, s) {
|
|
14
|
+
const { delay: o, flushOnUnmount: i, leading: f } = { delay: s, flushOnUnmount: !1, leading: !1 }, n = Z(r), c = y(0), u = O(() => {
|
|
15
|
+
const l = Object.assign(
|
|
16
|
+
(...d) => {
|
|
17
|
+
window.clearTimeout(c.current);
|
|
18
|
+
const g = l._isFirstCall;
|
|
19
|
+
l._isFirstCall = !1;
|
|
20
|
+
function a() {
|
|
21
|
+
window.clearTimeout(c.current), c.current = 0, l._isFirstCall = !0;
|
|
22
|
+
}
|
|
23
|
+
if (f && g) {
|
|
24
|
+
n(...d);
|
|
25
|
+
const m = () => {
|
|
26
|
+
a();
|
|
27
|
+
}, e = () => {
|
|
28
|
+
c.current !== 0 && (a(), n(...d));
|
|
29
|
+
}, v = () => {
|
|
30
|
+
a();
|
|
31
|
+
};
|
|
32
|
+
l.flush = e, l.cancel = v, c.current = window.setTimeout(m, o);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (f && !g) {
|
|
36
|
+
const m = () => {
|
|
37
|
+
c.current !== 0 && (a(), n(...d));
|
|
38
|
+
}, e = () => {
|
|
39
|
+
a();
|
|
40
|
+
};
|
|
41
|
+
l.flush = m, l.cancel = e;
|
|
42
|
+
const v = () => {
|
|
43
|
+
a();
|
|
44
|
+
};
|
|
45
|
+
c.current = window.setTimeout(v, o);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const p = () => {
|
|
49
|
+
c.current !== 0 && (a(), n(...d));
|
|
50
|
+
}, S = () => {
|
|
51
|
+
a();
|
|
52
|
+
};
|
|
53
|
+
l.flush = p, l.cancel = S, c.current = window.setTimeout(p, o);
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
flush: () => {
|
|
57
|
+
},
|
|
58
|
+
cancel: () => {
|
|
59
|
+
},
|
|
60
|
+
_isFirstCall: !0
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
return l;
|
|
64
|
+
}, [n, o, f]);
|
|
65
|
+
return C(
|
|
66
|
+
() => () => {
|
|
67
|
+
i ? u.flush() : u.cancel();
|
|
68
|
+
},
|
|
69
|
+
[u, i]
|
|
70
|
+
), u;
|
|
71
|
+
}
|
|
72
|
+
const P = [
|
|
73
|
+
{ value: "latest", label: "Latest" },
|
|
74
|
+
{ value: "oldest", label: "Oldest" },
|
|
75
|
+
{ value: "A-Z", label: "Title A-Z" },
|
|
76
|
+
{ value: "Z-A", label: "Title Z-A" }
|
|
77
|
+
];
|
|
78
|
+
function N(r) {
|
|
79
|
+
const [s, o] = b(r.search ?? ""), [i, f] = b(
|
|
80
|
+
r.sortBy ?? "latest"
|
|
81
|
+
), [n, c] = b(
|
|
82
|
+
r.tags ?? []
|
|
83
|
+
), [u, l] = b(!1), [d, g] = b(!1), a = D(() => {
|
|
84
|
+
const e = p();
|
|
85
|
+
r.navigate(e);
|
|
86
|
+
}, 300), p = _(() => {
|
|
87
|
+
const e = new URLSearchParams();
|
|
88
|
+
return s && e.set("search", s), n.length > 0 && e.set("tags", n.join(",")), i && e.set("sortBy", i), e.set("page", "0"), e.toString();
|
|
89
|
+
}, [s, n, i]);
|
|
90
|
+
C(() => {
|
|
91
|
+
a();
|
|
92
|
+
}, [n, s, i]);
|
|
93
|
+
const S = n.length > 0, m = i !== "latest";
|
|
94
|
+
return /* @__PURE__ */ t("form", { style: { paddingBottom: "20px" }, children: /* @__PURE__ */ w(A, { justify: "space-between", wrap: "nowrap", children: [
|
|
95
|
+
/* @__PURE__ */ t(
|
|
96
|
+
z,
|
|
97
|
+
{
|
|
98
|
+
placeholder: "Search articles...",
|
|
99
|
+
value: s,
|
|
100
|
+
onChange: (e) => o(e.currentTarget.value),
|
|
101
|
+
leftSection: /* @__PURE__ */ t(B, { size: 16 }),
|
|
102
|
+
rightSectionWidth: 40,
|
|
103
|
+
w: "100%",
|
|
104
|
+
size: "lg"
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ w(
|
|
108
|
+
h,
|
|
109
|
+
{
|
|
110
|
+
opened: u,
|
|
111
|
+
onChange: l,
|
|
112
|
+
position: "bottom-end",
|
|
113
|
+
width: 300,
|
|
114
|
+
trapFocus: !0,
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ t(h.Target, { children: /* @__PURE__ */ t(
|
|
117
|
+
T,
|
|
118
|
+
{
|
|
119
|
+
color: "blue",
|
|
120
|
+
size: 8,
|
|
121
|
+
offset: 4,
|
|
122
|
+
disabled: !S,
|
|
123
|
+
inline: !0,
|
|
124
|
+
children: /* @__PURE__ */ t(
|
|
125
|
+
F,
|
|
126
|
+
{
|
|
127
|
+
variant: "light",
|
|
128
|
+
onClick: () => l((e) => !e),
|
|
129
|
+
size: "lg",
|
|
130
|
+
children: /* @__PURE__ */ t(j, { size: 18 })
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
) }),
|
|
135
|
+
/* @__PURE__ */ t(h.Dropdown, { children: /* @__PURE__ */ t(k, { gap: "sm", children: /* @__PURE__ */ t(
|
|
136
|
+
I,
|
|
137
|
+
{
|
|
138
|
+
label: "Tags",
|
|
139
|
+
data: r.availableTags.map((e) => ({
|
|
140
|
+
value: e,
|
|
141
|
+
label: e
|
|
142
|
+
})),
|
|
143
|
+
value: n,
|
|
144
|
+
onChange: c,
|
|
145
|
+
searchable: !0,
|
|
146
|
+
placeholder: "Select tags"
|
|
147
|
+
}
|
|
148
|
+
) }) })
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ w(
|
|
153
|
+
h,
|
|
154
|
+
{
|
|
155
|
+
opened: d,
|
|
156
|
+
onChange: g,
|
|
157
|
+
position: "bottom-end",
|
|
158
|
+
width: 200,
|
|
159
|
+
trapFocus: !0,
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ t(h.Target, { children: /* @__PURE__ */ t(
|
|
162
|
+
T,
|
|
163
|
+
{
|
|
164
|
+
color: "blue",
|
|
165
|
+
size: 8,
|
|
166
|
+
offset: 4,
|
|
167
|
+
disabled: !m,
|
|
168
|
+
inline: !0,
|
|
169
|
+
children: /* @__PURE__ */ t(
|
|
170
|
+
F,
|
|
171
|
+
{
|
|
172
|
+
size: "lg",
|
|
173
|
+
variant: "light",
|
|
174
|
+
onClick: () => g((e) => !e),
|
|
175
|
+
children: /* @__PURE__ */ t(x, { size: 18 })
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
) }),
|
|
180
|
+
/* @__PURE__ */ t(h.Dropdown, { children: /* @__PURE__ */ t(k, { children: P.map((e) => /* @__PURE__ */ t(
|
|
181
|
+
R,
|
|
182
|
+
{
|
|
183
|
+
onClick: () => f(
|
|
184
|
+
e.value
|
|
185
|
+
),
|
|
186
|
+
size: "sm",
|
|
187
|
+
variant: "subtle",
|
|
188
|
+
leftSection: i === e.value ? /* @__PURE__ */ t(L, {}) : void 0,
|
|
189
|
+
children: e.label
|
|
190
|
+
},
|
|
191
|
+
e.value
|
|
192
|
+
)) }) })
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] }) });
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
N as default
|
|
200
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|