j-figma2html
TypeScript icon, indicating that this package has built-in type declarations

1.0.49 • Public • Published

j-figma2html

工具类

npm i j-figma2html

需要手动拼上文件id和token: https://jiamao.github.io/j-figma2html/example/index.html?fileid=&token= example

使用

引用

import { convert, nodeToDom, loadFigmaFile, getFigmaImage, getFigmaFileImages } from "j-figma2html";

获取figma信息(这块请自行调用api获取,这里只给示例)

// 用文件ID,和个人token拉取数据
data = await loadFigmaFile(fileKey, token);
// 获取当前文件所有图片
images = await getFigmaFileImages(fileKey, token);

转换格式到自定义格式

// 转换模板,并动态获取图片地址
const tpl = await convert(data, null, {
    images,
    async getImage(key) {
        console.log('get image', key);
        if(images[key]) return images[key];
        return '';// 待实现动态获取图片地址
    }
});
// 把自定义格式转为document元素结构
const node = await nodeToDom(tpl, {});

node && document.body.appendChild(node);

API

API

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.490latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.490
1.0.480
1.0.470
1.0.460
1.0.450
1.0.440
1.0.430
1.0.420
1.0.410
1.0.400
1.0.390
1.0.380
1.0.370
1.0.360
1.0.350
1.0.340
1.0.330
1.0.320
1.0.310
1.0.300
1.0.290
1.0.280
1.0.270
1.0.260
1.0.250
1.0.240
1.0.230
1.0.220
1.0.210
1.0.200
1.0.190
1.0.180
1.0.170
1.0.160
1.0.150
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10

Package Sidebar

Install

npm i j-figma2html

Weekly Downloads

0

Version

1.0.49

License

MIT

Unpacked Size

491 kB

Total Files

39

Last publish

Collaborators

  • jiamao