Dedicated Astro collections generator for Flotiq Headless CMS.
Generated content.config.ts
collections can be either committed with your code, or .gitignore
-d and generated during development and CI/CD.
The project is not production-ready! Versioning may reset, features and api may be changed, project may be removed. Do not use for anything other than playing around. See State of Alpha section for more details of what might change before v1.
To use collections you need @flotiq/flotiq-api-sdk
and types generated by it.
- run
npm install @flotiq/flotiq-api-sdk @flotiq/flotiq-astro-sdk
- (optional) Generate typescript types for your data definitions
- Create
.env
file and addFLOTIQ_API_KEY
env variable inside - Run
npm exec flotiq-api-typegen
to generate account type definitions - RUN
npm exec flotiq-astro-typegen
to generate collections
- Create
- run
yarn add @flotiq/flotiq-api-sdk @flotiq/flotiq-astro-sdk
- (optional) Generate typescript types for your data definitions
- Create
.env
file and addFLOTIQ_API_KEY
env variable inside - Run
yarn exec flotiq-api-typegen
to generate account type definitions - RUN
yarn exec flotiq-astro-typegen
to generate collections
- Create
- run
pnpm add @flotiq/flotiq-api-sdk @flotiq/flotiq-astro-sdk
- (optional) Generate typescript types for your data definitions
- Create
.env
file and addFLOTIQ_API_KEY
env variable inside - Run
pnpm exec flotiq-api-typegen
to generate account type definitions - RUN
pnpm exec flotiq-astro-typegen
to generate collections
- Create
Project with tags:
---
import { getCollection, getEntry } from 'astro:content';
const allProjects = await getCollection('project');
---
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<h1>Astro</h1>
{allProjects.map((project) => (
<section>
<h2>{project.data.name}</h2>
{project.data.tags.map(async (tag) => {
const tagContent = await getEntry(tag.collection, tag.id);
return (<span>{tagContent.data.name}</span>)
})}
</section>
))}
</body>
</html>
flotiq-astro-typegen
Generates Astro collections for Flotiq API based on the content type definitions on your account
Option | Description | Default |
---|---|---|
--flotiq-key |
Flotiq API key with read only access | |
--flotiq-api-url |
Url to the Flotiq API | https://api.flotiq.com |
--output |
Path to target filename | ./src/content.config.ts |
--watch |
Watch for changes in the content type definitions and regenerate collections | false |
See CONTRIBUTING.md
Features that might appear in the future (not necessarily before v1):
- [x] basic collections with references
- [ ] correct enums for selects
- [ ] filters
- [ ] draft
- [ ] easy access to images
- [ ] more usage examples
- [ ] slug as id