@fifthbell/brokaw 0.1.55 → 0.1.57
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.
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import Handlebars from 'handlebars';
|
|
2
2
|
import qrcode from 'qrcode-generator';
|
|
3
|
+
function buildQrCodeHtml(url) {
|
|
4
|
+
const qr = qrcode(0, 'M');
|
|
5
|
+
qr.addData(url);
|
|
6
|
+
qr.make();
|
|
7
|
+
const qrSvg = qr.createSvgTag(5, 0);
|
|
8
|
+
return `<div class="qr-container"><div class="qr-code" aria-label="QR Code">${qrSvg}</div></div>`;
|
|
9
|
+
}
|
|
10
|
+
export function registerInstagramImageHelpers() {
|
|
11
|
+
Handlebars.registerHelper('instagramQrCode', (url) => buildQrCodeHtml(url));
|
|
12
|
+
}
|
|
13
|
+
registerInstagramImageHelpers();
|
|
3
14
|
function isNodeRuntime() {
|
|
4
15
|
return typeof process !== 'undefined' && typeof process.versions?.node === 'string';
|
|
5
16
|
}
|
|
@@ -13,30 +24,13 @@ async function loadTemplateSource() {
|
|
|
13
24
|
const currentFile = fileURLToPath(import.meta.url);
|
|
14
25
|
const currentDir = pathModule.dirname(currentFile);
|
|
15
26
|
const projectRoot = pathModule.resolve(currentDir, '..');
|
|
16
|
-
const filePath = pathModule.join(projectRoot, 'src', 'templates', '
|
|
27
|
+
const filePath = pathModule.join(projectRoot, 'src', 'templates', 'templates', 'instagram-image.hbs');
|
|
17
28
|
return readFileSync(filePath, 'utf8');
|
|
18
29
|
}
|
|
19
|
-
const module = await import('./templates/
|
|
30
|
+
const module = await import('./templates/templates/instagram-image.hbs?raw');
|
|
20
31
|
return module.default;
|
|
21
32
|
}
|
|
22
33
|
const template = Handlebars.compile(await loadTemplateSource());
|
|
23
|
-
function buildQrCodeHtml(url) {
|
|
24
|
-
const qr = qrcode(0, 'M');
|
|
25
|
-
qr.addData(url);
|
|
26
|
-
qr.make();
|
|
27
|
-
const qrSvg = qr.createSvgTag(5, 0);
|
|
28
|
-
return `<div class="qr-container"><div class="qr-code" aria-label="QR Code">${qrSvg}</div></div>`;
|
|
29
|
-
}
|
|
30
|
-
function buildLogoSvg() {
|
|
31
|
-
return `<div style="color: white; width: 140px; height: 119px; display: flex; align-items: center; justify-content: end;">
|
|
32
|
-
<svg width="61" height="61" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
33
|
-
<path d="M10.268 21a2 2 0 0 0 3.464 0"></path>
|
|
34
|
-
<path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"></path>
|
|
35
|
-
<path d="M4 2C2.8 3.7 2 5.7 2 8"></path>
|
|
36
|
-
<path d="M22 8a10 10 0 0 0-2-6"></path>
|
|
37
|
-
</svg>
|
|
38
|
-
</div>`;
|
|
39
|
-
}
|
|
40
34
|
function resolveCategoryName(params) {
|
|
41
35
|
if (params.category) {
|
|
42
36
|
return params.category.toUpperCase();
|
|
@@ -53,6 +47,5 @@ export function buildInstagramImageHtml(params) {
|
|
|
53
47
|
title: params.title,
|
|
54
48
|
categoryName: resolveCategoryName(params),
|
|
55
49
|
qrCodeHtml,
|
|
56
|
-
logoSvg: buildLogoSvg(),
|
|
57
50
|
}).trim();
|
|
58
51
|
}
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { render, liveProgramPageHtml, liveProgramPageAsset, liveProgramPageFiles, fontFiles } from './renderer.node.js';
|
|
2
2
|
export type { LiveProgramFileEntry, FontFileEntry } from './renderer.node.js';
|
|
3
|
-
export { buildInstagramImageHtml, type InstagramImageTemplateParams } from './instagram-image-template.js';
|
|
3
|
+
export { buildInstagramImageHtml, registerInstagramImageHelpers, type InstagramImageTemplateParams } from './instagram-image-template.js';
|
|
4
4
|
export { outletConfig } from './outlet-config.js';
|
|
5
5
|
export { version } from './version.js';
|
|
6
6
|
export type { CanonicalDocument } from './types/canonical-article.js';
|
package/dist/renderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { render, liveProgramPageHtml, liveProgramPageAsset, liveProgramPageFiles, fontFiles } from './renderer.node.js';
|
|
2
|
-
export { buildInstagramImageHtml } from './instagram-image-template.js';
|
|
2
|
+
export { buildInstagramImageHtml, registerInstagramImageHelpers } from './instagram-image-template.js';
|
|
3
3
|
export { outletConfig } from './outlet-config.js';
|
|
4
4
|
export { version } from './version.js';
|
package/package.json
CHANGED
|
@@ -138,9 +138,20 @@
|
|
|
138
138
|
<div class="card-container">
|
|
139
139
|
<header>
|
|
140
140
|
<div class="logo-container">
|
|
141
|
-
<div class="brand-logo">
|
|
141
|
+
<div class="brand-logo" style="color: white; width: 140px; height: 119px; display: flex; align-items: center; justify-content: end;">
|
|
142
|
+
<svg width="61" height="61" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
143
|
+
<path d="M10.268 21a2 2 0 0 0 3.464 0"></path>
|
|
144
|
+
<path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"></path>
|
|
145
|
+
<path d="M4 2C2.8 3.7 2 5.7 2 8"></path>
|
|
146
|
+
<path d="M22 8a10 10 0 0 0-2-6"></path>
|
|
147
|
+
</svg>
|
|
148
|
+
</div>
|
|
142
149
|
</div>
|
|
143
|
-
{{
|
|
150
|
+
{{#if qrCodeHtml}}
|
|
151
|
+
{{{qrCodeHtml}}}
|
|
152
|
+
{{else if url}}
|
|
153
|
+
{{{instagramQrCode url}}}
|
|
154
|
+
{{/if}}
|
|
144
155
|
<div class="category-label">{{categoryName}}</div>
|
|
145
156
|
</header>
|
|
146
157
|
<main>
|