Merge branch 'dev'
This commit is contained in:
41
.drone.yml
41
.drone.yml
@@ -26,7 +26,6 @@ steps:
|
||||
mount:
|
||||
- "node_modules"
|
||||
|
||||
|
||||
#
|
||||
# Build Node.js app
|
||||
#
|
||||
@@ -36,7 +35,6 @@ steps:
|
||||
- npm install -s
|
||||
- npm run build
|
||||
|
||||
|
||||
#
|
||||
# Build the Docker image
|
||||
#
|
||||
@@ -65,6 +63,7 @@ steps:
|
||||
- master
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Restart container
|
||||
#
|
||||
@@ -72,13 +71,13 @@ steps:
|
||||
- name: restart-container-dev
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host: flayks.com
|
||||
host: housesof.world
|
||||
username:
|
||||
from_secret: ssh_user
|
||||
key:
|
||||
from_secret: ssh_key
|
||||
script:
|
||||
- cd /data/sites/housesof.world/dev
|
||||
- cd /data/sites/housesof.world/test
|
||||
- docker-compose down
|
||||
- docker-compose up -d --remove-orphans
|
||||
when:
|
||||
@@ -89,7 +88,7 @@ steps:
|
||||
- name: restart-container-prod
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host: flayks.com
|
||||
host: housesof.world
|
||||
username:
|
||||
from_secret: ssh_user
|
||||
key:
|
||||
@@ -103,6 +102,38 @@ steps:
|
||||
- master
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Purge CDN
|
||||
#
|
||||
# DEV
|
||||
- name: cdn-purge-dev
|
||||
image: plugins/webhook
|
||||
settings:
|
||||
urls:
|
||||
from_secret: cdn_purgeurl_dev
|
||||
headers:
|
||||
from_secret: cdn_accesskey
|
||||
method: POST
|
||||
when:
|
||||
branch:
|
||||
- dev
|
||||
|
||||
# PROD
|
||||
- name: cdn-purge-prod
|
||||
image: plugins/webhook
|
||||
settings:
|
||||
urls:
|
||||
from_secret: cdn_purgeurl_prod
|
||||
headers:
|
||||
from_secret: cdn_accesskey
|
||||
method: POST
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Rebuild cache
|
||||
#
|
||||
|
||||
@@ -45,20 +45,26 @@ const render = (pages, locations) => {
|
||||
|
||||
// Get function
|
||||
export async function get (req, res, next) {
|
||||
let locations
|
||||
|
||||
// Define base url from request
|
||||
baseURL = `https://${req.headers.host}`
|
||||
|
||||
// Get locations
|
||||
const locationsReq = await fetch(`${apiEndpoints.rest}/items/locations?fields=slug,country.slug,modified_on&status=published`)
|
||||
const locationsData = await locationsReq.json()
|
||||
const locations = locationsData.data
|
||||
await fetch(`${apiEndpoints.rest}/items/locations?fields=slug,country.slug,modified_on&status=published&sort=created_on`)
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
locations = res.data
|
||||
})
|
||||
|
||||
// Add last modified date to each location from its last photo
|
||||
const updatedLocations = locations.map(async (location, i) => {
|
||||
const latestPhotoReq = await fetch(`${apiEndpoints.rest}/items/photos?fields=created_on&limit=1&sort=created_on&status=published&filter[location.slug][rlike]=%${location.slug}`)
|
||||
const latestPhotoData = await latestPhotoReq.json()
|
||||
const latestPhoto = latestPhotoData.data[0]
|
||||
location.updated = latestPhoto ? latestPhoto.created_on : location.modified_on
|
||||
await fetch(`${apiEndpoints.rest}/items/photos?fields=created_on&limit=1&sort=-created_on&status=published&filter[location.slug][rlike]=%${location.slug}`)
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
const latestPhoto = res.data[0]
|
||||
location.updated = latestPhoto ? latestPhoto.created_on : location.modified_on
|
||||
})
|
||||
return location
|
||||
})
|
||||
await Promise.all(updatedLocations)
|
||||
|
||||
Reference in New Issue
Block a user