This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
const fields = [
|
||||
'id', 'name', 'slug', 'date', 'image.*',
|
||||
'location.id', 'location.name', 'location.slug', 'location.region', 'location.country.name', 'location.country.slug',
|
||||
'created_on'
|
||||
'created_on', 'modified_on'
|
||||
].join(',')
|
||||
const sort = ['-created_on', 'name'].join(',')
|
||||
const limit = -1
|
||||
|
||||
@@ -4,10 +4,10 @@ import { apiEndpoints } from '../utils/store'
|
||||
|
||||
|
||||
// Variables
|
||||
let BASE_URL
|
||||
let baseURL
|
||||
const pages = ['']
|
||||
|
||||
// Get each route
|
||||
// Get routes and push it to array
|
||||
fs.readdirSync('./src/routes').forEach(file => {
|
||||
const filename = file.split('.')[0]
|
||||
if (!file.startsWith('.') && !filename.startsWith('_') && ['sitemap', 'index', 'location', 'viewer'].indexOf(filename) === -1) {
|
||||
@@ -15,10 +15,9 @@ fs.readdirSync('./src/routes').forEach(file => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// Render function
|
||||
const render = (pages, locations) => {
|
||||
console.log(locations)
|
||||
|
||||
return `<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<urlset
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
@@ -27,13 +26,13 @@ const render = (pages, locations) => {
|
||||
>
|
||||
${pages.map(page => `
|
||||
<url>
|
||||
<loc>${BASE_URL}/${page}</loc>
|
||||
<loc>${baseURL}/${page}</loc>
|
||||
<priority>0.75</priority>
|
||||
</url>`).join('\n')}
|
||||
|
||||
${locations.map(loc => `
|
||||
<url>
|
||||
<loc>${BASE_URL}/location/${loc.country.slug}/${loc.slug}</loc>
|
||||
<loc>${baseURL}/location/${loc.country.slug}/${loc.slug}</loc>
|
||||
<priority>1</priority>
|
||||
</url>`).join('\n')}
|
||||
</urlset>`
|
||||
@@ -41,15 +40,18 @@ const render = (pages, locations) => {
|
||||
|
||||
// Get function
|
||||
export async function get (req, res, next) {
|
||||
BASE_URL = `http${(req.httpVersion >= 2) ? 's' : ''}://${req.headers.host}`
|
||||
// Define base url from request
|
||||
baseURL = `http${(req.httpVersion >= 2) ? 's' : ''}://${req.headers.host}`
|
||||
|
||||
// Get locations
|
||||
const locationsReq = await fetch(`${apiEndpoints.rest}/items/locations?fields=slug,country.slug`)
|
||||
const locations = await locationsReq.json()
|
||||
|
||||
res.setHeader('Cache-Control', `max-age=0, s-max-age=${600}`) // 10 minutes
|
||||
// Set headers
|
||||
res.setHeader('Cache-Control', 'max-age=0, s-max-age=600') // 10 minutes
|
||||
res.setHeader('Content-Type', 'application/rss+xml')
|
||||
|
||||
// Render sitemap
|
||||
const sitemap = render(pages, locations.data)
|
||||
res.end(sitemap)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
.photos {
|
||||
position: relative;
|
||||
margin-top: -22px;
|
||||
overflow-x: hidden;
|
||||
background-color: #fff;
|
||||
|
||||
@include breakpoint (sm) {
|
||||
@@ -55,6 +54,7 @@
|
||||
position: relative;
|
||||
z-index: 4;
|
||||
margin-bottom: 88px;
|
||||
overflow-x: hidden;
|
||||
|
||||
@include breakpoint (sm) {
|
||||
margin-bottom: 120px;
|
||||
|
||||
Reference in New Issue
Block a user