-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerateReadme.js
46 lines (39 loc) · 1.88 KB
/
generateReadme.js
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
36
37
38
39
40
41
42
43
44
45
46
// Import the necessary modules
import { promises as fs } from "fs";
import path from "path";
// Define the path for the markdown file you want to read
const IntroPath = path.join(process.cwd(), "./src/documents/wiki", "Home.md");
const QuickStartPath = path.join(process.cwd(), "./src/documents/wiki", "Quick start.md");
const AboutPath = path.join(process.cwd(), "./src/documents/wiki", "About.md");
// Define the path for the markdown file you want to generate
const outputMarkdownPath = path.join(process.cwd(), ".", "README.md");
// Function to read an existing markdown file and generate a new one
async function generateMarkdown() {
try {
// Read content from the existing markdown file
const IntroContent = await fs.readFile(IntroPath, "utf8");
const QuickStartContent = await fs.readFile(QuickStartPath, "utf8");
const AboutContent = await fs.readFile(AboutPath, "utf8");
// Combine the existing content with the new content
const combinedContent = [
"# CircuitPython Online IDE 2",
IntroContent,
"# Quick Start",
"***For More help documents, please visit our [Wiki page](https://github.com/urfdvw/circuitpython-online-ide-2/wiki/).***",
"[![Quick introduction to CircuitPython Online IDE](https://img.youtube.com/vi/kq554m21G4A/0.jpg)](https://www.youtube.com/watch?v=kq554m21G4A)",
QuickStartContent,
"# About",
AboutContent,
]
.join("\n\n")
.split("\n#")
.join("\n##");
// Write the combined content to a new markdown file
await fs.writeFile(outputMarkdownPath, combinedContent);
console.log("Markdown file generated successfully!");
} catch (err) {
console.error("Failed to generate markdown file:", err);
}
}
// Call the function to generate the markdown
generateMarkdown();