Huggingface.js 文件

🤗 Hugging Face Space Header

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

🤗 Hugging Face Space Header

一個由 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;
// }
< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.