0.0.3 • Published 9 months ago

@flotiq/flotiq-astro-sdk v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

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

OptionDescriptionDefault
--flotiq-keyFlotiq API key with read only access
--flotiq-api-urlUrl to the Flotiq APIhttps://api.flotiq.com
--outputPath to target filename./src/content.config.ts
--watchWatch for changes in the content type definitions and regenerate collectionsfalse

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