@riebeckite/plugin-query 0.0.5 → 0.0.6
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/index.d.ts +1 -1
- package/dist/index.js +10 -3
- package/package.json +8 -3
- package/style.css +111 -111
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QueryOptions } from "./src/types.js";
|
|
2
|
-
export { remarkQuery } from "./src/remark.js";
|
|
3
2
|
export { queryContentEntries } from "@riebeckite/core";
|
|
3
|
+
export { remarkQuery } from "./src/remark.js";
|
|
4
4
|
export type { QueryOptions, QueryOutputFormat, QuerySpec, } from "./src/types.js";
|
|
5
5
|
export declare function queryPlugin(options?: QueryOptions): import("@riebeckite/core").RiebeckitePlugin<QueryOptions>;
|
package/dist/index.js
CHANGED
|
@@ -86,7 +86,9 @@ function renderTable(entries, query) {
|
|
|
86
86
|
).join("");
|
|
87
87
|
const rows = entries.map((entry) => {
|
|
88
88
|
const cells = columns.map((field) => {
|
|
89
|
-
const modifier = escapeHtmlAttribute(
|
|
89
|
+
const modifier = escapeHtmlAttribute(
|
|
90
|
+
`rr-query__cell--${slugify(field)}`
|
|
91
|
+
);
|
|
90
92
|
return `<td class="${escapeHtmlAttribute(className)}__cell ${modifier}">${renderCell(entry, field, className)}</td>`;
|
|
91
93
|
}).join("");
|
|
92
94
|
return `<tr class="${escapeHtmlAttribute(className)}__row">${cells}</tr>`;
|
|
@@ -130,8 +132,12 @@ function renderCell(entry, field, className) {
|
|
|
130
132
|
return escapeHtml(formatValue(readFrontmatterField(entry, field)));
|
|
131
133
|
}
|
|
132
134
|
}
|
|
135
|
+
function entryTitle(entry) {
|
|
136
|
+
const title = entry.frontmatter.title;
|
|
137
|
+
return typeof title === "string" && title.trim() ? title : entry.title;
|
|
138
|
+
}
|
|
133
139
|
function renderTitleLink(entry, className) {
|
|
134
|
-
return `<a class="${escapeHtmlAttribute(className)}__link" href="${escapeHtmlAttribute(entry.permalink)}">${escapeHtml(entry
|
|
140
|
+
return `<a class="${escapeHtmlAttribute(className)}__link" href="${escapeHtmlAttribute(entry.permalink)}">${escapeHtml(entryTitle(entry))}</a>`;
|
|
135
141
|
}
|
|
136
142
|
function renderTags(tags, className) {
|
|
137
143
|
return tags.map(
|
|
@@ -150,7 +156,8 @@ function columnLabel(field) {
|
|
|
150
156
|
function formatValue(value) {
|
|
151
157
|
if (value === void 0 || value === null) return "";
|
|
152
158
|
if (value instanceof Date) return formatDate(value);
|
|
153
|
-
if (Array.isArray(value))
|
|
159
|
+
if (Array.isArray(value))
|
|
160
|
+
return value.map((item) => formatValue(item)).join(", ");
|
|
154
161
|
if (typeof value === "string") {
|
|
155
162
|
return DATE_ONLY.test(value.trim()) ? value.trim() : value;
|
|
156
163
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-query",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,7 +18,11 @@
|
|
|
18
18
|
"@types/mdast": "^4.0.4",
|
|
19
19
|
"unist-util-visit": "^5.1.0",
|
|
20
20
|
"vfile-matter": "^5.0.1",
|
|
21
|
-
"@riebeckite/core": "0.0.
|
|
21
|
+
"@riebeckite/core": "0.0.6"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"tsx": "^4.22.4",
|
|
25
|
+
"@riebeckite/test": "0.0.6"
|
|
22
26
|
},
|
|
23
27
|
"publishConfig": {
|
|
24
28
|
"access": "public"
|
|
@@ -53,6 +57,7 @@
|
|
|
53
57
|
"./style.css"
|
|
54
58
|
],
|
|
55
59
|
"scripts": {
|
|
56
|
-
"build": "node ../../../scripts/build_package.mjs"
|
|
60
|
+
"build": "node ../../../scripts/build_package.mjs",
|
|
61
|
+
"test": "node --import tsx --test \"test/*.test.ts\""
|
|
57
62
|
}
|
|
58
63
|
}
|
package/style.css
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
.rr-query {
|
|
2
|
-
--rr-query-ink: var(--rb-color-ink, #000000);
|
|
3
|
-
--rr-query-paper: var(--rb-color-paper, #ffffff);
|
|
4
|
-
--rr-query-muted: var(--rb-color-muted, #69645c);
|
|
5
|
-
--rr-query-accent: var(--rb-color-accent, #686868);
|
|
6
|
-
--rr-query-rule: var(
|
|
7
|
-
--rb-color-border,
|
|
8
|
-
color-mix(in srgb, var(--rr-query-ink) 18%, transparent)
|
|
9
|
-
);
|
|
10
|
-
--rr-query-surface: color-mix(
|
|
11
|
-
in srgb,
|
|
12
|
-
var(--rr-query-paper) 94%,
|
|
13
|
-
var(--rr-query-ink)
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
margin: 1.5rem 0;
|
|
17
|
-
color: var(--rr-query-ink);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.rr-query__table {
|
|
21
|
-
width: 100%;
|
|
22
|
-
border-collapse: collapse;
|
|
23
|
-
font-size: 0.9375rem;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.rr-query__heading {
|
|
27
|
-
padding: 0.5rem 0.75rem;
|
|
28
|
-
border-bottom: 1px solid var(--rr-query-ink);
|
|
29
|
-
text-align: left;
|
|
30
|
-
font-weight: 700;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.rr-query__cell {
|
|
34
|
-
padding: 0.5rem 0.75rem;
|
|
35
|
-
vertical-align: top;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.rr-query__row:not(:last-child) .rr-query__cell {
|
|
39
|
-
border-bottom: 1px solid var(--rr-query-rule);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.rr-query__cell--date,
|
|
43
|
-
.rr-query__meta--date,
|
|
44
|
-
.rr-query__meta--created,
|
|
45
|
-
.rr-query__meta--updated,
|
|
46
|
-
.rr-query__meta--published {
|
|
47
|
-
color: var(--rr-query-muted);
|
|
48
|
-
white-space: nowrap;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.rr-query__link {
|
|
52
|
-
color: inherit;
|
|
53
|
-
text-decoration: underline;
|
|
54
|
-
text-decoration-color: var(--rr-query-rule);
|
|
55
|
-
text-underline-offset: 0.2em;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.rr-query__link:hover,
|
|
59
|
-
.rr-query__link:focus-visible {
|
|
60
|
-
text-decoration-color: var(--rr-query-accent);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.rr-query__tag {
|
|
64
|
-
color: var(--rr-query-muted);
|
|
65
|
-
font-size: 0.8125em;
|
|
66
|
-
white-space: nowrap;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.rr-query__list {
|
|
70
|
-
margin: 0;
|
|
71
|
-
padding: 0;
|
|
72
|
-
list-style: none;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.rr-query__item {
|
|
76
|
-
display: flex;
|
|
77
|
-
flex-wrap: wrap;
|
|
78
|
-
gap: 0.5rem;
|
|
79
|
-
align-items: baseline;
|
|
80
|
-
padding: 0.5rem 0;
|
|
81
|
-
border-bottom: 1px solid var(--rr-query-rule);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.rr-query__item:last-child {
|
|
85
|
-
border-bottom: 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.rr-query__meta {
|
|
89
|
-
color: var(--rr-query-muted);
|
|
90
|
-
font-size: 0.8125em;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.rr-query--empty {
|
|
94
|
-
margin: 1.5rem 0;
|
|
95
|
-
color: var(--rr-query-muted);
|
|
96
|
-
font-style: italic;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.rr-query--error {
|
|
100
|
-
margin: 1.5rem 0;
|
|
101
|
-
padding: 0.75rem 1rem;
|
|
102
|
-
border: 1px solid var(--rr-query-ink);
|
|
103
|
-
background: var(--rr-query-surface);
|
|
104
|
-
font-size: 0.875rem;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
html[data-theme="dark"] .rr-query,
|
|
108
|
-
html.dark .rr-query {
|
|
109
|
-
--rr-query-ink: var(--rb-color-paper, #ffffff);
|
|
110
|
-
--rr-query-paper: var(--rb-color-ink, #000000);
|
|
111
|
-
}
|
|
1
|
+
.rr-query {
|
|
2
|
+
--rr-query-ink: var(--rb-color-ink, #000000);
|
|
3
|
+
--rr-query-paper: var(--rb-color-paper, #ffffff);
|
|
4
|
+
--rr-query-muted: var(--rb-color-muted, #69645c);
|
|
5
|
+
--rr-query-accent: var(--rb-color-accent, #686868);
|
|
6
|
+
--rr-query-rule: var(
|
|
7
|
+
--rb-color-border,
|
|
8
|
+
color-mix(in srgb, var(--rr-query-ink) 18%, transparent)
|
|
9
|
+
);
|
|
10
|
+
--rr-query-surface: color-mix(
|
|
11
|
+
in srgb,
|
|
12
|
+
var(--rr-query-paper) 94%,
|
|
13
|
+
var(--rr-query-ink)
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
margin: 1.5rem 0;
|
|
17
|
+
color: var(--rr-query-ink);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.rr-query__table {
|
|
21
|
+
width: 100%;
|
|
22
|
+
border-collapse: collapse;
|
|
23
|
+
font-size: 0.9375rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.rr-query__heading {
|
|
27
|
+
padding: 0.5rem 0.75rem;
|
|
28
|
+
border-bottom: 1px solid var(--rr-query-ink);
|
|
29
|
+
text-align: left;
|
|
30
|
+
font-weight: 700;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.rr-query__cell {
|
|
34
|
+
padding: 0.5rem 0.75rem;
|
|
35
|
+
vertical-align: top;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.rr-query__row:not(:last-child) .rr-query__cell {
|
|
39
|
+
border-bottom: 1px solid var(--rr-query-rule);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.rr-query__cell--date,
|
|
43
|
+
.rr-query__meta--date,
|
|
44
|
+
.rr-query__meta--created,
|
|
45
|
+
.rr-query__meta--updated,
|
|
46
|
+
.rr-query__meta--published {
|
|
47
|
+
color: var(--rr-query-muted);
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.rr-query__link {
|
|
52
|
+
color: inherit;
|
|
53
|
+
text-decoration: underline;
|
|
54
|
+
text-decoration-color: var(--rr-query-rule);
|
|
55
|
+
text-underline-offset: 0.2em;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.rr-query__link:hover,
|
|
59
|
+
.rr-query__link:focus-visible {
|
|
60
|
+
text-decoration-color: var(--rr-query-accent);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.rr-query__tag {
|
|
64
|
+
color: var(--rr-query-muted);
|
|
65
|
+
font-size: 0.8125em;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.rr-query__list {
|
|
70
|
+
margin: 0;
|
|
71
|
+
padding: 0;
|
|
72
|
+
list-style: none;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.rr-query__item {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-wrap: wrap;
|
|
78
|
+
gap: 0.5rem;
|
|
79
|
+
align-items: baseline;
|
|
80
|
+
padding: 0.5rem 0;
|
|
81
|
+
border-bottom: 1px solid var(--rr-query-rule);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.rr-query__item:last-child {
|
|
85
|
+
border-bottom: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.rr-query__meta {
|
|
89
|
+
color: var(--rr-query-muted);
|
|
90
|
+
font-size: 0.8125em;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.rr-query--empty {
|
|
94
|
+
margin: 1.5rem 0;
|
|
95
|
+
color: var(--rr-query-muted);
|
|
96
|
+
font-style: italic;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.rr-query--error {
|
|
100
|
+
margin: 1.5rem 0;
|
|
101
|
+
padding: 0.75rem 1rem;
|
|
102
|
+
border: 1px solid var(--rr-query-ink);
|
|
103
|
+
background: var(--rr-query-surface);
|
|
104
|
+
font-size: 0.875rem;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
html[data-theme="dark"] .rr-query,
|
|
108
|
+
html.dark .rr-query {
|
|
109
|
+
--rr-query-ink: var(--rb-color-paper, #ffffff);
|
|
110
|
+
--rr-query-paper: var(--rb-color-ink, #000000);
|
|
111
|
+
}
|