GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Share: render url on frontend · klimkin/opencode@772e185

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • function/src
      • api.ts
    • web/src/pages/s
      • [id].astro
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/function/src/api.ts‎

Copy file name to clipboardExpand all lines: packages/function/src/api.ts
-22Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { DurableObject } from "cloudflare:workers"
22
import { randomUUID } from "node:crypto"
3-
import { Base64 } from "js-base64"
43

54
type Env = {
65
SYNC_SERVER: DurableObjectNamespace<SyncServer>
@@ -184,9 +183,6 @@ export default {
184183

185184
let info
186185
const messages: Record<string, any> = {}
187-
let cost = 0
188-
const models: Set<string> = new Set()
189-
const version = "v0.1.1"
190186
data.forEach((d) => {
191187
const [root, type, ...splits] = d.key.split("/")
192188
if (root !== "session") return
@@ -197,31 +193,13 @@ export default {
197193
if (type === "message") {
198194
const [, messageID] = splits
199195
messages[messageID] = d.content
200-
201-
const assistant = d.content.metadata?.assistant
202-
if (assistant) {
203-
cost += assistant.cost
204-
models.add(assistant.modelID)
205-
}
206196
}
207197
})
208198

209-
const encodedTitle = encodeURIComponent(
210-
Base64.encode(
211-
// Convert to ASCII
212-
encodeURIComponent(
213-
// Truncate to fit S3's max key size
214-
info.title.substring(0, 700),
215-
),
216-
),
217-
)
218-
const encodedCost = encodeURIComponent(`$${cost.toFixed(2)}`)
219-
220199
return new Response(
221200
JSON.stringify({
222201
info,
223202
messages,
224-
ogImage: `https://social-cards.sst.dev/opencode-share/${encodedTitle}.png?cost=${encodedCost}&model=${Array.from(models).join(",")}&version=${version}&id=${id}`,
225203
}),
226204
{
227205
headers: { "Content-Type": "application/json" },
Collapse file

‎packages/web/src/pages/s/[id].astro‎

Copy file name to clipboardExpand all lines: packages/web/src/pages/s/[id].astro
+25-3Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import { Base64 } from "js-base64";
23
import config from "virtual:starlight/user-config";
34
45
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
@@ -10,14 +11,35 @@ const { id } = Astro.params;
1011
const res = await fetch(`${apiUrl}/share_data?id=${id}`);
1112
const data = await res.json();
1213
13-
const title = data.info.title;
14-
const ogImage = data.ogImage;
14+
let cost = 0;
15+
const models: Set<string> = new Set();
16+
const version = "v0.1.1";
17+
Object.values(data.messages).forEach((d) => {
18+
const assistant = d.metadata?.assistant;
19+
if (assistant) {
20+
cost += assistant.cost;
21+
models.add(assistant.modelID);
22+
}
23+
});
24+
25+
const encodedTitle = encodeURIComponent(
26+
Base64.encode(
27+
// Convert to ASCII
28+
encodeURIComponent(
29+
// Truncate to fit S3's max key size
30+
data.info.title.substring(0, 700),
31+
)
32+
)
33+
);
34+
const encodedCost = encodeURIComponent(`$${cost.toFixed(2)}`);
35+
36+
const ogImage = `https://social-cards.sst.dev/opencode-share/${encodedTitle}.png?cost=${encodedCost}&model=${Array.from(models).join(",")}&version=${version}&id=${id}`;
1537
1638
---
1739
<StarlightPage
1840
hasSidebar={false}
1941
frontmatter={{
20-
title: title,
42+
title: data.info.title,
2143
pagefind: false,
2244
template: "splash",
2345
tableOfContents: false,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.