diff --git a/README.md b/README.md index 481c7fc..eed7a94 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,26 @@ Utilities for serializing data from server for use in the client. 1. `Resumable` Astro component takes `id` and `data` 1. `resume(id: string): Object` function for use int he client takes an `id` string and returns the `data` as Object -## Intallation +## Installation & Usage + +### Install via npm + +On your [Astro](https://astro.build) project: ``` npm i @ayco/astro-resume ``` -## Usage +### Usage + +Serializing and deserializing basic primitive data ```astro --- import Resumable from "@ayco/astro-resume"; + const data = { - hello: 'world' + hello: 'world', } --- @@ -25,14 +32,46 @@ const data = { ``` -## Found issues? +### Type Safety -Send a plain text email to [~ayoayco/astro-resume@todo.sr.ht](mailto:~ayoayco/astro-resume@todo.sr.ht) or report via [SourceHut](https://todo.sr.ht/~ayoayco/astro-resume) +You can define a type for the data and use it in the client script. + +```astro +--- +import Resumable from "@ayco/astro-resume"; + +const data = { + hello: 'world', + isOkay: true +} +// define the type of data to be serialized +export type Data = typeof data; +--- + + + + +``` + +## Reporting Issues + +To report issues or request features, send a plain text email to [~ayoayco/astro-resume@todo.sr.ht](mailto:~ayoayco/astro-resume@todo.sr.ht) or file a ticket via [SourceHut](https://todo.sr.ht/~ayoayco/astro-resume) diff --git a/src/pages/index.astro b/src/pages/index.astro index 47826d0..45b3608 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -2,7 +2,8 @@ import Resumable from '../Resumable.astro'; const data = { hello: 'world' -} +}; +export type Data = typeof data; --- @@ -11,9 +12,10 @@ const data = {