import {jwennAwtisSlug, jwennTeksSlug} from '../lib/oki-api'

const url = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost'

async function jwennDone() {
  const teksSlug = await jwennTeksSlug()
  const awtisSlug = await jwennAwtisSlug()

  return {
    teksSlug,
    awtisSlug
  }
}

export default async function sitemap() {
  const {teksSlug, awtisSlug} = await jwennDone()

  const urls = [
    {
      url,
      priority: 1
    },
    {
      url: `${url}/paroles`,
      priority: 0.9
    },
    {
      url: `${url}/sipote`,
      priority: 0.8
    },
    {
      url: `${url}/awtis`,
      priority: 0.6
    }
  ]

  for (const teks of teksSlug) {
    urls.push({
      url: `${`${url}/paroles/${teks}`}`
    })
  }

  for (const awtis of awtisSlug) {
    urls.push({
      url: `${`${url}/awtis/${awtis}`}`
    })
  }

  return urls
}
