Skip to content

Commit

Permalink
[ci] release (#4903)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
astrobot-houston and github-actions[bot] authored Sep 29, 2022
1 parent 56fd9e4 commit 35fe8e8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions packages/integrations/cloudflare/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
# @astrojs/cloudflare

## 2.1.0

### Minor Changes

- [#4876](https://github.com/withastro/astro/pull/4876) [`d3091f89e`](https://github.com/withastro/astro/commit/d3091f89e92fcfe1ad48daca74055d54b1c853a3) Thanks [@matthewp](https://github.com/matthewp)! - Adds the Astro.cookies API

`Astro.cookies` is a new API for manipulating cookies in Astro components and API routes.

In Astro components, the new `Astro.cookies` object is a map-like object that allows you to get, set, delete, and check for a cookie's existence (`has`):

```astro
---
type Prefs = {
darkMode: boolean;
};
Astro.cookies.set<Prefs>(
'prefs',
{ darkMode: true },
{
expires: '1 month',
}
);
const prefs = Astro.cookies.get<Prefs>('prefs').json();
---
<body data-theme={prefs.darkMode ? 'dark' : 'light'}></body>
```

Once you've set a cookie with Astro.cookies it will automatically be included in the outgoing response.

This API is also available with the same functionality in API routes:

```js
export function post({ cookies }) {
cookies.set('loggedIn', false);

return new Response(null, {
status: 302,
headers: {
Location: '/login',
},
});
}
```

See [the RFC](https://github.com/withastro/rfcs/blob/main/proposals/0025-cookie-management.md) to learn more.

## 2.0.0

### Major Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@astrojs/cloudflare",
"description": "Deploy your site to cloudflare pages functions",
"version": "2.0.0",
"version": "2.1.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
Expand Down

0 comments on commit 35fe8e8

Please sign in to comment.