fix: update examples to use the new API of cookies (#7899)
This commit is contained in:
parent
41390c2ebd
commit
dc13687bb4
3 changed files with 3 additions and 3 deletions
|
@ -3,7 +3,7 @@ import Header from '../components/Header.astro';
|
||||||
import Container from '../components/Container.astro';
|
import Container from '../components/Container.astro';
|
||||||
import { getCart } from '../api';
|
import { getCart } from '../api';
|
||||||
|
|
||||||
if (!Astro.cookies.get('user-id').value) {
|
if (!Astro.cookies.get('user-id')) {
|
||||||
return Astro.redirect('/');
|
return Astro.redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
const mode = Astro.cookies.get('prefs').json().mode;
|
const mode = Astro.cookies.get('prefs')!.json().mode;
|
||||||
|
|
||||||
Astro.cookies.set('prefs', {
|
Astro.cookies.set('prefs', {
|
||||||
mode: mode === 'light' ? 'dark' : 'light'
|
mode: mode === 'light' ? 'dark' : 'light'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
const cookie = Astro.cookies.get('prefs');
|
const cookie = Astro.cookies.get('prefs')!;
|
||||||
const prefs = cookie.json();
|
const prefs = cookie.json();
|
||||||
---
|
---
|
||||||
<html>
|
<html>
|
||||||
|
|
Loading…
Reference in a new issue