0.0.3 • Published 9 months ago
@flotiq/flotiq-astro-sdk v0.0.3
Flotiq ASTRO SDK
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.
Installation from npm
- run
npm install @flotiq/flotiq-api-sdk @flotiq/flotiq-astro-sdk - (optional) Generate typescript types for your data definitions
- Create
.envfile and addFLOTIQ_API_KEYenv variable inside - Run
npm exec flotiq-api-typegento generate account type definitions - RUN
npm exec flotiq-astro-typegento generate collections
- Create
Installation from yarn
- run
yarn add @flotiq/flotiq-api-sdk @flotiq/flotiq-astro-sdk - (optional) Generate typescript types for your data definitions
- Create
.envfile and addFLOTIQ_API_KEYenv variable inside - Run
yarn exec flotiq-api-typegento generate account type definitions - RUN
yarn exec flotiq-astro-typegento generate collections
- Create
Installation from pnpm
- run
pnpm add @flotiq/flotiq-api-sdk @flotiq/flotiq-astro-sdk - (optional) Generate typescript types for your data definitions
- Create
.envfile and addFLOTIQ_API_KEYenv variable inside - Run
pnpm exec flotiq-api-typegento generate account type definitions - RUN
pnpm exec flotiq-astro-typegento generate collections
- Create
Usage example
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
flotiq-astro-typegen
Generates Astro collections for Flotiq API based on the content type definitions on your account
Options
| 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 |
Development
See CONTRIBUTING.md
State of Alpha
Features that might appear in the future (not necessarily before v1):
- basic collections with references
- correct enums for selects
- filters
- draft
- easy access to images
- more usage examples
- slug as id