[chore] Update npm packages and fix errors/run migrations
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
onMount(async () => {
|
||||
// Disable when changing filters on /photos and shop?
|
||||
if (!$page.query.get('country') && !$page.path.includes('/shop')) {
|
||||
if (!$page.url.searchParams.get('country') && !$page.url.pathname.includes('/shop')) {
|
||||
await tick()
|
||||
setTimeout(() => {
|
||||
// Scroll back to top between page transitions
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
>
|
||||
<ul class="switcher__links">
|
||||
{#each links as { icon, iconLabel, url, text }}
|
||||
<li class:is-active={$page.path.startsWith(url)}>
|
||||
<li class:is-active={$page.url.pathname.startsWith(url)}>
|
||||
<a href={url} on:click={toggleSwitcher}
|
||||
sveltekit:noscroll sveltekit:prefetch
|
||||
>
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
// Change URL to current photo slug
|
||||
$: if (browser && currentPhoto) {
|
||||
window.history.replaceState(null, '', $page.path.replace($page.params.photo, currentPhoto.slug))
|
||||
window.history.replaceState(null, '', $page.url.pathname.replace($page.params.photo, currentPhoto.slug))
|
||||
}
|
||||
|
||||
// Define previous URL
|
||||
@@ -407,11 +407,12 @@
|
||||
<script context="module" lang="ts">
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
// Get the first photo ID
|
||||
const firstPhoto = await fetchAPI(`
|
||||
query {
|
||||
photo: photo (search: "${page.params.photo}") {
|
||||
photo: photo (search: "${params.photo}") {
|
||||
id
|
||||
}
|
||||
}
|
||||
@@ -423,7 +424,7 @@
|
||||
count: photo_aggregated (
|
||||
filter: {
|
||||
id: { _gt: ${firstPhotoId} },
|
||||
location: { slug: { _eq: "${page.params.location}" }},
|
||||
location: { slug: { _eq: "${params.location}" }},
|
||||
status: { _eq: "published" },
|
||||
},
|
||||
sort: "-id",
|
||||
@@ -441,7 +442,7 @@
|
||||
query {
|
||||
photos: photo (
|
||||
filter: {
|
||||
location: { slug: { _eq: "${page.params.location}" }}
|
||||
location: { slug: { _eq: "${params.location}" }}
|
||||
status: { _eq: "published" },
|
||||
},
|
||||
sort: "-date_created",
|
||||
@@ -459,7 +460,7 @@
|
||||
city
|
||||
}
|
||||
|
||||
location (filter: { slug: { _eq: "${page.params.location}" }}) {
|
||||
location (filter: { slug: { _eq: "${params.location}" }}) {
|
||||
name
|
||||
slug
|
||||
country {
|
||||
@@ -471,11 +472,11 @@
|
||||
`)
|
||||
|
||||
const { data } = res
|
||||
const location = stuff.locations.find((location: any) => location.slug === page.params.location)
|
||||
const location = stuff.locations.find((location: any) => location.slug === params.location)
|
||||
const totalPhotos = stuff.countTotalPhotosByLocation.find((total: any) => total.group.location === Number(location.id)).count.id
|
||||
|
||||
// Find photo's index
|
||||
const currentIndex = data.photos.findIndex((photo: any) => photo.slug === page.params.photo)
|
||||
const currentIndex = data.photos.findIndex((photo: any) => photo.slug === params.photo)
|
||||
|
||||
return {
|
||||
props: {
|
||||
|
||||
@@ -356,8 +356,9 @@
|
||||
<script context="module" lang="ts">
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
const { location } = page.params
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
const { location } = params
|
||||
|
||||
const res = await fetchAPI(`
|
||||
query {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
let previous = ''
|
||||
page.subscribe(value => {
|
||||
$previousPage = previous
|
||||
previous = value.path
|
||||
previous = value.url.pathname
|
||||
})
|
||||
|
||||
// Define page loading from navigating store
|
||||
@@ -65,7 +65,7 @@
|
||||
<script context="module" lang="ts">
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
const res = await fetchAPI(`
|
||||
query {
|
||||
locations: location (filter: { status: { _eq: "published" }}) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
|
||||
|
||||
// Block GET requests
|
||||
export async function get ({ body, query }) {
|
||||
export async function get ({ url, body }) {
|
||||
return {
|
||||
status: 403,
|
||||
body: 'nope!'
|
||||
@@ -21,7 +21,7 @@ export async function get ({ body, query }) {
|
||||
/**
|
||||
* POST request
|
||||
*/
|
||||
export async function post ({ headers, query, body, params, ...rest }) {
|
||||
export async function post ({ headers, url, body, params, ...rest }) {
|
||||
try {
|
||||
const bodyParsed = JSON.parse(Buffer.from(body).toString())
|
||||
const { action, cartId, productId } = bodyParsed
|
||||
|
||||
@@ -152,7 +152,8 @@
|
||||
<script context="module" lang="ts">
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
const res = await fetchAPI(`
|
||||
query {
|
||||
credits {
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
export let photos: any
|
||||
|
||||
const { settings, locations }: any = getContext('global')
|
||||
const { path } = $page
|
||||
|
||||
let scrollY: number, innerHeight: number
|
||||
|
||||
@@ -128,7 +127,7 @@
|
||||
|
||||
<div class="cards">
|
||||
<BoxCTA
|
||||
url="{path}#locations"
|
||||
url="{$page.url.pathname}#locations"
|
||||
icon="globe"
|
||||
label="Discover locations"
|
||||
alt="Globe"
|
||||
@@ -176,7 +175,8 @@
|
||||
<script context="module" lang="ts">
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
const res = await fetchAPI(`
|
||||
query {
|
||||
photo (limit: 11, sort: ["-date_created"]) {
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
*/
|
||||
const urlFiltersParams = new URLSearchParams()
|
||||
let filtered: boolean
|
||||
let filterCountry = $page.query.get('country') || defaultCountry
|
||||
let filterSort = $page.query.get('sort') || defaultSort
|
||||
let filterCountry = $page.url.searchParams.get('country') || defaultCountry
|
||||
let filterSort = $page.url.searchParams.get('sort') || defaultSort
|
||||
let countryFlagId: string
|
||||
$: filtered = filterCountry !== defaultCountry || filterSort !== defaultSort
|
||||
$: latestPhoto = photos[0]
|
||||
@@ -93,7 +93,7 @@
|
||||
urlFiltersParams.set('country', filterCountry)
|
||||
urlFiltersParams.set('sort', filterSort)
|
||||
|
||||
let path = `${$page.path}?${urlFiltersParams.toString()}`
|
||||
let path = `${$page.url.pathname}?${urlFiltersParams.toString()}`
|
||||
goto(path, { replaceState: true, keepfocus: true, noscroll: true })
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@
|
||||
{:else if !filteredCountryExists}
|
||||
<div class="photos__message">
|
||||
<p>
|
||||
<strong>{$page.query.get('country').replace(/(^|\s)\S/g, letter => letter.toUpperCase())}</strong> is not available… yet 👀
|
||||
<strong>{$page.url.searchParams.get('country').replace(/(^|\s)\S/g, letter => letter.toUpperCase())}</strong> is not available… yet 👀
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -509,11 +509,13 @@
|
||||
const defaultCountry = String(import.meta.env.VITE_FILTERS_DEFAULT_COUNTRY)
|
||||
const defaultSort = String(import.meta.env.VITE_FILTERS_DEFAULT_SORT)
|
||||
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
console.log(url)
|
||||
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
// Query parameters
|
||||
const queryCountry = page.query.get('country') || defaultCountry
|
||||
const querySort = page.query.get('sort') || defaultSort
|
||||
const queryCountry = url.searchParams.get('country') || defaultCountry
|
||||
const querySort = url.searchParams.get('sort') || defaultSort
|
||||
|
||||
const res = await fetchAPI(`
|
||||
query {
|
||||
|
||||
@@ -169,11 +169,12 @@
|
||||
</PageTransition>
|
||||
|
||||
<script context="module" lang="ts">
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
let shopProduct: any
|
||||
|
||||
// Get a random product from the API
|
||||
const productAPI = stuff.posters.find(poster => poster.location.slug === page.params.name)
|
||||
const productAPI = stuff.posters.find(poster => poster.location.slug === params.name)
|
||||
|
||||
// Fetch this product on Swell API
|
||||
if (productAPI) {
|
||||
|
||||
@@ -43,7 +43,8 @@
|
||||
<script context="module" lang="ts">
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
// Get content from API
|
||||
const res = await fetchAPI(`
|
||||
query {
|
||||
|
||||
@@ -171,7 +171,8 @@
|
||||
<script context="module" lang="ts">
|
||||
import { getRandomElement } from '$utils/functions'
|
||||
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
let shopProduct: any
|
||||
|
||||
// Get a random product from the API
|
||||
|
||||
@@ -111,7 +111,8 @@
|
||||
<script context="module" lang="ts">
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export async function load ({ page, fetch, session, stuff }) {
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
const res = await fetchAPI(`
|
||||
query {
|
||||
settings {
|
||||
|
||||
Reference in New Issue
Block a user