1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-26 03:06:25 +02:00
blog/src/stores/location.ts
Matthias Kretschmann 3b25ae2282
Location fetching (#843)
* location component

* fetching with @nanostores/query

* layouts reorg

* typescript plugins cleanup

* location component unit test cases

* fetch only when visible
2023-10-04 14:45:54 +01:00

25 lines
464 B
TypeScript

import { createFetcherStore } from './fetcher'
export type Location = {
country: string
city: string
country_code: string
date_start: string
date_end: string
}
export type LocationStore =
| {
now: Location
next: Location
previous: Location
}
| undefined
const url = 'https://location.kremalicious.com'
export const $location = createFetcherStore<LocationStore>([url], {
refetchOnReconnect: true,
refetchOnFocus: true
})