nuxt.config.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. import axios from "axios";
  2. import { getNativeName } from "language-flag-colors";
  3. export default async function () {
  4. return {
  5. rootDir: "./",
  6. srcDir: "./src",
  7. head: {
  8. titleTemplate: "%s - PreMiD",
  9. link: [
  10. {
  11. rel: "icon",
  12. type: "image/x-icon",
  13. href: "/assets/meta/favicon.ico"
  14. },
  15. {
  16. rel: "icon",
  17. type: "image/x-icon",
  18. href: "/assets/meta/favicon-32x32.png"
  19. },
  20. {
  21. rel: "icon",
  22. type: "image/x-icon",
  23. href: "/assets/meta/favicon-32x32.png"
  24. }
  25. ],
  26. meta: [
  27. { charset: "utf-8" },
  28. { name: "viewport", content: "width=device-width, initial-scale=1" },
  29. { name: "PreMiD_Presence", content: "PreMiD" },
  30. {
  31. hid: "theme-color",
  32. name: "theme-color",
  33. content: "#7289DA"
  34. },
  35. {
  36. hid: "description",
  37. name: "description",
  38. content:
  39. "PreMiD is a simple, configurable utility that allows you to show what you're doing on the web in your Discord now playing status."
  40. },
  41. /* Twitter */
  42. {
  43. hid: "twitter:card",
  44. property: "twitter:card",
  45. content: "summary"
  46. },
  47. {
  48. hid: "twitter:url",
  49. property: "twitter:url",
  50. content: "https://premid.app"
  51. },
  52. {
  53. hid: "twitter:description",
  54. property: "twitter:description",
  55. content:
  56. "PreMiD is a simple, configurable utility that allows you to show what you're doing on the web in your Discord now playing status."
  57. },
  58. {
  59. hid: "twitter:image",
  60. property: "twitter:image",
  61. content: "https://premid.app/assets/images/logo.png"
  62. },
  63. /* Open-Graph */
  64. {
  65. hid: "og:site_name",
  66. property: "og:site_name",
  67. content: "PreMiD"
  68. },
  69. {
  70. hid: "og:title",
  71. property: "og:title",
  72. content: "PreMiD"
  73. },
  74. {
  75. hid: "og:description",
  76. property: "og:description",
  77. content:
  78. "PreMiD is a simple, configurable utility that allows you to show what you're doing on the web in your Discord now playing status."
  79. },
  80. {
  81. hid: "og:image",
  82. property: "og:image",
  83. content: "https://premid.app/assets/images/logo.png"
  84. }
  85. ],
  86. script: [
  87. {
  88. hid: "statuspage",
  89. src: "https://t8yhzkqt8q6g.statuspage.io/embed/script.js",
  90. async: true
  91. }
  92. ]
  93. },
  94. fontLoader: {
  95. url: {
  96. local: "/assets/fonts/FontAwesome/all.css",
  97. google:
  98. "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap"
  99. },
  100. prefetch: {
  101. hid: "font-prefetch"
  102. },
  103. preconnect: {
  104. hid: "font-preconnect",
  105. crossorigin: "anonymous"
  106. },
  107. preload: {
  108. hid: "font-preload"
  109. }
  110. },
  111. auth: {
  112. redirect: {
  113. login: "/login",
  114. logout: "/",
  115. callback: "/callback",
  116. home: "/"
  117. },
  118. strategies: {
  119. local: false,
  120. discord: {
  121. _scheme: "oauth2",
  122. authorization_endpoint: "https://discordapp.com/api/oauth2/authorize",
  123. userinfo_endpoint: "https://discordapp.com/api/users/@me",
  124. scope: ["identify"],
  125. client_id: "503557087041683458"
  126. }
  127. }
  128. },
  129. publicRuntimeConfig: {
  130. axios: {
  131. browserBaseURL: process.env.BROWSER_BASE_URL
  132. },
  133. privateRuntimeConfig: {
  134. axios: {
  135. baseURL: process.env.BASE_URL
  136. }
  137. }
  138. },
  139. axios: {
  140. baseURL: "https://api.premid.app",
  141. retry: { retries: 3 },
  142. credentials: false
  143. },
  144. loading: "~/components/Loader.vue",
  145. buildModules: [
  146. "nuxt-font-loader",
  147. "@nuxt/typescript-build",
  148. ["@nuxtjs/google-analytics", { id: "UA-129058596-1" }]
  149. ],
  150. components: true,
  151. css: ["~stylesheets/root.scss"],
  152. image: {
  153. provider: "ipx",
  154. ipx: {
  155. modifiers: {
  156. loading: "lazy",
  157. format: "webp"
  158. }
  159. }
  160. },
  161. modules: [
  162. "@nuxt/image",
  163. [
  164. "@nuxtjs/google-adsense",
  165. {
  166. id: "ca-pub-1575460061917202",
  167. tag: "adsense",
  168. onPageLoad: true
  169. }
  170. ],
  171. "@nuxtjs/auth",
  172. [
  173. "@nuxtjs/i18n",
  174. {
  175. strategy: "no_prefix",
  176. defaultLocale: "en",
  177. locales: await getAvailableLocales(),
  178. detectBrowserLanguage: {
  179. fallbackLocale: "en"
  180. },
  181. lazy: true,
  182. langDir: "./",
  183. vueI18n: {
  184. fallbackLocale: "en",
  185. silentTranslationWarn: true
  186. }
  187. }
  188. ],
  189. "@nuxtjs/axios"
  190. ],
  191. plugins: [
  192. "~/plugins/graphqlBase.js",
  193. { src: "~/plugins/Anime.js", mode: "client" },
  194. { src: "~/plugins/Axios.js", mode: "client" },
  195. { src: "~/plugins/Tippy.js", mode: "client" },
  196. { src: "~/plugins/Pagination.js", mode: "client" },
  197. { src: "~/plugins/Carousel.js", mode: "client" },
  198. { src: "~/plugins/Scrollmagic.js", mode: "client" },
  199. { src: "~/plugins/Modal.js", mode: "client" }
  200. ],
  201. build: {
  202. ssr: true
  203. },
  204. serverMiddleware: [
  205. {
  206. path: "/_ipx",
  207. handler: "~/serverMiddleware/ipx.ts"
  208. }
  209. ]
  210. };
  211. }
  212. async function getAvailableLocales() {
  213. const languageCodes = (
  214. await axios({
  215. url: process.env.BASE_URL
  216. ? process.env.BASE_URL + "/v3"
  217. : "https://api.premid.app/v3",
  218. method: "POST",
  219. data: {
  220. query: `
  221. {
  222. langFiles(project:"website") {
  223. lang
  224. }
  225. }
  226. `
  227. }
  228. })
  229. ).data.data.langFiles.flatMap(({ lang }) => [lang]);
  230. return languageCodes
  231. .map(lang => {
  232. return {
  233. code: lang,
  234. name: getNativeName(lang.replace("_", "-")),
  235. file: "fetchLocale.js"
  236. };
  237. })
  238. .sort((a, b) => {
  239. if (a.name < b.name) return -1;
  240. if (a.name > b.name) return 1;
  241. return 0;
  242. });
  243. }