Huggingface.js documentation

🤗 Hugging Face Space 页眉

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

🤗 Hugging Face Space 页眉

一个基于 Typescript 的封装,用于 Space 的 mini_header 功能。

space header preview

安装

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"

初始化

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

// ...

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

❗重要提示:必须在客户端调用 init 方法。

用法

使用 target 选项将 space-header 注入到另一个 DOM 元素中

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

// ...

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

如果您已经拥有空间数据,也可以将其作为参数传入,以避免获取操作

init(space);

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