0.2.1 • Published 7 months ago

astro-csv v0.2.1

Weekly downloads
-
License
-
Repository
github
Last release
7 months ago

Astro CSV Integration

Use CSV files as data sources in Astro.

Install

npx astro add astro-csv

Manual install

npm i astro-csv
// astro.config.mjs
import { defineConfig } from 'astro/config'
import astroCSV from 'astro-csv'

export default defineConfig({
  integrations: [
    astroCSV()
  ]
})

Usage

Accept any data

import { defineCollection, z } from 'astro:content';

const sheets = defineCollection({
  type: 'data',
  schema: z.object({
    rows: z.array(z.array(z.string().or(z.number().or(z.boolean()).nullish()))),
  })
});

export const collections = { sheets };

Accept typed data

import { defineCollection, z } from 'astro:content';

const sheets = defineCollection({
  type: 'data',
  schema: z.object({
    rows: z.array(z.tuple([
      z.string(), // name
      z.string(), // email
      z.number(), // age
    ]))
  })
});

export const collections = { sheets };
0.2.1

7 months ago

0.2.0

7 months ago

0.1.0

12 months ago