config.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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?.trim().toLowerCase() === "true" ? `/v${verMajor}/docs/` : "/",
  23. title: "geniURL",
  24. description: "JSON and XML REST API to search for song metadata, lyrics URL and lyrics translations via the genius.com API without requiring an API key.",
  25. theme: defaultTheme({
  26. // logo: "https://vuejs.press/images/hero.png",
  27. navbar: navbarEn,
  28. sidebar: sidebarEn,
  29. }),
  30. // @ts-ignore
  31. bundler: viteBundler(),
  32. plugins: [
  33. seoPlugin({
  34. hostname: "https://api.sv443.net",
  35. author: rootPkgJson.author,
  36. }),
  37. sitemapPlugin({
  38. hostname: "https://api.sv443.net",
  39. changefreq: "weekly",
  40. }),
  41. registerComponentsPlugin({
  42. components: componentNames.reduce((a, c) => ({ ...a, [c]: join(componentDir, `${c}.vue`) }), {}),
  43. }),
  44. ],
  45. });