Download react-grid-layout/examples/util/generate.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-grid-layout/examples/util/generate.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-grid-layout/examples/util/generate.js
-
curl -L -o generate.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-grid-layout/examples/util/generate.js
1 kB
| ; | |
| const fs = require("fs"); | |
| const ejs = require("ejs"); | |
| const path = require("path"); | |
| const data = require("./vars"); | |
| const tpl = fs.readFileSync(__dirname + "/template.ejs").toString(); | |
| const version = require('../../package.json').version; | |
| const base = process.env.CONTENT_BASE; | |
| if (typeof base !== "string") { | |
| throw new Error("env CONTENT_BASE is required to be set."); | |
| } | |
| const banner = | |
| "Do not edit this file! It is generated by `generate.js` in this folder, from `template.ejs` and " + | |
| "vars.js."; | |
| data.forEach(function(datum, i) { | |
| datum.base = base.replace(/\/$/, ""); // trim trailing slash | |
| datum.index = (i).toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}); | |
| datum.banner = banner; | |
| datum.previous = data[i - 1]; | |
| datum.next = data[i + 1]; | |
| datum.version = version; | |
| }); | |
| data.forEach(function(datum, i) { | |
| const html = ejs.render(tpl, datum); | |
| fs.writeFileSync(path.resolve(__dirname, '..', `${datum.index}-${datum.source}.html`), html); | |
| }); | |