Skip to content

omerlo-ts 2024.11.1

Install from the command line:
Learn more about npm packages
$ npm install @omerlo-technologies/omerlo-ts@2024.11.1
Install via package.json:
"@omerlo-technologies/omerlo-ts": "2024.11.1"

About this version

Omerlo-TS

Node.js CI

omerlo-ts is a TypeScript API wrapper for Omerlo CMS. It is optimized for usage in SvelteKit but is perfectly usable elsewhere.

Installation

Start by logging in to GitHub Packages. You need to provide a Personal Access Token with the packages:read scope instead of your password.

pnpm login --auth-type=legacy --registry=https://npm.pkg.github.com --scope=@omerlo-technologies

In your project's .npmrc, you need to define the registry used for @omerlo-technologies's packages.

@omerlo-technologies:registry=https://npm.pkg.github.com

Then, install the package.

pnpm i -D @omerlo-technologies/omerlo-ts

Usage

To use it in SvelteKit, first make a function that creates the client and that receives the fetch function from SvelteKit's load functions.

import { base } from '$app/paths'
import { currentLocale } from '$lib/stores/locale'
import { Client, GlobalFetch } from '@omerlo-technologies/omerlo-ts/api'

export function c(fetch: GlobalFetch) {
	return new Client(base, fetch, currentLocale)
}

Then, it can be used in your load functions.

import { c } from '$lib/helpers/omerlo-ts'
import { error } from '@sveltejs/kit'
import type { PageLoad } from './$types'

export const load = (async ({ params, fetch }) => {
	const article = await c(fetch)
		.document.getArticle(params.article_id)
		.then(r => {
			if (!r.ok) throw error(r.status, r.statusText)
			return r.json()
		})

	return { article }
}) satisfies PageLoad

Outside of SvelteKit's load functions, you can use new Client(base, fetch, locale) and the global fetch will be used.

Details


Assets

  • omerlo-ts-2024.11.1.tgz

Download activity

  • Total downloads 192
  • Last 30 days 80
  • Last week 9
  • Today 0