50 lines
1020 B
JavaScript
50 lines
1020 B
JavaScript
import {jwennSlugs} from '../lib/oki-api'
|
|
|
|
const url = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost'
|
|
|
|
const createSitemap = teks => {
|
|
return (
|
|
`<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
<url>
|
|
<loc>${url}</loc>
|
|
<priority>1</priority>
|
|
</url>
|
|
<url>
|
|
<loc>${url}/teks</loc>
|
|
<priority>0.8</priority>
|
|
</url>
|
|
<url>
|
|
<loc>${url}/awtis</loc>
|
|
<priority>0.6</priority>
|
|
</url>
|
|
${teks
|
|
.map(m => {
|
|
return `
|
|
<url>
|
|
<loc>${`${url}/teks/${m}`}</loc>
|
|
</url>
|
|
`
|
|
})
|
|
.join('')}
|
|
</urlset>
|
|
`
|
|
)
|
|
}
|
|
|
|
export default function Sitemap() {
|
|
return null
|
|
}
|
|
|
|
export async function getServerSideProps({res}) {
|
|
const request = await jwennSlugs()
|
|
|
|
res.setHeader('Content-Type', 'text/xml')
|
|
res.write(createSitemap(request))
|
|
res.end()
|
|
|
|
return {
|
|
props: {}
|
|
}
|
|
}
|