Skip to content

Files

Latest commit

787c7ca · Sep 3, 2024

History

History
This branch is 1 commit ahead of, 407 commits behind huggingface/huggingface.js:main.

space-header

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 3, 2024
Jun 14, 2024
Jun 14, 2024
Jun 14, 2024
Jun 25, 2024
Jun 18, 2024
Sep 3, 2024
Jun 14, 2024
Jun 18, 2024
Jun 18, 2024
Jun 18, 2024

README.md

🤗 Hugging Face Space Header

A Typescript powered wrapper for the Space mini_header feature.

space header preview

Install

pnpm add @huggingface/space-header

npm add @huggingface/space-header

yarn add @huggingface/space-header

Deno

// esm.sh
import { init } from "https://esm.sh/@huggingface/space-header"
// or npm:
import { init } from "npm:@huggingface/space-header"

Initialize

import { init } from "@huggingface/space-header";

// ...

init(":user/:spaceId");
// init("enzostvs/lora-studio") for example

❗Important note: The init method must be called on the client side.

Usage

Uses the target option to inject the space-header into another DOM element

const app = document.getElementById("app");

// ...

init(":user/:spaceId", {
  target: app
});

If you already have the space data, you can also pass it as a parameter to avoid a fetch

init(space);

// space = {
//  id: string;
//  likes: number;
//  author: string;
// }