@lekoarts/flickr-loader
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

Astro Flickr loader

This package provides multiple Flickr content loaders for Astro's content layer. Most loaders correspond to a single Flickr API endpoint, however some loaders call multiple one for better results. The data returned from Flickr is normalized and cleaned up, so that each loader's response is similar and easy to work with.

Want to see an overview of all my loaders? Visit astro-loaders.lekoarts.de

npm version npm downloads license

Prerequisites

  • Astro 5 or later installed
  • A Flickr API key
    • Create an account on Flickr, go to App Garden to register an app, and copy the Key

Installation

# npm
npm install @lekoarts/flickr-loader
# yarn
yarn add @lekoarts/flickr-loader
# pnpm
pnpm install @lekoarts/flickr-loader

Usage

Import @lekoarts/flickr-loader into src/content.config.ts and define your collections. You can import various loaders that correspond to their respective Flickr API endpoints.

Important: You need to either define the Flickr API key as an environment variable (FLICKR_API_KEY) or pass it to every loader with the api_key argument.

flickrPeopleGetPhotosLoader

Return photos from the given user's photostream. Only photos visible to the calling user will be returned.

Flickr API: flickr.people.getPhotos

Required options

  • username (string)

Usage

import { flickrPeopleGetPhotosLoader } from '@lekoarts/flickr-loader'

const peopleGetPhotos = defineCollection({
  loader: flickrPeopleGetPhotosLoader({
    username: 'flickr-username',
  }),
})

flickrPhotosetsGetListLoader

Returns the photosets belonging to the specified user.

Flickr API: flickr.photosets.getList

Required options

  • username (string)

Usage

import { flickrPhotosetsGetListLoader } from '@lekoarts/flickr-loader'

const photosetsGetList = defineCollection({
  loader: flickrPhotosetsGetListLoader({
    username: 'flickr-username',
  }),
})

flickrPhotosetsGetPhotosLoader

Get the list of photos in a photoset.

Flickr API: flickr.photosets.getPhotos

Required options

  • username (string)
  • photoset_id (string)

Usage

import { flickrPhotosetsGetPhotosLoader } from '@lekoarts/flickr-loader'

const photosetsGetPhotos = defineCollection({
  loader: flickrPhotosetsGetPhotosLoader({
    username: 'flickr-username',
    photoset_id: '72177720313250218',
  }),
})

flickrPhotosetsGetListWithPhotosLoader

This loader combines the flickrPhotosetsGetListLoader() and flickrPhotosetsGetPhotosLoader() loaders to get the most out of photosets. You'll get back the photosets and their list of photos.

Flickr API: flickr.photosets.getList + flickr.photosets.getPhotos

Required options

  • username (string)

Optional options

  • in (string[]) - Array of photoset IDs to match against
  • nin (string[]) - Array of photoset IDs to exclude

Usage

Fetching all photosets a user has.

import { flickrPhotosetsGetListWithPhotosLoader } from '@lekoarts/flickr-loader'

const photosetsGetListWithPhotos = defineCollection({
  loader: flickrPhotosetsGetListWithPhotosLoader({
    username: 'flickr-username',
  }),
})

Only fetching the photosets 123 and 456.

import { flickrPhotosetsGetListWithPhotosLoader } from '@lekoarts/flickr-loader'

const photosetsGetListWithPhotos = defineCollection({
  loader: flickrPhotosetsGetListWithPhotosLoader({
    username: 'flickr-username',
    in: ['123', '456'],
  }),
})

Excluding the photosets 789 and 001.

import { flickrPhotosetsGetListWithPhotosLoader } from '@lekoarts/flickr-loader'

const photosetsGetListWithPhotos = defineCollection({
  loader: flickrPhotosetsGetListWithPhotosLoader({
    username: 'flickr-username',
    nin: ['789', '001'],
  }),
})

Readme

Keywords

Package Sidebar

Install

npm i @lekoarts/flickr-loader

Weekly Downloads

7

Version

1.2.4

License

MIT

Unpacked Size

27 kB

Total Files

5

Last publish

Collaborators

  • lekoarts