Skip to content

Commit

Permalink
Use js for generateSlugs to avoid runtime issues/extra deps
Browse files Browse the repository at this point in the history
  • Loading branch information
switz committed Jul 25, 2023
1 parent 7662c1a commit d0fcea6
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 108 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "NODE_ENV=production next build",
"start": "next",
"lint": "eslint src/pages/*.tsx src/redux/*.js src/lib/*.ts src/layouts/*.tsx src/components/*.tsx bin/*.js",
"bands": "ts-node-esm src/lib/generateSlugs.ts"
"bands": "node src/lib/generateSlugs.js"
},
"author": "Daniel Saewitz",
"license": "MIT",
Expand All @@ -36,7 +36,6 @@
"styled-jsx-plugin-stylus": "^0.0.4",
"stylus": "^0.54.8",
"thenby": "^1.3.4",
"ts-node": "^10.9.1",
"ua-parser-js": "0.7.28",
"url-loader": "^4.1.1"
},
Expand Down
7 changes: 3 additions & 4 deletions src/lib/generateSlugs.ts → src/lib/generateSlugs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import fs from 'fs';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { Artist } from '../types';
import fetch from 'isomorphic-fetch';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

fetch('https://api.relisten.net/api/v2/artists')
.then((res: Response) => res.json())
.then((json: object[]) => {
const str = json.map((artist: Artist) => `"${artist.slug}"`).join(',');
.then((res) => res.json())
.then((json) => {
const str = json.map((artist) => `"${artist.slug}"`).join(',');

fs.writeFileSync(__dirname + '/rawSlugs.ts', `export default [${str}]`);
});
Loading

0 comments on commit d0fcea6

Please sign in to comment.