config.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { join, dirname } from "node:path";
  2. import { fileURLToPath } from "node:url";
  3. import { readdirSync } from "node:fs";
  4. import { defineUserConfig } from "vuepress/cli";
  5. import { defaultTheme } from "@vuepress/theme-default";
  6. import { viteBundler } from "@vuepress/bundler-vite";
  7. import { seoPlugin } from "@vuepress/plugin-seo";
  8. import { sitemapPlugin } from "@vuepress/plugin-sitemap";
  9. import { registerComponentsPlugin } from "@vuepress/plugin-register-components";
  10. import "dotenv/config";
  11. import rootPkgJson from "../../package.json";
  12. import { navbarEn, sidebarEn } from "./configs/index.js";
  13. const verMajor = Number(rootPkgJson.version.split(".")![0]);
  14. const componentDir = join(dirname(fileURLToPath(import.meta.url)), "./components/");
  15. const componentNames = readdirSync(componentDir).map((p) => {
  16. const fileNameParts = p.split("/")!.at(-1).split(".");
  17. fileNameParts.pop();
  18. return fileNameParts.join(".");
  19. });
  20. export default defineUserConfig({
  21. lang: "en-US",
  22. base: process.env.HOST_HOMEPAGE === "true" ? `/v${verMajor}/docs/` : "/",
  23. title: "geniURL",
  24. description: "A simple JSON and XML REST API to search for song metadata, the lyrics URL and lyrics translations on genius.com",
  25. theme: defaultTheme({
  26. // logo: "https://vuejs.press/images/hero.png",
  27. navbar: navbarEn,
  28. sidebar: sidebarEn,
  29. }),
  30. bundler: viteBundler(),
  31. plugins: [
  32. seoPlugin({
  33. hostname: "https://api.sv443.net",
  34. author: rootPkgJson.author,
  35. }),
  36. sitemapPlugin({
  37. hostname: "https://api.sv443.net",
  38. }),
  39. registerComponentsPlugin({
  40. components: componentNames.reduce((a, c) => {
  41. a[c] = join(componentDir, `${c}.vue`);
  42. return a;
  43. }, {}),
  44. }),
  45. ],
  46. });