From 08dd998ca0e8b3d0bf3d9b0e69a996b502775403 Mon Sep 17 00:00:00 2001 From: Wituareard <87208350+Wituareard@users.noreply.github.com> Date: Sun, 6 Oct 2024 01:23:54 +0200 Subject: [PATCH 01/64] Index dynamic routes using Pagefind --- scripts/create-pagefind-index.ts | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/scripts/create-pagefind-index.ts b/scripts/create-pagefind-index.ts index f8e7902a..78de0e64 100644 --- a/scripts/create-pagefind-index.ts +++ b/scripts/create-pagefind-index.ts @@ -1,9 +1,31 @@ import { promises as fs } from 'fs' import * as pagefind from 'pagefind' +import type { Post } from '../src/lib/types' + +const POSTS_PATH = 'build/api/posts' +const INPUT_PATH = 'build' +const STATIC_PATH = 'static/pagefind' +const BUILD_PATH = 'build/pagefind' const { index, errors } = await pagefind.createIndex({}) if (!index) throw new Error(errors.toString()) -await index.addDirectory({ path: 'build' }) -await index.writeFiles({ outputPath: 'static/pagefind' }) -await fs.cp('static/pagefind', 'build/pagefind', { recursive: true }) +const posts: Post[] = JSON.parse(await fs.readFile(POSTS_PATH, 'utf-8')) +for (const post of posts) { + await index.addCustomRecord({ + url: '/' + post.slug, + content: post.description ?? '', + language: 'en', + meta: { + title: post.title + } + }) +} + +await index.addDirectory({ path: INPUT_PATH }) + +await index.writeFiles({ outputPath: STATIC_PATH }) + +await pagefind.close() + +await fs.cp(STATIC_PATH, BUILD_PATH, { recursive: true }) From 70e2f0988a32c62a27234788ed8b14a0bf5fb968 Mon Sep 17 00:00:00 2001 From: Wituareard <87208350+Wituareard@users.noreply.github.com> Date: Sun, 6 Oct 2024 01:29:06 +0200 Subject: [PATCH 02/64] Index title of dynamic pages using Pagefind --- scripts/create-pagefind-index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create-pagefind-index.ts b/scripts/create-pagefind-index.ts index 78de0e64..d7394546 100644 --- a/scripts/create-pagefind-index.ts +++ b/scripts/create-pagefind-index.ts @@ -14,7 +14,7 @@ const posts: Post[] = JSON.parse(await fs.readFile(POSTS_PATH, 'utf-8')) for (const post of posts) { await index.addCustomRecord({ url: '/' + post.slug, - content: post.description ?? '', + content: post.title + '. ' + (post.description ?? ''), language: 'en', meta: { title: post.title From 2828df3b91ac34a8b0688e57d1626b96dd5972b2 Mon Sep 17 00:00:00 2001 From: Wituareard <87208350+Wituareard@users.noreply.github.com> Date: Sun, 6 Oct 2024 01:49:59 +0200 Subject: [PATCH 03/64] Revert "Index title of dynamic pages using Pagefind" This reverts commit 70e2f0988a32c62a27234788ed8b14a0bf5fb968. --- scripts/create-pagefind-index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create-pagefind-index.ts b/scripts/create-pagefind-index.ts index d7394546..78de0e64 100644 --- a/scripts/create-pagefind-index.ts +++ b/scripts/create-pagefind-index.ts @@ -14,7 +14,7 @@ const posts: Post[] = JSON.parse(await fs.readFile(POSTS_PATH, 'utf-8')) for (const post of posts) { await index.addCustomRecord({ url: '/' + post.slug, - content: post.title + '. ' + (post.description ?? ''), + content: post.description ?? '', language: 'en', meta: { title: post.title From 461d1a785ea44fc93e80d67b656053bfaa18e401 Mon Sep 17 00:00:00 2001 From: Wituareard <87208350+Wituareard@users.noreply.github.com> Date: Sun, 6 Oct 2024 01:50:12 +0200 Subject: [PATCH 04/64] Revert "Index dynamic routes using Pagefind" This reverts commit 08dd998ca0e8b3d0bf3d9b0e69a996b502775403. --- scripts/create-pagefind-index.ts | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/scripts/create-pagefind-index.ts b/scripts/create-pagefind-index.ts index 78de0e64..f8e7902a 100644 --- a/scripts/create-pagefind-index.ts +++ b/scripts/create-pagefind-index.ts @@ -1,31 +1,9 @@ import { promises as fs } from 'fs' import * as pagefind from 'pagefind' -import type { Post } from '../src/lib/types' - -const POSTS_PATH = 'build/api/posts' -const INPUT_PATH = 'build' -const STATIC_PATH = 'static/pagefind' -const BUILD_PATH = 'build/pagefind' const { index, errors } = await pagefind.createIndex({}) if (!index) throw new Error(errors.toString()) +await index.addDirectory({ path: 'build' }) +await index.writeFiles({ outputPath: 'static/pagefind' }) -const posts: Post[] = JSON.parse(await fs.readFile(POSTS_PATH, 'utf-8')) -for (const post of posts) { - await index.addCustomRecord({ - url: '/' + post.slug, - content: post.description ?? '', - language: 'en', - meta: { - title: post.title - } - }) -} - -await index.addDirectory({ path: INPUT_PATH }) - -await index.writeFiles({ outputPath: STATIC_PATH }) - -await pagefind.close() - -await fs.cp(STATIC_PATH, BUILD_PATH, { recursive: true }) +await fs.cp('static/pagefind', 'build/pagefind', { recursive: true }) From 308b1c036ac5c559c99dfe638c0730bc689db544 Mon Sep 17 00:00:00 2001 From: Pato-desu Date: Sun, 6 Oct 2024 02:25:59 +0100 Subject: [PATCH 05/64] put playlist with talks instead of /learn#video --- src/posts/action.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/posts/action.md b/src/posts/action.md index 5cfd8c9c..265b3ef3 100644 --- a/src/posts/action.md +++ b/src/posts/action.md @@ -29,7 +29,6 @@ Here are some examples of what you can do. - Join or create a [local community](/communities) or [event](/events). - Join the PauseAI [Discord](https://discord.gg/2XXWXvErfA), where most of the collaboration happens. - If you want to volunteer, fill out [this form](https://airtable.com/embed/appWPTGqZmUcs3NWu/pagoxRuCai4OYJEHt/form). - - [**Donate**](/donate) to PauseAI or buy some merchandise in our [store](https://pauseai-shop.fourthwall.com/). - **Follow** our [social media channels](https://linktr.ee/pauseai) and stay updated, @@ -52,7 +51,7 @@ Here are some examples of what you can do. - **Don't work towards superintelligence**. If you have some cool idea on how we can make AI systems 10x faster, please don't build it / spread it / talk about it. We need to slow down AI development, not speed it up. - **Talk to your management and colleagues** about the risks. Get them to take an institutional position on this. -- **Hold a seminar** on AI safety at your workplace. Check out the [videos](/learn#videos) for inspiration. +- **Hold a seminar** on AI safety at your workplace. Check out [these talks and videos](https://www.youtube.com/playlist?list=PLI46NoubGtIJa0JVCBR-9CayxCOmU0EJt) for inspiration. - **Sign** the [Statement on AI Risk](https://www.safe.ai/statement-on-ai-risk). From f345db986c73bbe0db0bad1df28b9a919dd34b84 Mon Sep 17 00:00:00 2001 From: Pato-desu Date: Sun, 6 Oct 2024 02:40:10 +0100 Subject: [PATCH 06/64] added dr phil --- src/posts/press.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/posts/press.md b/src/posts/press.md index 6e2522f3..816bb4b2 100644 --- a/src/posts/press.md +++ b/src/posts/press.md @@ -38,6 +38,7 @@ If you want to create PauseAI-related material yourself, you can use our brand c ## Podcasts & Talks - [**Youtube Playlist**](https://www.youtube.com/playlist?list=PLI46NoubGtIJvSAWkC7VOmfWrLD2u1ZPA). The **more than 10 podcasts** and talks that multiple people from PauseAI participated in. Subsequent items on this list are recordings that weren't uploaded to YouTube. +- [Dr. Phil Primetime](https://www.meritplus.com/c/s/VQ2aB6Sp?episodeId=LknWbG7N&play=1): Liron Shapira went as a guest to a discussion about AI and education. - [Creatives with AI podcast](https://podcasters.spotify.com/pod/show/creativeswithai/episodes/15-AI-The-Race-Against-Time---Balancing-Progress-and-Potential-Catastrophe-with-Joep-Meinderstma-e28ln8a/a-aa9vpjp): Interview with PauseAI founder Joep Meindertsma. - [Art of AI podcast](https://spotify.link/AggzYfcj8Db): Interview with Joep Meindertsma about protesting, psychology of x-risk, AI policy. From d6b1a91a5b5a7b94f0c992567560fa3e54078da0 Mon Sep 17 00:00:00 2001 From: Wituareard <87208350+Wituareard@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:38:01 +0200 Subject: [PATCH 07/64] Cache people page (#219) --- package.json | 1 + scripts/exclude-from-edge-function.ts | 13 +++++-------- scripts/opt-in-to-caching.ts | 6 ++++++ scripts/utils.ts | 15 +++++++++++++++ src/routes/api/people/+server.ts | 5 ++++- src/routes/people/+page.ts | 5 ++++- 6 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 scripts/opt-in-to-caching.ts create mode 100644 scripts/utils.ts diff --git a/package.json b/package.json index ef396f2d..c2e20360 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build:dev": "vite build --mode development && run-s _postbuild:*", "_postbuild:pagefind": "tsx scripts/create-pagefind-index.ts", "_postbuild:exclude": "tsx scripts/exclude-from-edge-function.ts", + "_postbuild:caching": "tsx scripts/opt-in-to-caching.ts", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", diff --git a/scripts/exclude-from-edge-function.ts b/scripts/exclude-from-edge-function.ts index f8b16963..cba41276 100644 --- a/scripts/exclude-from-edge-function.ts +++ b/scripts/exclude-from-edge-function.ts @@ -1,12 +1,9 @@ -import { promises as fs } from 'fs' +import { readEdgeManifest, searchRenderFunction, writeEdgeManifest } from './utils' -const MANIFEST_PATH = '.netlify/edge-functions/manifest.json' -const EXCLUDE_PATHS = ['^/pagefind/.*$'] +const EXCLUDE_PATHS = ['^/pagefind/.*$', '^/~partytown/.*$'] -const manifest = JSON.parse(await fs.readFile(MANIFEST_PATH, 'utf-8')) -const renderFunction = manifest.functions.find( - (route: { function: string }) => route.function == 'render' -) +const manifest = await readEdgeManifest() +const renderFunction = await searchRenderFunction(manifest) if (!renderFunction.excludedPattern) renderFunction.excludedPattern = [] renderFunction.excludedPattern = EXCLUDE_PATHS.concat(renderFunction.excludedPattern) -await fs.writeFile(MANIFEST_PATH, JSON.stringify(manifest)) +await writeEdgeManifest(manifest) diff --git a/scripts/opt-in-to-caching.ts b/scripts/opt-in-to-caching.ts new file mode 100644 index 00000000..fe8bd880 --- /dev/null +++ b/scripts/opt-in-to-caching.ts @@ -0,0 +1,6 @@ +import { readEdgeManifest, searchRenderFunction, writeEdgeManifest } from './utils' + +const manifest = await readEdgeManifest() +const renderFunction = await searchRenderFunction(manifest) +renderFunction.cache = 'manual' +await writeEdgeManifest(manifest) diff --git a/scripts/utils.ts b/scripts/utils.ts new file mode 100644 index 00000000..fbb73295 --- /dev/null +++ b/scripts/utils.ts @@ -0,0 +1,15 @@ +import fs from 'fs/promises' + +const MANIFEST_PATH = '.netlify/edge-functions/manifest.json' + +export async function readEdgeManifest() { + return JSON.parse(await fs.readFile(MANIFEST_PATH, 'utf-8')) +} + +export function searchRenderFunction(manifest) { + return manifest.functions.find((route: { function: string }) => route.function == 'render') +} + +export async function writeEdgeManifest(manifest) { + await fs.writeFile(MANIFEST_PATH, JSON.stringify(manifest)) +} diff --git a/src/routes/api/people/+server.ts b/src/routes/api/people/+server.ts index 8898b9d6..3b1106ab 100644 --- a/src/routes/api/people/+server.ts +++ b/src/routes/api/people/+server.ts @@ -42,8 +42,11 @@ async function fetchAllPages(fetch: any, url: any) { return allRecords } -export async function GET({ fetch }) { +export async function GET({ fetch, setHeaders }) { const url = `https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tblZhQc49PkCz3yHd` + setHeaders({ + 'cache-control': 'public, max-age=3600' // 1 hour in seconds + }) try { const records = await fetchAllPages(fetch, url) diff --git a/src/routes/people/+page.ts b/src/routes/people/+page.ts index beaf49fa..dd34cacc 100644 --- a/src/routes/people/+page.ts +++ b/src/routes/people/+page.ts @@ -2,9 +2,12 @@ import type { Person } from '$lib/types' export const prerender = false -export const load = async ({ fetch }) => { +export const load = async ({ fetch, setHeaders }) => { const response = await fetch('api/people') const people: Person[] = await response.json() + setHeaders({ + 'cache-control': 'public, max-age=3600' // 1 hour in seconds + }) return { people: people } From c45ba31f2bda67050806efa07cdb6c2044df0b60 Mon Sep 17 00:00:00 2001 From: Wituareard <87208350+Wituareard@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:45:31 +0200 Subject: [PATCH 08/64] Revert "Cache people page (#219)", needs more testing ["Edge functions configured for caching always shadow static files that actually exist within the site."](https://docs.netlify.com/edge-functions/limits/#feature-limitations) --- package.json | 1 - scripts/exclude-from-edge-function.ts | 13 ++++++++----- scripts/opt-in-to-caching.ts | 6 ------ scripts/utils.ts | 15 --------------- src/routes/api/people/+server.ts | 5 +---- src/routes/people/+page.ts | 5 +---- 6 files changed, 10 insertions(+), 35 deletions(-) delete mode 100644 scripts/opt-in-to-caching.ts delete mode 100644 scripts/utils.ts diff --git a/package.json b/package.json index c2e20360..ef396f2d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "build:dev": "vite build --mode development && run-s _postbuild:*", "_postbuild:pagefind": "tsx scripts/create-pagefind-index.ts", "_postbuild:exclude": "tsx scripts/exclude-from-edge-function.ts", - "_postbuild:caching": "tsx scripts/opt-in-to-caching.ts", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", diff --git a/scripts/exclude-from-edge-function.ts b/scripts/exclude-from-edge-function.ts index cba41276..f8b16963 100644 --- a/scripts/exclude-from-edge-function.ts +++ b/scripts/exclude-from-edge-function.ts @@ -1,9 +1,12 @@ -import { readEdgeManifest, searchRenderFunction, writeEdgeManifest } from './utils' +import { promises as fs } from 'fs' -const EXCLUDE_PATHS = ['^/pagefind/.*$', '^/~partytown/.*$'] +const MANIFEST_PATH = '.netlify/edge-functions/manifest.json' +const EXCLUDE_PATHS = ['^/pagefind/.*$'] -const manifest = await readEdgeManifest() -const renderFunction = await searchRenderFunction(manifest) +const manifest = JSON.parse(await fs.readFile(MANIFEST_PATH, 'utf-8')) +const renderFunction = manifest.functions.find( + (route: { function: string }) => route.function == 'render' +) if (!renderFunction.excludedPattern) renderFunction.excludedPattern = [] renderFunction.excludedPattern = EXCLUDE_PATHS.concat(renderFunction.excludedPattern) -await writeEdgeManifest(manifest) +await fs.writeFile(MANIFEST_PATH, JSON.stringify(manifest)) diff --git a/scripts/opt-in-to-caching.ts b/scripts/opt-in-to-caching.ts deleted file mode 100644 index fe8bd880..00000000 --- a/scripts/opt-in-to-caching.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { readEdgeManifest, searchRenderFunction, writeEdgeManifest } from './utils' - -const manifest = await readEdgeManifest() -const renderFunction = await searchRenderFunction(manifest) -renderFunction.cache = 'manual' -await writeEdgeManifest(manifest) diff --git a/scripts/utils.ts b/scripts/utils.ts deleted file mode 100644 index fbb73295..00000000 --- a/scripts/utils.ts +++ /dev/null @@ -1,15 +0,0 @@ -import fs from 'fs/promises' - -const MANIFEST_PATH = '.netlify/edge-functions/manifest.json' - -export async function readEdgeManifest() { - return JSON.parse(await fs.readFile(MANIFEST_PATH, 'utf-8')) -} - -export function searchRenderFunction(manifest) { - return manifest.functions.find((route: { function: string }) => route.function == 'render') -} - -export async function writeEdgeManifest(manifest) { - await fs.writeFile(MANIFEST_PATH, JSON.stringify(manifest)) -} diff --git a/src/routes/api/people/+server.ts b/src/routes/api/people/+server.ts index 3b1106ab..8898b9d6 100644 --- a/src/routes/api/people/+server.ts +++ b/src/routes/api/people/+server.ts @@ -42,11 +42,8 @@ async function fetchAllPages(fetch: any, url: any) { return allRecords } -export async function GET({ fetch, setHeaders }) { +export async function GET({ fetch }) { const url = `https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tblZhQc49PkCz3yHd` - setHeaders({ - 'cache-control': 'public, max-age=3600' // 1 hour in seconds - }) try { const records = await fetchAllPages(fetch, url) diff --git a/src/routes/people/+page.ts b/src/routes/people/+page.ts index dd34cacc..beaf49fa 100644 --- a/src/routes/people/+page.ts +++ b/src/routes/people/+page.ts @@ -2,12 +2,9 @@ import type { Person } from '$lib/types' export const prerender = false -export const load = async ({ fetch, setHeaders }) => { +export const load = async ({ fetch }) => { const response = await fetch('api/people') const people: Person[] = await response.json() - setHeaders({ - 'cache-control': 'public, max-age=3600' // 1 hour in seconds - }) return { people: people } From ea9db8c9e2e7a85056adaaf4acd7d3a2aee8c123 Mon Sep 17 00:00:00 2001 From: Wituareard <87208350+Wituareard@users.noreply.github.com> Date: Sun, 6 Oct 2024 23:57:39 +0200 Subject: [PATCH 09/64] Index dynamic pages using Pagefind --- scripts/create-pagefind-index.ts | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/scripts/create-pagefind-index.ts b/scripts/create-pagefind-index.ts index f8e7902a..e52d7c47 100644 --- a/scripts/create-pagefind-index.ts +++ b/scripts/create-pagefind-index.ts @@ -1,9 +1,33 @@ -import { promises as fs } from 'fs' +import fs from 'fs' import * as pagefind from 'pagefind' +import type { Post } from '../src/lib/types' + +const POSTS_PATH = 'build/api/posts' +const INPUT_PATH = 'build' +const STATIC_PATH = 'static/pagefind' +const BUILD_PATH = 'build/pagefind' const { index, errors } = await pagefind.createIndex({}) if (!index) throw new Error(errors.toString()) -await index.addDirectory({ path: 'build' }) -await index.writeFiles({ outputPath: 'static/pagefind' }) -await fs.cp('static/pagefind', 'build/pagefind', { recursive: true }) +// Index dynamic pages +const posts: Post[] = JSON.parse(fs.readFileSync(POSTS_PATH, 'utf-8')) +for (const post of posts) { + if (fs.existsSync(`build/${post.slug}.html`)) continue + await index.addCustomRecord({ + url: '/' + post.slug, + content: post.title + '. ' + (post.description ?? ''), + language: 'en', + meta: { + title: post.title + } + }) +} + +await index.addDirectory({ path: INPUT_PATH }) + +await index.writeFiles({ outputPath: STATIC_PATH }) + +await pagefind.close() + +fs.cpSync(STATIC_PATH, BUILD_PATH, { recursive: true }) From 6b9b99498dc72ffa55d546a2257e45ab9e16fd05 Mon Sep 17 00:00:00 2001 From: Wituareard <87208350+Wituareard@users.noreply.github.com> Date: Mon, 7 Oct 2024 00:23:09 +0200 Subject: [PATCH 10/64] Fix events page layout --- src/posts/events.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/posts/events.md b/src/posts/events.md index 2bee24a1..bc5d5c8b 100644 --- a/src/posts/events.md +++ b/src/posts/events.md @@ -7,10 +7,9 @@ description: Meetings, workshops, protests, and more!