@riebeckite/plugin-diff 0.0.16 → 0.0.18
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/README.md +1 -1
- package/README_ja.md +1 -1
- package/dist/index.js +30 -21
- package/package.json +3 -3
- package/style.css +12 -11
package/README.md
CHANGED
package/README_ja.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// index.ts
|
|
2
2
|
import {
|
|
3
|
+
appendContentBodySlot,
|
|
3
4
|
createClientEntry,
|
|
4
5
|
createStyleAsset,
|
|
5
6
|
definePlugin
|
|
@@ -73,13 +74,14 @@ function renderDiffHistory(input) {
|
|
|
73
74
|
const history = input.revisions;
|
|
74
75
|
const selected = input.selected;
|
|
75
76
|
const payloadPath = input.payloadPath;
|
|
77
|
+
if (history.length === 0 || !selected) return "";
|
|
76
78
|
return `<section class="rr-diff-history" data-rr-diff-history>
|
|
77
79
|
<details class="rr-diff-history__panel">
|
|
78
80
|
<summary class="rr-diff-history__header">
|
|
79
81
|
<h2 class="rr-diff-history__title">History</h2>
|
|
80
82
|
<span class="rr-diff-history__header-meta"><span class="rr-diff-history__count">${history.length} changes</span><span class="rr-diff-history__toggle-label rr-diff-history__toggle-label--open">Collapse</span><span class="rr-diff-history__toggle-label rr-diff-history__toggle-label--closed">Expand</span><span class="rr-diff-history__toggle" aria-hidden="true"><svg class="rr-diff-history__toggle-icon" viewBox="0 0 16 16" width="16" height="16" focusable="false"><path d="M5.2 3.4 10.8 8l-5.6 4.6" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"/></svg></span></span>
|
|
81
83
|
</summary>
|
|
82
|
-
|
|
84
|
+
${renderContent(history, selected)}
|
|
83
85
|
</details>
|
|
84
86
|
${payloadPath ? `<script type="application/json" data-rr-diff-history-data>${JSON.stringify({ path: payloadPath }).replace(/</g, "\\u003c")}</script>` : ""}
|
|
85
87
|
</section>`;
|
|
@@ -92,9 +94,6 @@ function renderContent(history, selected) {
|
|
|
92
94
|
${renderDiffViewer({ history, selected })}
|
|
93
95
|
</div>`;
|
|
94
96
|
}
|
|
95
|
-
function renderEmptyState() {
|
|
96
|
-
return `<p class="rr-diff-history__empty">No Git history is available for this article.</p>`;
|
|
97
|
-
}
|
|
98
97
|
function renderRevisionButton(revision, selected) {
|
|
99
98
|
return `<li class="rr-diff-history__item">
|
|
100
99
|
<button class="rr-diff-history__commit" type="button" data-rr-diff-select="${escapeHtml(revision.hash)}" aria-pressed="${selected}">
|
|
@@ -391,39 +390,49 @@ function diff(options = {}) {
|
|
|
391
390
|
let api;
|
|
392
391
|
return definePlugin({
|
|
393
392
|
name: "diff",
|
|
393
|
+
order: 200,
|
|
394
394
|
processedContentCache: {
|
|
395
|
-
version: "diff-
|
|
395
|
+
version: "diff-v3",
|
|
396
396
|
dependencyMode: "unsafe"
|
|
397
397
|
},
|
|
398
398
|
options,
|
|
399
399
|
assets: ui.enabled === false ? [] : [createStyleAsset("diff")],
|
|
400
400
|
clientEntries: ui.enabled === false ? [] : [createClientEntry("diff", "initDiffHistory")],
|
|
401
|
-
|
|
401
|
+
onManifestCreated: async (context) => {
|
|
402
402
|
if (ui.enabled === false) return;
|
|
403
403
|
api ??= createPostDiffApi({
|
|
404
404
|
...options,
|
|
405
405
|
cwd: options.cwd ?? context.config?.content.directory
|
|
406
406
|
});
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
407
|
+
for (const entry of context.manifest.discoverableEntries) {
|
|
408
|
+
const filePath = resolvePostFilePath({
|
|
409
|
+
slug: entry.slug,
|
|
410
|
+
contentIndex: context.contentIndex
|
|
411
|
+
});
|
|
412
|
+
const history = (await api.getHistory(filePath)).slice(
|
|
413
|
+
0,
|
|
414
|
+
ui.maxRevisions
|
|
415
|
+
);
|
|
416
|
+
const revisions = await getMarkdownRevisions(api, filePath, history);
|
|
417
|
+
if (revisions.length === 0) continue;
|
|
418
|
+
const selected = await api.getCurrentDiff(filePath);
|
|
419
|
+
if (!selected) continue;
|
|
420
|
+
const payloadPath = diffPayloadPath(entry.slug);
|
|
416
421
|
context.output.emit({
|
|
417
422
|
path: payloadPath,
|
|
418
423
|
content: JSON.stringify({ revisions }).replace(/</g, "\\u003c"),
|
|
419
|
-
dependencies: [{ type: "content", slug:
|
|
424
|
+
dependencies: [{ type: "content", slug: entry.slug }]
|
|
420
425
|
});
|
|
426
|
+
appendContentBodySlot(
|
|
427
|
+
entry,
|
|
428
|
+
"article.footer",
|
|
429
|
+
renderDiffHistory({
|
|
430
|
+
revisions,
|
|
431
|
+
selected,
|
|
432
|
+
payloadPath: `/${payloadPath}`
|
|
433
|
+
})
|
|
434
|
+
);
|
|
421
435
|
}
|
|
422
|
-
context.content.html += renderDiffHistory({
|
|
423
|
-
revisions,
|
|
424
|
-
selected,
|
|
425
|
-
payloadPath: payloadPath ? `/${payloadPath}` : void 0
|
|
426
|
-
});
|
|
427
436
|
}
|
|
428
437
|
});
|
|
429
438
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-diff",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"./style.css": "./style.css"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@riebeckite/core": "0.0.
|
|
24
|
+
"@riebeckite/core": "0.0.18"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^24.5.2",
|
|
28
28
|
"tsx": "^4.22.4",
|
|
29
|
-
"@riebeckite/test": "0.0.
|
|
29
|
+
"@riebeckite/test": "0.0.18"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
package/style.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.rr-diff-history {
|
|
2
|
-
margin-block:
|
|
2
|
+
margin-block-start: var(--rb-space-6, 3rem);
|
|
3
3
|
border-block-start: 1px solid
|
|
4
4
|
var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
|
|
5
5
|
padding-block-start: 1.5rem;
|
|
@@ -277,15 +277,6 @@
|
|
|
277
277
|
background: color-mix(in srgb, currentColor 2%, transparent);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
.rr-diff-history__empty {
|
|
281
|
-
margin: 0;
|
|
282
|
-
color: var(
|
|
283
|
-
--rb-color-muted,
|
|
284
|
-
color-mix(in srgb, currentColor 62%, transparent)
|
|
285
|
-
);
|
|
286
|
-
font-size: 0.9375rem;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
280
|
@media (max-width: 720px) {
|
|
290
281
|
.rr-diff-history__layout {
|
|
291
282
|
grid-template-columns: 1fr;
|
|
@@ -298,6 +289,16 @@
|
|
|
298
289
|
}
|
|
299
290
|
|
|
300
291
|
.rr-diff-history__header {
|
|
301
|
-
align-items:
|
|
292
|
+
align-items: center;
|
|
293
|
+
flex-wrap: nowrap;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.rr-diff-history__title {
|
|
297
|
+
min-width: 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.rr-diff-history__header-meta {
|
|
301
|
+
flex: none;
|
|
302
|
+
white-space: nowrap;
|
|
302
303
|
}
|
|
303
304
|
}
|