@refrakt-md/svelte 0.9.3 → 0.9.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/package.json +4 -4
- package/src/Renderer.svelte +2 -0
- package/src/ThemeShell.svelte +9 -2
- package/src/elements.ts +3 -7
- package/src/elements/Pre.svelte +0 -77
- package/src/elements/Table.svelte +0 -12
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refrakt-md/svelte",
|
|
3
3
|
"description": "Svelte renderer for refrakt.md content",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@markdoc/markdoc": "0.4.0",
|
|
30
|
-
"@refrakt-md/behaviors": "0.9.
|
|
31
|
-
"@refrakt-md/transform": "0.9.
|
|
32
|
-
"@refrakt-md/types": "0.9.
|
|
30
|
+
"@refrakt-md/behaviors": "0.9.5",
|
|
31
|
+
"@refrakt-md/transform": "0.9.5",
|
|
32
|
+
"@refrakt-md/types": "0.9.5"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"svelte": "^5.0.0"
|
package/src/Renderer.svelte
CHANGED
|
@@ -121,6 +121,8 @@
|
|
|
121
121
|
</ElementOverride>
|
|
122
122
|
{:else if node.name === 'svg'}
|
|
123
123
|
{@html svgToHtml(node)}
|
|
124
|
+
{:else if VOID_ELEMENTS.has(node.name)}
|
|
125
|
+
<svelte:element this={node.name} {...htmlAttrs(node.attributes)} />
|
|
124
126
|
{:else}
|
|
125
127
|
<svelte:element this={node.name} {...htmlAttrs(node.attributes)}>
|
|
126
128
|
{#each node.children as child}
|
package/src/ThemeShell.svelte
CHANGED
|
@@ -108,25 +108,32 @@
|
|
|
108
108
|
{#if page.seo?.og.title}
|
|
109
109
|
<title>{page.seo.og.title}</title>
|
|
110
110
|
<meta property="og:title" content={page.seo.og.title} />
|
|
111
|
+
<meta name="twitter:title" content={page.seo.og.title} />
|
|
111
112
|
{:else if page.title}
|
|
112
113
|
<title>{page.title}</title>
|
|
113
114
|
{/if}
|
|
114
115
|
{#if page.seo?.og.description}
|
|
115
116
|
<meta name="description" content={page.seo.og.description} />
|
|
116
117
|
<meta property="og:description" content={page.seo.og.description} />
|
|
118
|
+
<meta name="twitter:description" content={page.seo.og.description} />
|
|
117
119
|
{:else if page.description}
|
|
118
120
|
<meta name="description" content={page.description} />
|
|
119
121
|
{/if}
|
|
120
122
|
{#if page.seo?.og.image}
|
|
121
123
|
<meta property="og:image" content={page.seo.og.image} />
|
|
122
124
|
<meta name="twitter:card" content="summary_large_image" />
|
|
125
|
+
<meta name="twitter:image" content={page.seo.og.image} />
|
|
126
|
+
{:else}
|
|
127
|
+
<meta name="twitter:card" content="summary" />
|
|
123
128
|
{/if}
|
|
124
129
|
{#if page.seo?.og.url}
|
|
130
|
+
<link rel="canonical" href={page.seo.og.url} />
|
|
125
131
|
<meta property="og:url" content={page.seo.og.url} />
|
|
126
132
|
{/if}
|
|
127
133
|
{#if page.seo?.og.type}
|
|
128
134
|
<meta property="og:type" content={page.seo.og.type} />
|
|
129
135
|
{/if}
|
|
136
|
+
<meta property="og:site_name" content={theme.manifest.siteName ?? 'refrakt.md'} />
|
|
130
137
|
{#if page.seo}
|
|
131
138
|
{#each page.seo.jsonLd as schema}
|
|
132
139
|
{@html `<script type="application/ld+json">${JSON.stringify(schema)}</script>`}
|
|
@@ -139,7 +146,7 @@
|
|
|
139
146
|
{@const tree = layoutTransform(layoutEntry, page, 'rf')}
|
|
140
147
|
<Renderer node={tree} />
|
|
141
148
|
{:else if layoutEntry}
|
|
142
|
-
<
|
|
149
|
+
<layoutEntry
|
|
143
150
|
title={page.title}
|
|
144
151
|
description={page.description}
|
|
145
152
|
frontmatter={page.frontmatter}
|
|
@@ -148,6 +155,6 @@
|
|
|
148
155
|
pages={page.pages}
|
|
149
156
|
url={page.url}
|
|
150
157
|
headings={page.headings}
|
|
151
|
-
|
|
158
|
+
></layoutEntry>
|
|
152
159
|
{/if}
|
|
153
160
|
{/key}
|
package/src/elements.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { ElementOverrides } from './context.js';
|
|
2
|
-
import Table from './elements/Table.svelte';
|
|
3
|
-
import Pre from './elements/Pre.svelte';
|
|
4
2
|
|
|
5
|
-
/** Base element overrides —
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
'pre': Pre,
|
|
9
|
-
};
|
|
3
|
+
/** Base element overrides — empty by default. User-defined overrides can be
|
|
4
|
+
* registered via setElementOverrides(). */
|
|
5
|
+
export const elements: ElementOverrides = {};
|
package/src/elements/Pre.svelte
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { SerializedTag } from '../types.js';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
|
-
|
|
5
|
-
let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
|
|
6
|
-
|
|
7
|
-
const isCodeBlock = 'data-language' in (tag.attributes || {});
|
|
8
|
-
|
|
9
|
-
let preEl: HTMLPreElement;
|
|
10
|
-
let copied = $state(false);
|
|
11
|
-
let timer: ReturnType<typeof setTimeout>;
|
|
12
|
-
|
|
13
|
-
function copy() {
|
|
14
|
-
const text = preEl.textContent ?? '';
|
|
15
|
-
navigator.clipboard.writeText(text);
|
|
16
|
-
copied = true;
|
|
17
|
-
clearTimeout(timer);
|
|
18
|
-
timer = setTimeout(() => copied = false, 2000);
|
|
19
|
-
}
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
{#if isCodeBlock}
|
|
23
|
-
<div class="rf-codeblock">
|
|
24
|
-
<pre bind:this={preEl} {...tag.attributes}>{@render children()}</pre>
|
|
25
|
-
<button class="rf-codeblock__copy" class:rf-codeblock__copy--copied={copied} onclick={copy} aria-label="Copy code">
|
|
26
|
-
{#if copied}
|
|
27
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
28
|
-
<polyline points="20 6 9 17 4 12" />
|
|
29
|
-
</svg>
|
|
30
|
-
{:else}
|
|
31
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
32
|
-
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
|
|
33
|
-
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
|
|
34
|
-
</svg>
|
|
35
|
-
{/if}
|
|
36
|
-
</button>
|
|
37
|
-
</div>
|
|
38
|
-
{:else}
|
|
39
|
-
<pre {...tag.attributes}>{@render children()}</pre>
|
|
40
|
-
{/if}
|
|
41
|
-
|
|
42
|
-
<style>
|
|
43
|
-
.rf-codeblock {
|
|
44
|
-
position: relative;
|
|
45
|
-
}
|
|
46
|
-
.rf-codeblock :global(pre) {
|
|
47
|
-
margin: 0;
|
|
48
|
-
}
|
|
49
|
-
.rf-codeblock__copy {
|
|
50
|
-
position: absolute;
|
|
51
|
-
top: 0.5rem;
|
|
52
|
-
right: 0.5rem;
|
|
53
|
-
display: flex;
|
|
54
|
-
align-items: center;
|
|
55
|
-
justify-content: center;
|
|
56
|
-
width: 2rem;
|
|
57
|
-
height: 2rem;
|
|
58
|
-
border: none;
|
|
59
|
-
border-radius: var(--rf-radius-sm);
|
|
60
|
-
background: transparent;
|
|
61
|
-
color: var(--rf-color-code-text, #e2e8f0);
|
|
62
|
-
cursor: pointer;
|
|
63
|
-
opacity: 0;
|
|
64
|
-
transition: opacity 150ms ease, background-color 150ms ease;
|
|
65
|
-
}
|
|
66
|
-
.rf-codeblock:hover .rf-codeblock__copy {
|
|
67
|
-
opacity: 0.6;
|
|
68
|
-
}
|
|
69
|
-
.rf-codeblock__copy:hover {
|
|
70
|
-
opacity: 1 !important;
|
|
71
|
-
background: rgba(255, 255, 255, 0.1);
|
|
72
|
-
}
|
|
73
|
-
.rf-codeblock__copy--copied {
|
|
74
|
-
opacity: 1 !important;
|
|
75
|
-
color: var(--rf-color-success, #4ade80);
|
|
76
|
-
}
|
|
77
|
-
</style>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { SerializedTag } from '../types.js';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
|
-
|
|
5
|
-
let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<div class="rf-table-wrapper">
|
|
9
|
-
<table {...tag.attributes}>
|
|
10
|
-
{@render children()}
|
|
11
|
-
</table>
|
|
12
|
-
</div>
|