chore: remove indentation in readme script examples

This commit is contained in:
Ayo Ayco 2024-04-10 16:39:11 +02:00
parent 3600df5279
commit aa994c4793

View file

@ -31,9 +31,9 @@ const data = {
<Serialize id="my-data" data={data} /> <Serialize id="my-data" data={data} />
<script> <script>
import {deserialize} from '@ayco/astro-resume'; import {deserialize} from '@ayco/astro-resume';
const data = deserialize('my-data'); const data = deserialize('my-data');
console.log(data) // {hello: 'world'} console.log(data) // {hello: 'world'}
</script> </script>
``` ```
@ -57,17 +57,17 @@ export type Data = typeof data;
<Serialize id="my-data" data={data} /> <Serialize id="my-data" data={data} />
<script> <script>
import {deserialize} from '@ayco/astro-resume'; import {deserialize} from '@ayco/astro-resume';
/** /**
* reuse the type in the client * reuse the type in the client
* assuming this component's name is `ThisComponent.astro` * assuming this component's name is `ThisComponent.astro`
*/ */
import type {Data} from './ThisComponent.astro'; import type {Data} from './ThisComponent.astro';
const data = deserialize<Data>('my-data'); const data = deserialize<Data>('my-data');
console.log(data) // {hello: 'world', isOkay: true} console.log(data) // {hello: 'world', isOkay: true}
</script> </script>
``` ```
@ -87,10 +87,10 @@ export interface Props {
<Serialize id="preferences" data={{...Astro.props}} /> <Serialize id="preferences" data={{...Astro.props}} />
<script> <script>
import {deserialize} from '@ayco/astro-resume'; import {deserialize} from '@ayco/astro-resume';
import type {Props} from './ThisComponent.astro'; import type {Props} from './ThisComponent.astro';
const {hello, isOkay} = deserialize<Props>('preferences'); const {hello, isOkay} = deserialize<Props>('preferences');
console.log(hello, isOkay); console.log(hello, isOkay);
</script> </script>
``` ```
@ -119,11 +119,11 @@ In Child.astro:
<h1>I'm a child. I have access to the appConfig in index!</h1> <h1>I'm a child. I have access to the appConfig in index!</h1>
<GrandChild /> <GrandChild />
<script> <script>
import {deserialize} from '@ayco/astro-resume'; import {deserialize} from '@ayco/astro-resume';
import type {AppConfig} from '..pages/index.astro'; import type {AppConfig} from '..pages/index.astro';
const data = deserialize<AppConfig>('app-config'); const data = deserialize<AppConfig>('app-config');
// ... do something with the app config // ... do something with the app config
</script> </script>
``` ```
@ -131,11 +131,11 @@ In GrandChild.astro:
```astro ```astro
<h1>I'm a grand child. I also have access to the appConfig in index!</h1> <h1>I'm a grand child. I also have access to the appConfig in index!</h1>
<script> <script>
import {deserialize} from '@ayco/astro-resume'; import {deserialize} from '@ayco/astro-resume';
import type {AppConfig} from '..pages/index.astro'; import type {AppConfig} from '..pages/index.astro';
const data = deserialize<AppConfig>('app-config'); const data = deserialize<AppConfig>('app-config');
// ... do something with the app config // ... do something with the app config
</script> </script>
``` ```
@ -159,13 +159,13 @@ export type Data = typeof data;
<Serialize data={data} id="my-data" use={stringify} /> <Serialize data={data} id="my-data" use={stringify} />
<script> <script>
import {parse} from 'devalue'; import {parse} from 'devalue';
import {deserialize} from '@ayco/astro-resume'; import {deserialize} from '@ayco/astro-resume';
import type {Data} from './index.astro'; import type {Data} from './index.astro';
const {age, now} = deserialize<Data>('my-data', parse); const {age, now} = deserialize<Data>('my-data', parse);
console.log(typeof age); // 'bigint' console.log(typeof age); // 'bigint'
console.log(now instanceof Date); // true console.log(now instanceof Date); // true
</script> </script>
``` ```