@flotiq/flotiq-astro-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

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

  1. run npm install @flotiq/flotiq-api-sdk @flotiq/flotiq-astro-sdk
  2. (optional) Generate typescript types for your data definitions
    1. Create .env file and add FLOTIQ_API_KEY env variable inside
    2. Run npm exec flotiq-api-typegen to generate account type definitions
    3. RUN npm exec flotiq-astro-typegen to generate collections

Installation from yarn

  1. run yarn add @flotiq/flotiq-api-sdk @flotiq/flotiq-astro-sdk
  2. (optional) Generate typescript types for your data definitions
    1. Create .env file and add FLOTIQ_API_KEY env variable inside
    2. Run yarn exec flotiq-api-typegen to generate account type definitions
    3. RUN yarn exec flotiq-astro-typegen to generate collections

Installation from pnpm

  1. run pnpm add @flotiq/flotiq-api-sdk @flotiq/flotiq-astro-sdk
  2. (optional) Generate typescript types for your data definitions
    1. Create .env file and add FLOTIQ_API_KEY env variable inside
    2. Run pnpm exec flotiq-api-typegen to generate account type definitions
    3. RUN pnpm exec flotiq-astro-typegen to generate collections

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):

  • [x] basic collections with references
  • [ ] correct enums for selects
  • [ ] filters
  • [ ] draft
  • [ ] easy access to images
  • [ ] more usage examples
  • [ ] slug as id

Package Sidebar

Install

npm i @flotiq/flotiq-astro-sdk

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

34.1 kB

Total Files

19

Last publish

Collaborators

  • flotiq