liveog 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,21 @@
1
+ export interface Look {
2
+ /** Background, text and quiet-text colours: hex, rgb(), hsl() or oklch(). */
3
+ bg?: string;
4
+ fg?: string;
5
+ muted?: string;
6
+ /** A CSS font-family list. */
7
+ font?: string;
8
+ /** The site's mark as inline SVG, shown before the site's name (or alone). Your own file: it is not cleaned. */
9
+ mark?: string;
10
+ }
11
+ export interface CoverWords {
12
+ title: string;
13
+ site?: string;
14
+ line?: string;
15
+ /** A word or two, top right: "Live", "Sold", "Friday 8pm". */
16
+ tag?: string;
17
+ /** A picture for the bottom right, as inline SVG drawn in currentColor. Your own file: it is not cleaned. */
18
+ art?: string;
19
+ }
20
+ /** The HTML of a 1200 x 630 cover, ready for draw(). */
21
+ export declare function coverHtml(w: CoverWords, look?: Look): string;
@@ -0,0 +1,35 @@
1
+ // A default cover, as an HTML page drawn at 1200 x 630. One grid on even 96px sides: the site (or
2
+ // its mark) top left, a short tag top right, the title and a quiet line bottom left, and a
3
+ // picture bottom right whose foot sits on the line's. One font, two weights, three sizes.
4
+ // Black, white and grey unless you give it a look.
5
+ import { esc } from './og.js';
6
+ const COLOR = /^(#[0-9a-f]{3,8}|(rgb|rgba|hsl|hsla|oklch|oklab)\([0-9a-z.,%/ +-]{1,60}\)|[a-z]{3,20})$/i;
7
+ const FONT = /^[\w\s,"'.-]{1,200}$/;
8
+ const pick = (x, ok, d) => (x && ok.test(x.trim()) ? x.trim() : d);
9
+ const SANS = 'Inter, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif';
10
+ /** The HTML of a 1200 x 630 cover, ready for draw(). */
11
+ export function coverHtml(w, look = {}) {
12
+ const bg = pick(look.bg, COLOR, '#0a0a0a');
13
+ const fg = pick(look.fg, COLOR, '#f2f2f2');
14
+ const muted = pick(look.muted, COLOR, '#8a8a8a');
15
+ const font = pick(look.font, FONT, SANS);
16
+ const n = w.title.length;
17
+ const size = n <= 16 ? 96 : n <= 30 ? 80 : n <= 56 ? 62 : 50;
18
+ const site = look.mark || w.site ? `<div class="site">${look.mark ?? ''}${w.site ? `<span>${esc(w.site)}</span>` : ''}</div>` : '';
19
+ return `<!doctype html>
20
+ <html><head><meta charset="utf-8"><style>
21
+ html, body { margin: 0; width: 1200px; height: 630px; overflow: hidden; background: ${bg}; color: ${fg};
22
+ font-family: ${font}; -webkit-font-smoothing: antialiased; }
23
+ .c { position: absolute; inset: 80px 96px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; column-gap: 64px; }
24
+ .site { grid-area: 1 / 1; display: flex; align-items: center; gap: 16px; font-size: 34px; line-height: 44px; font-weight: 600; letter-spacing: -.03em; }
25
+ .site svg { display: block; height: 44px; width: auto; fill: currentColor; }
26
+ .tag { grid-area: 1 / 2; justify-self: end; align-self: center; font-size: 22px; line-height: 1; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: ${muted}; }
27
+ .words { grid-area: 2 / 1; align-self: end; min-width: 0; }
28
+ h1 { margin: 0; font-size: ${size}px; line-height: 1.06; font-weight: 500; letter-spacing: -.035em;
29
+ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
30
+ p { margin: 24px 0 0; font-size: 34px; line-height: 44px; color: ${muted}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
31
+ .art { grid-area: 2 / 2; align-self: end; height: 300px; }
32
+ .art svg { display: block; height: 100%; width: auto; }
33
+ </style></head><body><div class="c">${site}${w.tag ? `<div class="tag">${esc(w.tag)}</div>` : ''}<div class="words"><h1>${esc(w.title)}</h1>${w.line ? `<p>${esc(w.line)}</p>` : ''}</div>${w.art ? `<div class="art">${w.art}</div>` : ''}</div></body></html>
34
+ `;
35
+ }
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "liveog",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Link previews that stay current: Open Graph tags, covers drawn by a browser you already run, versioned cover addresses, privacy per link kind.",
5
+ "keywords": [
6
+ "open graph",
7
+ "og",
8
+ "link preview",
9
+ "twitter card",
10
+ "og image",
11
+ "mcp"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "Bilal Abraham",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/bilal-abraham/liveog.git"
18
+ },
19
+ "homepage": "https://bilal-abraham.github.io/liveog/",
20
+ "bugs": "https://github.com/bilal-abraham/liveog/issues",
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ },
27
+ "./browser": {
28
+ "types": "./dist/browser.d.ts",
29
+ "default": "./dist/browser.js"
30
+ },
31
+ "./draw": {
32
+ "types": "./dist/draw.d.ts",
33
+ "default": "./dist/draw.js"
34
+ },
35
+ "./study": {
36
+ "types": "./dist/study.d.ts",
37
+ "default": "./dist/study.js"
38
+ }
39
+ },
40
+ "bin": {
41
+ "liveog": "dist/cli.js"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "!dist/**/*.test.*"
46
+ ],
47
+ "engines": {
48
+ "node": ">=22"
49
+ },
50
+ "scripts": {
51
+ "build": "rm -rf dist && tsc",
52
+ "test": "npm run build && node --test 'dist/*.test.js'",
53
+ "prepublishOnly": "npm test"
54
+ },
55
+ "devDependencies": {
56
+ "@types/node": "22.20.5",
57
+ "typescript": "7.0.2"
58
+ }
59
+ }