- TypeScript 92.6%
- JavaScript 7.4%
| Filnamn | Senaste incheckningsmeddelande | Senaste incheckningsdatum |
|---|---|---|
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [czg](https://cz-git.qbb.sh/cli/) ([source](https://github.com/Zhengqbbb/cz-git/tree/HEAD/packages/cli)) | devDependencies | minor | [`1.11.1` → `1.14.0`](https://renovatebot.com/diffs/npm/czg/1.11.1/1.14.0) | > ❗ **Important** > > Release Notes retrieval for this PR were skipped because no github.com credentials were available. > If you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes). --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODguMCIsInVwZGF0ZWRJblZlciI6IjQzLjI4OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: #12 |
||
| .changeset | ||
| .forgejo/workflows | ||
| .github | ||
| src | ||
| .gitignore | ||
| .npmignore | ||
| .prettierignore | ||
| .prettierrc | ||
| CHANGELOG.md | ||
| commitlint.config.js | ||
| eslint.config.mjs | ||
| lefthook.json | ||
| LICENSE | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| readme.md | ||
| release.md | ||
| renovate.json | ||
| tsconfig.json | ||
| tsup.config.ts | ||
| vitest.config.ts | ||
Next Image Storyblok Loader
An image loader for the Next.js Image component to load images from Storyblok.
Inspired by @delicious-simplicity/next-image-imgix-loader.
Usage
Pass the loader to a Next.js Image component to load images from Storyblok directly instead of intermediate storage, resizing, etc on the Next.js server.
Install the package using your package manager of choice:
pnpm add @supernaut/next-image-storyblok-loader
npm install @supernaut/next-image-storyblok-loader
yarn add @supernaut/next-image-storyblok-loader
Basic Usage
Import the loader as is to use default settings.
import Image from "next/image";
import { storyblokImageLoader } from "@supernaut/next-image-storyblok-loader";
const Component = ({ image }) => {
return (
<Image
loader={storyblokImageLoader}
src={image.url}
alt={image.title}
width={image.width}
height={image.height}
/>
);
};
Create an Image Loader with Options
You can import the getStoryblokImageLoader function to construct a loader with options.
import Image from "next/image";
import { getStoryblokImageLoader } from "@supernaut/next-image-storyblok-loader";
const loader = getStoryblokImageLoader({ host: "my-custom-domain.com" });
const Component = ({ image }) => {
return (
<Image
loader={loader}
src={image.url}
alt={image.title}
width={image.width}
height={image.height}
/>
);
};
Create Image URL's for getImageProps
You use the getStoryblokImageSrc function to create image src URL's to use with getImageProps.
This can be useful for creating picture elements with editorial responsive behaviors. Here is a simplified example of a component taking a single source image from Storyblok and creating a picture element showing differently cropped images depending on the screen orientation.
iimport { getImageProps } from "next/image";
import {
getStoryblokImageSrc,
storyblokImageLoader,
} from "@supernaut/next-image-storyblok-loader";
const Component = ({ image }) => {
const srcPortrait = getStoryblokImageSrc(image, {
resize: {
height: 800,
width: 600,
},
});
const srcLandscape = getStoryblokImageSrc(image, {
resize: {
height: 600,
width: 800,
},
});
const { props: propsPortrait } = getImageProps({
...image,
src: srcPortrait,
loader: storyblokImageLoader,
});
const { props: propsLandscape } = getImageProps({
...image,
src: srcLandscape,
loader: storyblokImageLoader,
});
return (
<picture>
<source media="(orientation: portrait)" {...propsPortrait} />
<source media="(orientation: landscape)" {...propsLandscape} />
<img {...propsLandscape} />
</picture>
);
};
Options
Setting Options
You can either provide options to the getStoryblokImageLoader function or set them with environment variables. Using environment variables is generally simpler, but if you need to set optios conditionally at runtime there might be scenarios where using options and the factory function works better.
Host
The default host is set to a.storyblok.com and can be overriden with either the STORYBLOK_IMAGE_LOADER_HOST environment variable or the host option.
This is intentionally host and not hostname and allows for setting an optional port if needed.
This is useful if you rewrite image requests to another hostname, or using Storyblok in a region outside the EU that might have a different subdomain.
Setting the host option to my-domain.com would change the generated src URL from https://a.storyblok.com/f/88751/2600x1214/2c6ef16b8f/hero-visual-editor.png/m/2600x0/ to https://my-domain.com/f/88751/2600x1214/2c6ef16b8f/hero-visual-editor.png/m/2600x0/.
Prefix
An optional overriding prefix can be set using the STORYBLOK_IMAGE_LOADER_PREFIX environment variable or the prefix option.
This is useful if you rewrite image requests to a pathname instead of a complete URL.
Setting the prefix option to /assets/storyblok would change the generated src URL from https://a.storyblok.com/f/88751/2600x1214/2c6ef16b8f/hero-visual-editor.png/m/2600x0/ to /assets/storyblok/f/88751/2600x1214/2c6ef16b8f/hero-visual-editor.png/m/2600x0/.