Skip to content

Commit 04daec0

Browse files
enzostvscoyotte508
andauthored
add Readme for space-header (#756)
Co-authored-by: coyotte508 <[email protected]>
1 parent 1f4eb84 commit 04daec0

File tree

7 files changed

+80
-4
lines changed

7 files changed

+80
-4
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"editor.defaultFormatter": "esbenp.prettier-vscode"
1414
},
1515
"cSpell.words": ["huggingface"],
16-
"deno.enablePaths": ["./e2e/deno"]
16+
"deno.enablePaths": ["./e2e/deno"],
17+
"typescript.tsdk": "node_modules/typescript/lib"
1718
}

CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
# Ownership for the gguf Package
2222

2323
/packages/gguf @mishig25 @julien-c
24+
25+
# Ownership for the space-header Package
26+
/packages/space-header @enzostvs

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ This is a collection of JS libraries to interact with the Hugging Face API, with
5454
- [@huggingface/agents](packages/agents/README.md): Interact with HF models through a natural language interface
5555
- [@huggingface/gguf](packages/gguf/README.md): A GGUF parser that works on remotely hosted files.
5656
- [@huggingface/tasks](packages/tasks/README.md): The definition files and source-of-truth for the Hub's main primitives like pipeline tasks, model libraries, etc.
57+
- [@huggingface/space-header](packages/space-header/README.md): Use the Space `mini_header` outside Hugging Face
5758

5859

5960
We use modern features to avoid polyfills and dependencies, so the libraries will only work on modern browsers / Node.js >= 18 / Bun / Deno.

docs/_toctree.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,13 @@
2121
title: Use Agents to run multi-modal workflows from a natural language API
2222
- local: agents/modules
2323
title: API Reference
24+
- title: "@huggingface/space-header"
25+
isExpanded: true
26+
sections:
27+
- local: space-header/README
28+
title: Use Space mini_header in your app
29+
- title: "@huggingface/gguf"
30+
isExpanded: true
31+
sections:
32+
- local: gguf/README
33+
title: Parse local and remote GGUF files

packages/doc-internal/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
"description": "Package to generate doc for other @huggingface packages",
66
"private": true,
77
"scripts": {
8-
"start": "pnpm run fix-cdn-versions && pnpm run doc-hub && pnpm run doc-inference && pnpm run doc-agents && cp ../../README.md ../../docs/index.md && pnpm run update-toc && pnpm run fix-md-links && pnpm run fix-md-headinghashlinks",
8+
"start": "pnpm run fix-cdn-versions && pnpm run doc-hub && pnpm run doc-inference && pnpm run doc-agents && pnpm run doc-space-header && pnpm run doc-gguf && cp ../../README.md ../../docs/index.md && pnpm run update-toc && pnpm run fix-md-links && pnpm run fix-md-headinghashlinks",
99
"lint": "eslint --quiet --fix --ext .cjs,.ts .",
1010
"lint:check": "eslint --ext .cjs,.ts .",
1111
"format": "prettier --write .",
1212
"format:check": "prettier --check .",
1313
"doc-hub": "typedoc --tsconfig ../hub/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/hub --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../hub/index.ts",
1414
"doc-inference": "typedoc --tsconfig ../inference/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/inference --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../inference/src/index.ts",
1515
"doc-agents": "typedoc --tsconfig ../agents/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/agents --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../agents/src/index.ts",
16+
"doc-gguf": "mkdir -p ../../docs/gguf && cp ../../packages/gguf/README.md ../../docs/gguf/README.md",
17+
"doc-space-header": "mkdir -p ../../docs/space-header && cp ../../packages/space-header/README.md ../../docs/space-header/README.md",
1618
"update-toc": "tsx update-toc.ts",
1719
"fix-cdn-versions": "tsx fix-cdn-versions.ts",
1820
"fix-md-links": "tsx fix-md-links.ts",

packages/space-header/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# 🤗 Hugging Face Space Header
2+
3+
A Typescript powered wrapper for the Space `mini_header` feature.
4+
5+
## Install
6+
7+
```console
8+
pnpm add @huggingface/space-header
9+
10+
npm add @huggingface/space-header
11+
12+
yarn add @huggingface/space-header
13+
```
14+
15+
### Deno
16+
17+
```ts
18+
// esm.sh
19+
import { init } from "https://esm.sh/@huggingface/space-header"
20+
// or npm:
21+
import { init } from "npm:@huggingface/space-header"
22+
```
23+
24+
### Initialize
25+
```ts
26+
import { init } from "@huggingface/space-header";
27+
28+
// ...
29+
30+
init(":user/:spaceId");
31+
// init("enzostvs/lora-studio") for example
32+
```
33+
❗Important note: The `init` method must be called on the client side.
34+
35+
## Usage
36+
37+
Uses the `target` option to inject the space-header into another DOM element
38+
39+
```ts
40+
const app = document.getElementById("app");
41+
42+
// ...
43+
44+
init(":user/:spaceId", {
45+
target: app
46+
});
47+
```
48+
49+
If you already have the space data, you can also pass it as a parameter to avoid a fetch
50+
51+
```ts
52+
init(space);
53+
54+
// space = {
55+
// id: string;
56+
// likes: number;
57+
// author: string;
58+
// }
59+
```

packages/space-header/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@huggingface/space-header",
3-
"version": "1.0.0",
3+
"version": "0.0.0",
44
"description": "",
55
"main": "index.js",
66
"type": "module",
@@ -15,7 +15,7 @@
1515
"prepublishOnly": "pnpm run build"
1616
},
1717
"keywords": [],
18-
"author": "",
18+
"author": "Hugging Face",
1919
"license": "ISC",
2020
"devDependencies": {
2121
"tsup": "^8.1.0",

0 commit comments

Comments
 (0)