diff --git a/bun.lockb b/bun.lockb index 7601486..e1065dd 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/assets/github.toml b/data/github.toml similarity index 100% rename from assets/github.toml rename to data/github.toml diff --git a/assets/tags/bug.md b/data/tags/bug.md similarity index 77% rename from assets/tags/bug.md rename to data/tags/bug.md index bb9c9ae..d805c96 100644 --- a/assets/tags/bug.md +++ b/data/tags/bug.md @@ -1,10 +1,9 @@ --- +question: Found a bug in bun? keywords: - - bug - - report - - bugs + - "bug" + - "report" + - "bugs" --- - -Found a bug in bun? - If you are unsure, first discuss your bug in <#887787428973281300> or <#995247410794217553> - [Open an issue on GitHub]() and fill out the given template diff --git a/assets/tags/bun.md b/data/tags/bun.md similarity index 76% rename from assets/tags/bun.md rename to data/tags/bun.md index f0582b4..c6ec5fc 100644 --- a/assets/tags/bun.md +++ b/data/tags/bun.md @@ -1,5 +1,8 @@ --- -keywords: [ bun, bun.sh ] +question: What is bun? +keywords: + - "bun" + - "bun.sh" --- Bun is an all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager. diff --git a/assets/tags/feature-request.md b/data/tags/feature-request.md similarity index 71% rename from assets/tags/feature-request.md rename to data/tags/feature-request.md index 2768e74..641f9f5 100644 --- a/assets/tags/feature-request.md +++ b/data/tags/feature-request.md @@ -1,10 +1,9 @@ --- +question: Any idea what to add to bun? keywords: - - feature-request - - feature - - request + - "feature-request" + - "feature" + - "request" --- - -Any idea what to add to bun? - Please consider if this is a request for bun, not for other 3rd party packages - [Open an issue on GitHub]() and fill out the given template diff --git a/assets/tags/illegal-instruction.md b/data/tags/illegal-instruction.md similarity index 81% rename from assets/tags/illegal-instruction.md rename to data/tags/illegal-instruction.md index 81ca669..7d445a4 100644 --- a/assets/tags/illegal-instruction.md +++ b/data/tags/illegal-instruction.md @@ -1,4 +1,5 @@ --- +question: "How to solve illegal instruction (core dumped) error?" keywords: - "illegal-instruction" - "core-dumped" @@ -6,9 +7,6 @@ keywords: - "core" - "illegal" --- - -**Illegal instruction - core dumped** - Update to latest version using: ```sh curl https://bun.sh/install | bash diff --git a/assets/tags/io-uring-is-not-supported.md b/data/tags/io-uring-is-not-supported.md similarity index 90% rename from assets/tags/io-uring-is-not-supported.md rename to data/tags/io-uring-is-not-supported.md index 161842d..a03579c 100644 --- a/assets/tags/io-uring-is-not-supported.md +++ b/data/tags/io-uring-is-not-supported.md @@ -1,4 +1,5 @@ --- +question: How to upgrade linux kernel? keywords: - "io-uring-is-not-supported" - "io uring" @@ -6,9 +7,6 @@ keywords: - "update" - "linux" --- - -**error: Linux kernel version doesn't support io_uring, which Bun depends on** - To fix this error, you need to update Linux kernel. If you are using the Windows Subsystem for Linux, do: **1.** Open powershell as administrator diff --git a/assets/tags/nix.md b/data/tags/nix.md similarity index 93% rename from assets/tags/nix.md rename to data/tags/nix.md index 4e54f85..40b4f44 100644 --- a/assets/tags/nix.md +++ b/data/tags/nix.md @@ -1,4 +1,5 @@ --- +question: "How to use bun on NixOS?" keywords: - "nix" - "nixos" diff --git a/assets/tags/tags.md b/data/tags/tags.md similarity index 66% rename from assets/tags/tags.md rename to data/tags/tags.md index 6791a59..ed61b71 100644 --- a/assets/tags/tags.md +++ b/data/tags/tags.md @@ -1,7 +1,7 @@ --- +question: "Where can i add new tag to bot?" keywords: - - tags - - contributing + - "tags" + - "contributing" --- - To create or update tag, check [xHyroM/bun-discord-bot#contributing-tags]() diff --git a/assets/tags/ts.md b/data/tags/ts.md similarity index 85% rename from assets/tags/ts.md rename to data/tags/ts.md index 2e6f7ff..ee0f66c 100644 --- a/assets/tags/ts.md +++ b/data/tags/ts.md @@ -1,4 +1,5 @@ --- +question: "Do i need compiler for typescript?" keywords: - "ts" - "typescript" diff --git a/assets/tags/windows.md b/data/tags/windows.md similarity index 82% rename from assets/tags/windows.md rename to data/tags/windows.md index 03f66dd..d89b542 100644 --- a/assets/tags/windows.md +++ b/data/tags/windows.md @@ -1,8 +1,8 @@ --- +question: "Where can i found windows version of bun?" keywords: - "windows" - "windows support" --- - Bun does not currently have support for Windows, so you must use WSL (Windows Subsystem for Linux). To install WSL, check [microsoft documentation]() diff --git a/package.json b/package.json index de935ca..e4f9f51 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "dependencies": { "@paperdave/logger": "^3.0.1", "discord.js": "^14.13.0", + "glob": "^10.3.3", + "gray-matter": "^4.0.3", "zlib-sync": "^0.1.8" } } diff --git a/src/index.ts b/src/index.ts index 4e9cb1f..e6c0924 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ -import "./commands" +import "./loaders/tags.ts"; +import "./commands"; import "./listeners"; import { Bubu } from "./structs/Client.ts"; diff --git a/src/loaders/tags.ts b/src/loaders/tags.ts new file mode 100644 index 0000000..544ed8a --- /dev/null +++ b/src/loaders/tags.ts @@ -0,0 +1,22 @@ +import matter from "gray-matter"; +import { readFileSync } from "node:fs"; +import { globSync as glob } from "glob"; +import { join } from "node:path"; +import { Tag } from "../structs/Tag"; + +const tags = glob(join(__dirname, "..", "..", "data", "tags", "*.md")); + +export const TAGS: Tag[] = []; + +for (const tag of tags) { + const content = readFileSync(tag); + const frontMatter = matter(content); + + TAGS.push({ + question: frontMatter.data.question, + keywords: frontMatter.data.keywords, + answer: frontMatter.content + }); +} + +console.log(TAGS); diff --git a/src/structs/Tag.ts b/src/structs/Tag.ts new file mode 100644 index 0000000..c34f029 --- /dev/null +++ b/src/structs/Tag.ts @@ -0,0 +1,6 @@ +export interface Tag { + question: string; + answer: string; + keywords: string[]; +} + diff --git a/tsconfig.json b/tsconfig.json index b406c3b..85192d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "target": "esnext", "moduleResolution": "Node", "allowImportingTsExtensions": true, + "allowSyntheticDefaultImports": true, // "bun-types" is the important part "types": ["bun-types"] }