advent-of-code/_templates/riddle/new/index.js

25 lines
558 B
JavaScript
Raw Normal View History

2023-11-02 00:23:17 +01:00
const { default: axios } = require('axios')
async function getInput(year, day) {
const { data } = await axios({
url: `https://adventofcode.com/${year}/day/${day}/input`,
headers: {
Cookie: `session=${process.env.TOKEN};`,
},
})
return data
}
module.exports = {
params: async ({ args }) => {
2023-11-18 17:06:39 +01:00
const day = args.day.toString().padStart(2, '0') // Padded
return {
...args,
id: `${args.year}-${day}`,
dir: `./${args.year}/${day}`,
input: await getInput(args.year, parseInt(day)),
day,
}
2023-11-02 00:23:17 +01:00
},
}