@studiocms/cfetch 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +19 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # `@studiocms/cfetch`
2
2
 
3
+ ![Readme's Banner](https://github.com/withstudiocms/cfetch/blob/main/assets/cfetch-banner.png)
4
+
5
+ [![NPM Version](https://img.shields.io/npm/v/@studiocms/cfetch?logo=npm)](https://npm.im/@studiocms/cfetch)
6
+ [![Formatted with Biome](https://img.shields.io/badge/Formatted_with-Biome-60a5fa?style=flat&logo=biome)](https://biomejs.dev/)
7
+ [![Built with Astro](https://astro.badg.es/v2/built-with-astro/tiny.svg)](https://astro.build)
8
+
3
9
  This is an [Astro integration](https://docs.astro.build/en/guides/integrations-guide/) that provides a cacheable fetch function for Astro SSR
4
10
 
5
11
  ## Usage
@@ -54,39 +60,39 @@ export default defineConfig({
54
60
 
55
61
  ### Usage
56
62
 
57
- You can import the cachedFetch function anywhere you would use a normal `fetch` call. `cfetch` adapts the same default options as fetch,
63
+ You can import the `cFetch` function anywhere and use it as you would use a normal `fetch` call. `cFetch` adapts the same default options as `fetch`:
58
64
 
59
65
  ```astro
60
66
  ---
61
- import { cFetch } from 'cached:fetch';
67
+ import { cFetch } from 'c:fetch';
62
68
 
63
69
  const response = await cFetch(
64
70
  'https://example.com', // string | URL | Request
65
71
  { /* Normal fetch init optional options here, method, mode, etc. */ },
66
72
  { lifetime: "1h" } // Optional, allows changing the default lifetime of the cache
67
- );
73
+ );
68
74
 
69
75
  const html = await response.text();
70
76
  ---
71
77
  ```
72
78
 
73
- If you are also wanting the other available metadata (such as `lastChecked` value which is the last time the cache was updated) then you can add the following prop to cached fetch, changing the shape of the data output to the following:
79
+ If you need to access the other available metadata (such as the `lastChecked` value which provides the last time the cache was updated), you can pass `true` as the fourth parameter, which will change the returned object to the following:
74
80
 
75
81
  ```astro
76
82
  ---
77
- import { cFetch } from 'cached:fetch';
83
+ import { cFetch } from 'c:fetch';
78
84
 
79
- const { lastCheck, data: response } = await cFetch(
80
- 'https://example.com', // string | URL | Request
81
- { /* Normal fetch init optional options here, method, mode, etc. */ },
82
- { lifetime: "1h" }, // Optional, allows changing the default lifetime of the cache
83
- true
84
- );
85
+ const { lastCheck, data } = await cFetch(
86
+ 'https://example.com',
87
+ { /* ... */ },
88
+ { lifetime: "1h" },
89
+ true // Changes the the output to include the lastCheck value
90
+ );
85
91
 
86
- const html = await response.text();
92
+ const html = await data.text();
87
93
  ---
88
94
  ```
89
95
 
90
96
  ## Licensing
91
97
 
92
- [MIT Licensed](https://github.com/withstudiocms/cfetch/blob/main/LICENSE).
98
+ [MIT Licensed](https://github.com/withstudiocms/cfetch/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studiocms/cfetch",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Astro integration that allows you to have a cached fetch function in your Astro SSR project.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://studiocms.dev",