Huggingface.js 文档

🤗 Hugging Face Space 标题

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

🤗 Hugging Face Space 标题

Space mini_header 功能的 Typescript 驱动的包装器。

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
});

如果你已经有了 space 数据,你也可以将其作为参数传递,以避免 fetch

init(space);

// space = {
//  id: string;
//  likes: number;
//  author: string;
// }
< > 在 GitHub 上更新