Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 1a73a0b

Browse files
committed
update asset generation
1 parent 87a4f9c commit 1a73a0b

File tree

5 files changed

+205
-12
lines changed

5 files changed

+205
-12
lines changed

.github/workflows/generate-images.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Generate Programming Images
22

33
on:
44
schedule:
5-
- cron: "0 0 * * *"
5+
- cron: "0 * * * *"
66
workflow_dispatch:
77

88
jobs:
@@ -23,7 +23,7 @@ jobs:
2323
run: yarn install
2424

2525
- name: Generate images
26-
run: yarn scripts:generate-images
26+
run: yarn scripts:generator
2727

2828
- name: Commit updates
2929
uses: EndBug/add-and-commit@v9

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint",
10-
"scripts:generate-images": "ts-node src/scripts/generate-images",
11-
"scripts:generate": "ts-node src/scripts/generate"
10+
"scripts:generator": "ts-node src/scripts/generate-images",
11+
"scripts:generate": "ts-node src/scripts/generate",
1212
},
1313
"dependencies": {
1414
"@ethersproject/providers": "^5.7.1",
@@ -18,7 +18,8 @@
1818
"next": "12.3.1",
1919
"next-api-og-image": "^4.3.0",
2020
"react": "18.2.0",
21-
"react-dom": "18.2.0"
21+
"react-dom": "18.2.0",
22+
"slugify": "^1.6.5"
2223
},
2324
"devDependencies": {
2425
"@types/node": "18.7.18",

src/scripts/generate-images.ts

+29-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fetch from 'cross-fetch'
22
import { APP_URL, GetBaseUri } from 'utils/constants'
33
import { getDay } from 'utils/generator'
44
import fs from 'fs'
5+
import slugify from'slugify'
56

67
Run()
78

@@ -15,13 +16,39 @@ async function Run() {
1516
console.log(body.data.length, 'sessions')
1617

1718
for (let i = 0; i < body.data.length; i++) {
18-
await GenerateImages(body.data[i])
19+
await GenerateAssets(body.data[i])
20+
await GenerateCopy(body.data[i])
1921
}
2022

2123
console.log('Done')
2224
}
2325

24-
export async function GenerateImages(session: any) {
26+
export async function GenerateCopy(session: any) {
27+
const day = getDay(session.start)
28+
const room = session.room.name
29+
const text = `Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more.
30+
https://archive.devcon.org/archive/watch/6/${slugify(session.title.toLowerCase(), { strict: true })}/index
31+
32+
${session.description}
33+
34+
Speaker(s): ${session.speakers.map((i: any) => i.name).join(', ')}
35+
${session.expertise ? `Skill level: ${session.expertise}\n` : ''}Track: ${session.track}
36+
Keywords: ${session.tags}
37+
38+
Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum
39+
Learn more about devcon: https://www.devcon.org/
40+
Learn more about ethereum: https://ethereum.org/
41+
42+
Devcon is the Ethereum conference for developers, researchers, thinkers, and makers.
43+
Devcon 6 was held in Bogotá, Colombia on Oct 11 - 14, 2022.
44+
Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/`
45+
46+
const dirName = `./generated/${day}/${room}`
47+
fs.mkdir(dirName, { recursive: true }, () => '')
48+
fs.writeFile(`${dirName}/${session.id}_youtube.txt`, text, () => '')
49+
}
50+
51+
export async function GenerateAssets(session: any) {
2552
setTimeout(async () => {
2653
console.log('PROCESSING', session.id, 'social')
2754
await GenerateImage(session, 'og')

src/scripts/generate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fetch from 'cross-fetch'
22
import { APP_URL, GetBaseUri } from 'utils/constants'
3-
import { GenerateImages } from './generate-images'
3+
import { GenerateAssets } from './generate-images'
44

55
Run()
66

@@ -18,7 +18,7 @@ async function Run() {
1818
const session = body.data.find((i: any) => i.id === sessionId)
1919
if (!session) return console.warn('Session not found')
2020

21-
await GenerateImages(session)
21+
await GenerateAssets(session)
2222

2323
console.log('Done')
2424
}

0 commit comments

Comments
 (0)