@refrakt-md/svelte 0.9.5 → 0.9.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/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.5",
4
+ "version": "0.9.6",
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.5",
31
- "@refrakt-md/transform": "0.9.5",
32
- "@refrakt-md/types": "0.9.5"
30
+ "@refrakt-md/behaviors": "0.9.6",
31
+ "@refrakt-md/transform": "0.9.6",
32
+ "@refrakt-md/types": "0.9.6"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "svelte": "^5.0.0"
@@ -22,7 +22,7 @@
22
22
  const result: Record<string, any> = {};
23
23
  for (const [k, v] of Object.entries(attrs)) {
24
24
  if (v === undefined || v === null || v === false) continue;
25
- result[k] = v === true ? '' : String(v);
25
+ result[k] = v === true ? true : String(v);
26
26
  }
27
27
  return result;
28
28
  }
@@ -36,7 +36,7 @@
36
36
  * outside the SVG namespace context during client-side navigation. */
37
37
  function svgToHtml(tag: SerializedTag): string {
38
38
  const attrs = Object.entries(htmlAttrs(tag.attributes))
39
- .map(([k, v]) => ` ${k}="${escapeAttr(v)}"`)
39
+ .map(([k, v]) => v === true ? ` ${k}` : ` ${k}="${escapeAttr(String(v))}"`)
40
40
  .join('');
41
41
  const children = tag.children.map(child => {
42
42
  if (typeof child === 'string') return escapeAttr(child);
@@ -61,7 +61,7 @@
61
61
  if (n.name === 'svg') return svgToHtml(n);
62
62
 
63
63
  const attrs = Object.entries(htmlAttrs(n.attributes))
64
- .map(([k, v]) => ` ${k}="${escapeAttr(v)}"`)
64
+ .map(([k, v]) => v === true ? ` ${k}` : ` ${k}="${escapeAttr(String(v))}"`)
65
65
  .join('');
66
66
 
67
67
  if (VOID_ELEMENTS.has(n.name)) return `<${n.name}${attrs}>`;
@@ -119,16 +119,18 @@
119
119
  {:else if page.description}
120
120
  <meta name="description" content={page.description} />
121
121
  {/if}
122
- {#if page.seo?.og.image}
123
- <meta property="og:image" content={page.seo.og.image} />
122
+ {#if page.seo?.og.image || theme.manifest.defaultImage}
123
+ {@const ogImage = page.seo?.og.image ?? ((theme.manifest.baseUrl ?? '') + theme.manifest.defaultImage)}
124
+ <meta property="og:image" content={ogImage} />
124
125
  <meta name="twitter:card" content="summary_large_image" />
125
- <meta name="twitter:image" content={page.seo.og.image} />
126
+ <meta name="twitter:image" content={ogImage} />
126
127
  {:else}
127
128
  <meta name="twitter:card" content="summary" />
128
129
  {/if}
129
130
  {#if page.seo?.og.url}
130
- <link rel="canonical" href={page.seo.og.url} />
131
- <meta property="og:url" content={page.seo.og.url} />
131
+ {@const absoluteUrl = (theme.manifest.baseUrl ?? '') + page.seo.og.url}
132
+ <link rel="canonical" href={absoluteUrl} />
133
+ <meta property="og:url" content={absoluteUrl} />
132
134
  {/if}
133
135
  {#if page.seo?.og.type}
134
136
  <meta property="og:type" content={page.seo.og.type} />
@@ -139,6 +141,21 @@
139
141
  {@html `<script type="application/ld+json">${JSON.stringify(schema)}</script>`}
140
142
  {/each}
141
143
  {/if}
144
+ {#if theme.manifest.baseUrl}
145
+ {@html `<script type="application/ld+json">${JSON.stringify({
146
+ '@context': 'https://schema.org',
147
+ '@type': 'WebSite',
148
+ name: theme.manifest.siteName ?? theme.manifest.name,
149
+ url: theme.manifest.baseUrl
150
+ })}</script>`}
151
+ {@html `<script type="application/ld+json">${JSON.stringify({
152
+ '@context': 'https://schema.org',
153
+ '@type': 'Organization',
154
+ name: theme.manifest.siteName ?? theme.manifest.name,
155
+ url: theme.manifest.baseUrl,
156
+ ...(theme.manifest.logo ? { logo: theme.manifest.baseUrl + theme.manifest.logo } : {})
157
+ })}</script>`}
158
+ {/if}
142
159
  </svelte:head>
143
160
 
144
161
  {#key page.url}