No description
Find a file
2023-07-16 21:31:44 +02:00
.vscode initial commit 2023-07-16 11:55:35 +02:00
public initial commit 2023-07-16 11:55:35 +02:00
src feat: type for supported data (only primitives) 2023-07-16 21:31:44 +02:00
.gitignore initial commit 2023-07-16 11:55:35 +02:00
astro.config.mjs initial commit 2023-07-16 11:55:35 +02:00
index.ts chore: finalize package for publishing 2023-07-16 12:10:40 +02:00
LICENSE chore: add MIT as LICENSE 2023-07-16 12:55:00 +02:00
package-lock.json 0.0.9 2023-07-16 20:20:04 +02:00
package.json 0.0.9 2023-07-16 20:20:04 +02:00
README.md chore: add example for type safety 2023-07-16 20:50:44 +02:00
tsconfig.json initial commit 2023-07-16 11:55:35 +02:00

Astro Resume

Utilities for serializing data from server for use in the client.

  1. Resumable Astro component takes id and data
  2. resume(id: string): Object function for use int he client takes an id string and returns the data as Object

Installation & Usage

Install via npm

On your Astro project:

npm i @ayco/astro-resume

Usage

Serializing and deserializing basic primitive data

---
import Resumable from "@ayco/astro-resume";

const data = {
	hello: 'world',
}
---

<Resumable id="astro-obj" data={data} />

<script>
	import {resume} from '@ayco/astro-resume';
	const data = resume('astro-obj');
	console.log(data) // {hello: 'world'}
</script>

Type Safety

You can define a type for the data and use it in the client script.

---
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;
---

<Resumable id="astro-obj" data={data} />

<script>
	import {resume} from '@ayco/astro-resume';

	/**
     * reuse the type in the client
	 * assuming this component's name is `Component.astro`
	 */
	import type {Data} from './Component.astro';

	const data = resume<Data>('astro-obj');

	console.log(data) // {hello: 'world'}
</script>

Reporting Issues

To report issues or request features, send a plain text email to ~ayoayco/astro-resume@todo.sr.ht or file a ticket via SourceHut