summaryrefslogtreecommitdiff
path: root/src/pages/sitemap/homepage.xml.js
blob: 08c52112e31000462a7ae224cdeade1d2b2f9664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { create } from 'xmlbuilder';

export async function getServerSideProps({ res }) {
  const links = [
    { label: 'Hubungi Kami', url: 'https://indoteknik.com/hubungi-kami' },
    { label: 'Tentang Kami', url: 'https://indoteknik.com/tentang-kami' },
    { label: 'Karir', url: 'https://indoteknik.com/karir' },
    { label: 'Daftar Tempo', url: 'https://indoteknik.com/my/pembayaran-tempo' },
  ];
  const sitemap = create('urlset', { encoding: 'utf-8' }).att(
    'xmlns',
    'http://www.sitemaps.org/schemas/sitemap/0.9'
  )

  const date = new Date()
  links.forEach((link) => {
    const url = sitemap.ele('url')
    url.ele('loc', link.url)
    url.ele('lastmod', date.toISOString().slice(0, 10))
    url.ele('changefreq', 'daily')
    url.ele('priority', '1.0')
  })

  res.setHeader('Content-Type', 'text/xml')
  res.write(sitemap.end())
  res.end()

  return { props: {} }
}

export default function SitemapProducts() {
  return null
}