import config from './config'

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  app: {
    head: {
      htmlAttrs: {
        lang: config.locale || 'en',
      },
      link: [
        {
          rel: 'icon',
          type: 'image/x-icon',
          href: '/favicon.ico',
        },
      ],
      meta: [
        {
          charset: 'utf-8',
        },
        {
          name: 'viewport',
          content: 'width=device-width, initial-scale=1',
        },
        {
          'http-equiv': 'X-UA-Compatible',
          content: 'ie=edge',
        },
      ],
    },
    pageTransition: { name: 'page', mode: 'out-in' },
    rootId: 'ender-app',
  },
  devtools: {
    enabled: true,
  },
  features: {
    inlineStyles: false,
  },
  experimental: {
    inlineRouteRules: true,
  },
  components: {
    dirs: [
      {
        path: '~/components',
        pathPrefix: false,
        extensions: ['.vue'],
      },
    ],
  },
  css: ['~/assets/styles/main.scss'],
  plugins: [],
  modules: [
    '@pinia/nuxt',
    '@nuxt/content',
    '@nuxtjs/seo',
    '@nuxtjs/google-fonts',
    '@nuxtjs/tailwindcss',
    '@nuxtjs/color-mode',
    '@nuxt/eslint',
    ['@nuxtjs/stylelint-module', { failOnError: true, lintOnStart: false }],
  ],
  colorMode: {
    preference: 'system',
    fallback: 'dark',
    classPrefix: '',
    classSuffix: '',
    componentName: 'NuxtTheme',
    storageKey: 'ecmatheme',
  },
  content: {
    markdown: {
      remarkPlugins: ['remark-reading-time'],
    },
    highlight: {
      theme: {
        default: 'github-dark',
        light: 'github-light',
        sepia: 'monokai',
      },
      langs: [
        'shell',
        'batch',
        'vb',
        'ini',
        'asm',
        'c',
        'cpp',
        'java',
        'python',
        'csv',
        'xml',
        'json',
        'yaml',
        'html',
        'css',
        'sass',
        'php',
        'js',
        'ts',
        'vue',
        'md',
        'mdc',
        'pascal',
        'lisp',
        'sql',
      ],
    },
  },
  nitro: {
    prerender: {
      crawlLinks: true,
      autoSubfolderIndex: true,
      failOnError: true,
      routes: ['/robots.txt', '/sitemap.xml'],
    },
  },
  googleFonts: {
    download: true,
    families: {
      Lato: true,
      Alexandria: true,
    },
  },
  site: {
    env: process.env.NODE_ENV,
    url: config.url,
    name: config.name,
    indexable: true,
    trailingSlash: false,
  },
  linkChecker: {
    failOnError: true,
    report: {
      html: true,
      markdown: true,
    },
  },
  // routeRules: {
  //   '/': {
  //     sitemap: {
  //       changefreq: 'yearly',
  //       priority: 1,
  //     },
  //   },
  //   '/about': {
  //     sitemap: {
  //       changefreq: 'yearly',
  //       priority: 0.6,
  //     },
  //   },
  //   '/projects': {
  //     sitemap: {
  //       changefreq: 'monthly',
  //       priority: 0.7,
  //     },
  //   },
  //   '/social': {
  //     sitemap: {
  //       changefreq: 'yearly',
  //       priority: 0.7,
  //     },
  //   },
  // },
  sitemap: {
    sources: ['/api/__sitemap__/content'],
    cacheMaxAgeSeconds: 360,
    exclude: [],
    credits: false,
    xslColumns: [
      { label: 'URL', width: '50%' },
      { label: 'Last Modified', select: 'sitemap:lastmod', width: '25%' },
      { label: 'Priority', select: 'sitemap:priority', width: '12.5%' },
      {
        label: 'Change Frequency',
        select: 'sitemap:changefreq',
        width: '12.5%',
      },
    ],
    defaults: {
      changefreq: 'yearly',
      priority: 0.7,
      lastmod: config.build.date,
    },
  },
  robots: {
    enabled: true,
    metaTag: true,
    blockNonSeoBots: true,
    credits: false,
  },
  tailwindcss: {
    exposeConfig: true,
  },
  typescript: {
    typeCheck: true,
  },
  vue: {
    compilerOptions: {
      isCustomElement: (tag) => tag === 'iconify-icon',
    },
  },
})
