Skip to content

Commit c8eea7a

Browse files
committed
feat: update deps, support video tags
1 parent f103135 commit c8eea7a

File tree

8 files changed

+1008
-1619
lines changed

8 files changed

+1008
-1619
lines changed

package-lock.json

Lines changed: 955 additions & 1586 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,34 @@
2121
"postinstall": "symlink-dir node_modules/.astro/.astrotion/static public/static"
2222
},
2323
"dependencies": {
24-
"@astrojs/rss": "^4.0.11",
25-
"@astrojs/sitemap": "^3.4.0",
24+
"@astrojs/rss": "^4.0.13",
25+
"@astrojs/sitemap": "^3.6.0",
2626
"@resvg/resvg-js": "^2.6.2",
27-
"@tailwindcss/vite": "^4.1.8",
28-
"astro": "^5.8.1",
27+
"@tailwindcss/vite": "^4.1.16",
28+
"astro": "^5.15.1",
2929
"astro-analytics": "^2.7.0",
3030
"astro-google-fonts-optimizer": "^0.2.2",
3131
"astro-robots-txt": "^1.0.0",
3232
"date-fns": "^4.1.0",
3333
"ezog": "^0.4.0",
34-
"katex": "^0.16.22",
35-
"mermaid": "^11.6.0",
36-
"notiondown": "^0.1.8",
34+
"katex": "^0.16.25",
35+
"mermaid": "^11.12.1",
36+
"notiondown": "^0.2.2",
3737
"prismjs": "^1.30.0",
38-
"sharp": "^0.34.2",
39-
"tailwindcss": "^4.1.8"
38+
"sharp": "^0.34.4",
39+
"tailwindcss": "^4.1.16"
4040
},
4141
"devDependencies": {
4242
"@types/katex": "^0.16.7",
43-
"@types/node": "^22.15.29",
43+
"@types/node": "^24.9.1",
4444
"@types/prismjs": "^1.26.5",
45-
"eslint": "^9.28.0",
45+
"eslint": "^9.38.0",
4646
"eslint-config-reearth": "^0.3.8",
47-
"eslint-plugin-astro": "^1.3.1",
48-
"prettier": "^3.5.3",
47+
"eslint-plugin-astro": "^1.4.0",
48+
"prettier": "^3.6.2",
4949
"prettier-plugin-astro": "^0.14.1",
50-
"symlink-dir": "^6.0.5",
51-
"typescript": "^5.8.3",
52-
"vitest": "^3.2.0"
50+
"symlink-dir": "^9.0.0",
51+
"typescript": "^5.9.3",
52+
"vitest": "^4.0.4"
5353
}
5454
}

src/config-default.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ const config: Config = {
9191
operator: "on_or_before",
9292
value: "now"
9393
}
94-
},
95-
properties: {
96-
title: "Page",
9794
}
9895
}
9996
};

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { default } from "./customization/config";
22

33
export const auth = import.meta.env.NOTION_API_SECRET;
4-
export const databaseId = import.meta.env.DATABASE_ID;
4+
export const dataSourceId = import.meta.env.DATA_SOURCE_ID;
55
export const debug = !!import.meta.env.DEBUG;
66
export const site = import.meta.env.SITE || "http://localhost:3000";

src/integrations/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import child_process from "node:child_process";
22
import fs from "node:fs";
3+
import path from "node:path";
34

45
import type { AstroIntegration } from "astro";
56

@@ -8,10 +9,33 @@ import { ASSET_DIR, CACHE_DIR_ASSETS } from "../constants";
89
export default (): AstroIntegration => ({
910
name: "astrotion",
1011
hooks: {
12+
"astro:config:setup": async ({ command }) => {
13+
fs.mkdirSync(CACHE_DIR_ASSETS, { recursive: true });
14+
15+
// In dev mode, create symlink to public directory
16+
if (command === "dev") {
17+
const publicAssetDir = path.join("public", ASSET_DIR);
18+
19+
// Remove existing symlink or directory
20+
if (fs.existsSync(publicAssetDir)) {
21+
fs.rmSync(publicAssetDir, { recursive: true });
22+
console.log(`astrotion: removed existing ${publicAssetDir}`);
23+
}
24+
25+
// Create symlink
26+
const relativeTarget = path.relative(
27+
path.dirname(publicAssetDir),
28+
CACHE_DIR_ASSETS
29+
);
30+
fs.symlinkSync(relativeTarget, publicAssetDir, "dir");
31+
console.log(`astrotion: created symlink ${publicAssetDir} -> ${CACHE_DIR_ASSETS}`);
32+
}
33+
},
1134
"astro:build:start": async () => {
1235
fs.mkdirSync(CACHE_DIR_ASSETS, { recursive: true });
1336
},
1437
"astro:build:done": async ({ dir }) => {
38+
// only triggerd in build mode
1539
const outDir = new URL(ASSET_DIR, dir.href).pathname;
1640
fs.mkdirSync(outDir, { recursive: true });
1741

src/notion.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { Client, downloadImages, downloadImagesWithRetry, type Post } from "notiondown";
22

3-
import config, { auth, databaseId, debug } from "./config";
3+
import config, { auth, dataSourceId, debug } from "./config";
44
import { ASSET_DIR, CACHE_DIR_ASSETS, CACHE_DIR_NOTION } from "./constants";
55
import { postUrl } from "./utils";
66

77
const pageSize = config.postsPerPage ?? 20;
88

9-
if (!auth || !databaseId) {
10-
throw new Error("NOTION_API_SECRET and DATABASE_ID environment variables must be set.");
9+
if (!auth || !dataSourceId) {
10+
throw new Error("NOTION_API_SECRET and DATA_SOURCE_ID environment variables must be set.");
1111
}
1212

1313
const client = new Client({
1414
...config.notiondown,
1515
auth,
16-
databaseId,
16+
dataSourceId,
1717
cacheDir: CACHE_DIR_NOTION,
18-
imageDir: "/" + ASSET_DIR,
18+
assetsDir: "/" + ASSET_DIR,
1919
debug,
2020
internalLink: (post) => postUrl(post.slug),
2121
});
@@ -69,17 +69,17 @@ export async function getPostOnly(slug: string) {
6969
}
7070

7171
export async function getPost(slug: string) {
72-
const { database, posts, images } = await client.getDatabaseAndAllPosts();
72+
const { database, posts, assets } = await client.getDatabaseAndAllPosts();
7373
const post = posts.find((p) => p.slug === slug);
7474
if (!post) {
7575
throw new Error(`Post with slug "${slug}" not found.`);
7676
}
7777

7878
const content = await client.getPostContent(post.id);
79-
for (const [key, value] of content.images?.entries() || []) {
80-
images.set(key, value);
79+
for (const [key, value] of content.assets?.entries() || []) {
80+
assets.set(key, value);
8181
}
82-
await donwloadImages(images, post.id);
82+
await donwloadImages(assets, post.id);
8383

8484
return {
8585
post,

src/pages/posts/[slug].webp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ export const GET: APIRoute<Props> = async ({ params }) => {
6868
);
6969

7070
const webp = await sharp(image).webp().toBuffer();
71-
return new Response(webp.buffer);
71+
return new Response(new Uint8Array(webp));
7272
};

vitest.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
/// <reference types="vitest" />
2-
import { getViteConfig } from "astro/config";
1+
import { defineConfig } from "vitest/config";
32

4-
export default getViteConfig({
3+
export default defineConfig({
54
test: {},
65
});

0 commit comments

Comments
 (0)