Вышел Модуль интеграций 2.0 для MedusaЧитать анонс
H

Hero banners

Home-page hero banners for Medusa v2, managed in the Admin: desktop (12:5) and phone (4:5) images uploaded through the File Module with a focal point, title, subtitle and button per language, link, drag-and-drop order, on/off and scheduling, typed Store A

npm install medusa-hero-banners
Категория
Создано
Версия
0.1.0
Последнее обновление
1 неделю назад
Ежемесячные загрузки
Загрузка данных

Haus Kayu

medusa-hero-banners

The hero slider of your home page, managed in the Medusa Admin. Each banner has a wide photo for desktops (12:5) and a tall one for phones (4:5), uploaded through Medusa's File Module with a focal point, a headline, a line of text and a button, in every language of your store; drag-and-drop order, on/off, a schedule, several placements, a typed Store API and a storefront integration for Kiln.
Slider hero beranda yang diatur dari Admin Medusa: foto desktop dan HP dengan titik fokus, judul, teks, tombol per bahasa, urutan drag-and-drop, jadwal tampil, Store API bertipe.

npm CI Medusa license: MIT

Compatibility

PluginMedusaNodeTested in CI on
0.1.x2.19.0 or newer 2.x ()20.19+ or 22.12+Medusa 2.19.0 and 2.22.2

No other service needed: images go through Medusa's File Module, whichever provider the project uses (local, S3, R2, …).

Quick start

npx medusa db:migrate

Open Banners in the Admin sidebar, create a banner, write the texts, upload the two images, switch it on. The storefront reads and draws the slider.

What a banner is

FieldNotes
Internal nameOnly in the Admin.
Shown (on/off)Off keeps the banner without showing it. New banners start off.
OrderDrag in the list; 0 is the first slide.
Button linkA storefront path (, , ) or an absolute URL. Empty = no button.
ScheduleShow from / until (optional).
LanguagesBCP 47 codes; the first is the default and must have a headline. Visitors asking for get ; a banner without text in a language falls back to its default.
Text per languageHeadline, line of text, button label (empty = the storefront's default), image description (alt).
Desktop image12:5, e.g. 1920 × 800. Uploads are rotated by EXIF and scaled down to 2400 px wide when larger.
Phone image4:5, e.g. 840 × 1050. Scaled down to 1200 px wide when larger.
Focal pointClick on the preview; the storefront keeps that point visible when it crops.

Without images a banner is a text panel; with one image the storefront uses it for both viewports. Uploads accept JPEG, PNG, WebP and AVIF (checked by their first bytes, never by the file name), at most 12 MB; SVG is refused. Replacing or removing an image deletes the previous file, so nothing piles up in the bucket.

Options

OptionDefaultNotes
–Public origin of the storefront, for the "leads to" links in the Admin.
Per locale (, ) or .
Languages a new banner starts with; the first is the default.
Independent sets of banners (a second slider, a promo bar). The storefront asks for one.
–: changes are batched and sent as .
A small "Banners by Haus Kayu" line under the Admin page.

Store API

GET /store/hero-banners?placement=home&locale=id (x-publishable-api-key)

Only banners that are on and within their schedule, in order. may also come from the header. The answer carries ; with the option the storefront learns about changes at once.

Typed SDK

wraps the Admin routes (, , , , , , , ). Only is used, so any object with that shape works.

Admin API

All under (session or bearer):

Route
Non-secret options the Admin adapts to.
· List one placement (default: the first) · create .
· · One banner. A pasted image URL over an upload deletes the upload.
: listed ids first, the rest keep their order.
· Multipart field . Answers .

Rule violations answer // with ; codes: , , , , , , , .

Storefront

Kiln 0.5+ detects the plugin and draws the banners as its home hero (slide 1 preloaded as the LCP image, the others loaded when idle; swipe, dots, arrow keys, optional autoplay that pauses on hover and respects ); a banner without images becomes a text panel. Any other storefront: read the Store API, reserve 12:5 / 4:5 boxes so nothing shifts while the photos load, and call your revalidation from the hook.

Development

See CONTRIBUTING.md. runs the whole suite against a local Postgres container.

License

MIT © Haus Kayu