Skip to content

Commit

Permalink
feat(ripple-nuxt-tide): forward sitemap query params (#1244)
Browse files Browse the repository at this point in the history
Co-authored-by: David Featherston <david.featherstone@dpc.vic.gov.au>
Co-authored-by: Jason Smith <jason.smith@dpc.vic.gov.au>
  • Loading branch information
3 people committed Oct 2, 2022
1 parent a683e57 commit ed4ce0c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/ripple-nuxt-tide/modules/site/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ module.exports = function () {
options: options
})

const getQuery = (req) => {
return req.query ? '&' + new URLSearchParams(req.query).toString() : ''
}

// This won't override nuxt tide module's proxy option, as they have been added into array already.
// But this may impact nuxt proxy settings if there is, so need to be reviewed for that case.
this.options.proxy = {
...this.options.proxy,
'/sitemap.xml': baseUrl + 'sitemap.xml?site=' + options.site,
'/sitemaps/**/sitemap.xml': { target: baseUrl, pathRewrite: (path) => { return baseUrl + path + '?site=' + options.site } }
'/sitemap.xml': {
target: baseUrl,
pathRewrite: (path, req) => {
return baseUrl + 'sitemap.xml?site=' + options.site + getQuery(req)
}
},
'/sitemaps/**/sitemap.xml': {
target: baseUrl,
pathRewrite: (path, req) => {
return baseUrl + path + '?site=' + options.site + getQuery(req)
}
}
}
}

0 comments on commit ed4ce0c

Please sign in to comment.