import * as plugins from './plugins.js';
import * as paths from './paths.js';
import * as helpers from './helpers.js';

// refer https://vitepress.dev/reference/site-config for details
export default async () => {
  // lets download gitea files
  await helpers.downloadReadmes(
    'https://code.foss.global',
    'api.global',
    plugins.path.join(paths.docsDir, 'api.global'),
  );

  await helpers.downloadReadmes(
    'https://code.foss.global',
    'apiclient.xyz',
    plugins.path.join(paths.docsDir, 'apiclient.xyz'),
  );

  await helpers.downloadReadmes(
    'https://code.foss.global',
    'design.estate',
    plugins.path.join(paths.docsDir, 'design.estate'),
  );

  await helpers.downloadReadmes(
    'https://code.foss.global',
    'push.rocks',
    plugins.path.join(paths.docsDir, 'push.rocks'),
  );


  return plugins.vitepress.defineConfig({
    lang: 'en-US',
    lastUpdated: true,
    cleanUrls: true,
    title: 'docs.foss.global',
    description: 'Vite & Vue powered static site generator.',
    ignoreDeadLinks: true,
    metaChunk: true,
    themeConfig: {
      outline: 'deep',
      nav: [],

      sidebar: [
        { text: '01. Home', link: '/index.md' },
        { text: '02. Legal Info', link: 'https://legal.task.vc' },
        ...(await helpers.generateNavLinks('foss.global')),
        {
          text: 'Projects',
          items: [
            {
              text: 'apiclient.xyz',
              items: await helpers.generateNavLinks('apiclient.xyz'),
              collapsed: true,
            },
            {
              text: 'api.global',
              items: await helpers.generateNavLinks('api.global'),
              collapsed: true,
            },
            {
              text: 'design.estate',
              items: await helpers.generateNavLinks('design.estate'),
              collapsed: true,
            },
            {
              text: 'push.rocks',
              items: await helpers.generateNavLinks('push.rocks'),
              collapsed: true,
            },
            {
              text: 'serve.zone',
              items: await helpers.generateNavLinks('serve.zone'),
              collapsed: true,
            },
          ],
        },
      ],
      socialLinks: [
        {
          icon: 'mastodon',
          link: 'mtd.foss.global',
        },
        {
          icon: {
            svg: '<svg viewBox="0 0 24 24"><path d="M22 4H2v16h20zm-2 4l-8 5l-8-5V6l8 5l8-5z"/></svg>',
          },
          link: '/contact',
        },
      ],
      search: {
        provider: 'local',
      },
      footer: {
        message: 'The legal entity behind this project is Task Venture Capital GmbH.',
        copyright: 'Copyright © Task Venture Capital GmbH since 2014',
      },
    },
  });
};
