-
Notifications
You must be signed in to change notification settings - Fork 17
/
replace-content-ids.ts
35 lines (24 loc) · 1.01 KB
/
replace-content-ids.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import fs from 'fs'
import { v4 as uuid } from 'uuid'
import { logger } from './logger'
import { content } from './app/src/resources/translations'
const localeToUpdate = ''
const outputFilepath = `./app/src/resources/translations/content/${localeToUpdate}.ts`
const replaceContentIds = () => {
const updatedContent = { ...content[localeToUpdate] }
let contentString = JSON.stringify(updatedContent)
// Only the keys which have .allIds
const keys = ['articles', 'categories', 'subCategories', 'quizzes', 'didYouKnows', 'videos']
keys.forEach((key) => {
updatedContent[key]?.allIds.forEach((id) => {
contentString = contentString.replaceAll(id, uuid())
})
})
const outputString = `
import { StaticContent } from '../../../types'
export const ${localeToUpdate}: StaticContent = ${contentString}`
fs.writeFileSync(outputFilepath, outputString)
}
// ========================= Execute ========================= //
// replaceContentIds()
logger('===== EDIT THIS FILE BEFORE EXECUTING IT =====')