@refrakt-md/svelte 0.9.4 → 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.4",
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.4",
31
- "@refrakt-md/transform": "0.9.4",
32
- "@refrakt-md/types": "0.9.4"
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}>`;
@@ -108,30 +108,54 @@
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
- {#if page.seo?.og.image}
121
- <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} />
122
125
  <meta name="twitter:card" content="summary_large_image" />
126
+ <meta name="twitter:image" content={ogImage} />
127
+ {:else}
128
+ <meta name="twitter:card" content="summary" />
123
129
  {/if}
124
130
  {#if page.seo?.og.url}
125
- <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} />
126
134
  {/if}
127
135
  {#if page.seo?.og.type}
128
136
  <meta property="og:type" content={page.seo.og.type} />
129
137
  {/if}
138
+ <meta property="og:site_name" content={theme.manifest.siteName ?? 'refrakt.md'} />
130
139
  {#if page.seo}
131
140
  {#each page.seo.jsonLd as schema}
132
141
  {@html `<script type="application/ld+json">${JSON.stringify(schema)}</script>`}
133
142
  {/each}
134
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}
135
159
  </svelte:head>
136
160
 
137
161
  {#key page.url}