Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 26 additions & 99 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions www/deno.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes aren't needed right now if #2900 is merged soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, I'll track #2900 and follow up once it's merged.👏

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@std/path": "jsr:@std/path@1",
"@std/semver": "jsr:@std/semver@1",
"@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",
"astral": "jsr:@astral/astral",
"autoprefixer": "npm:autoprefixer@10.4.17",
"cssnano": "npm:cssnano@6.0.3",
"esbuild": "npm:esbuild@0.23.1",
Expand All @@ -30,6 +31,7 @@
"fresh/dev": "../src/dev/mod.ts",
"fresh/runtime": "../src/runtime/shared.ts",
"github-slugger": "npm:github-slugger@^2.0.0",
"imagescript": "https://deno.land/x/imagescript@1.3.0/mod.ts",
"marked": "npm:marked@^14.1.2",
"marked-mangle": "npm:marked-mangle@^1.1.9",
"postcss": "npm:postcss@8.4.35",
Expand Down
26 changes: 14 additions & 12 deletions www/utils/screenshot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import puppeteer from "npm:puppeteer@24.7.2";
import { Image } from "https://deno.land/x/imagescript@1.3.0/mod.ts";
import { launch } from "astral";
import { Image } from "imagescript";

if (Deno.args.length !== 2) {
throw new Error("Usage: screenshot <url> <id>");
Expand All @@ -11,20 +11,22 @@ if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
throw new Error("Invalid URL");
}

const browser = await puppeteer.launch({
defaultViewport: { width: 1200, height: 675 },
headless: true,
});
const page = await browser.newPage();
await page.goto(url, { waitUntil: "networkidle2" });
const browser = await launch();
const page = await browser.newPage(url);
await page.waitForNetworkIdle();
const raw = await page.screenshot();

await browser.close();

// convert to jpeg
const image2x = await Image.decode(raw);
const jpeg2x = import.meta.resolve(`../static/showcase/${id}2x.jpg`);
await Deno.writeFile(jpeg2x, await image2x.encodeJPEG(80));
await Deno.writeFile(
`./www/static/showcase/${id}2x.jpg`,
await image2x.encodeJPEG(80),
);

const jpeg1x = import.meta.resolve(`../static/showcase/${id}1x.jpg`);
const image1x = image2x.resize(image2x.width / 2, Image.RESIZE_AUTO);
await Deno.writeFile(jpeg1x, await image1x.encodeJPEG(80));
await Deno.writeFile(
`./www/static/showcase/${id}1x.jpg`,
await image1x.encodeJPEG(80),
);
Loading