npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@seaart/footer-embed

v0.1.2

Published

SeaArt embeddable website footer SDK

Readme

@seaart/footer-embed

SeaArt 网站公共 Footer 渲染包。调用方负责获取和筛选页面组件配置,将目标模块的 elList 作为 footerData 传入;包负责渲染栏目、社媒与应用下载区域,并支持浏览器挂载与 SSR HTML 输出。

安装

pnpm add @seaart/footer-embed

npm 使用

import { mountFooter, type FooterData } from '@seaart/footer-embed';

const footerData: FooterData = [
  {
    title: 'SeaArt AI',
    child: [{ title: '价格', link_route: '/pricing' }],
  },
];

const controller = mountFooter('#seaart-footer', {
  footerData,
  locale: 'zhCN',
  websiteOrigin: 'https://www.seaart.ai',
  onTrack(event) {
    reportFooterClick(event);
  },
});

controller.destroy();

浏览器脚本

<div id="seaart-footer"></div>
<script src="./dist/seaart-footer.global.js"></script>
<script>
  const controller = SeaArtFooter.mount('#seaart-footer', {
    footerData: window.footerData,
    locale: 'zhCN',
    websiteOrigin: 'https://www.seaart.ai',
  });
</script>

全局对象为 SeaArtFooter,其 mount 方法等同于 mountFooter

挂载参数

mountFooter(target, options)target 可以是 CSS 选择器或 HTMLElement。找不到目标元素时会抛出异常。

| 参数 | 类型 | 必填 | 默认值 | 说明 | | --- | --- | --- | --- | --- | | target | string \| HTMLElement | 是 | - | Footer 的挂载容器。 | | footerData | FooterData | 否 | 内置静态数据 | 页面组件配置中已选定模块的 elList。传入空数组时只渲染社媒与应用下载区域。 | | locale | string | 否 | - | 以 zh 开头时,固定区标题显示“关注我们”“获取应用”;否则显示英文。 | | websiteOrigin | string | 否 | https://www.seaart.ai | 相对链接的站点前缀。 | | className | string | 否 | - | 添加到 Footer 根节点的自定义 class。 | | onTrack | (event) => void | 否 | - | 点击链接、社媒或应用下载入口时触发。 |

footerData 结构

footerData 直接对应 POST /api/v1/square/component/config-v2 目标模块的 elList

const footerData = [
  {
    title: '视频',
    child: [
      {
        title: 'AI视频生成器',
        key: 'footer_video_generator',
        obj_type: 61,
        link_route: '/ai-video-generator',
        id: 'ai-video-generator',
        obj_id: 'ai-video-generator',
      },
    ],
  },
  {
    title: '帮助',
    childs: [{ title: '指南', link_route: '/guide' }],
  },
];

| 字段 | 类型 | 说明 | | --- | --- | --- | | title | string | 栏目标题。 | | child / childs | FooterConfigLinkItem[] | 栏目链接列表,两个字段均兼容。 | | child[].title | string | 链接展示文字。 | | child[].link_route | string | 链接地址,优先使用。 | | child[].id | string \| number | 未提供 link_route 时的链接回退值。 | | child[].obj_id | string \| number | 未提供 link_routeid 时的链接回退值。 | | child[].key / obj_type | string / string \| number | 接口原始字段,包不使用它们筛选或渲染。 |

HTTP(S) 链接保持不变;相对链接会拼接 websiteOrigin。缺少标题或链接地址的条目不会渲染。

当前主站筛选方式

当前 SeaArt Web 主站在调用包前,从 component/config-v2 响应中完成以下业务筛选:

const targetModule = response.items
  ?.find((item) => item.parent_id === 'home_visitor')
  ?.modules?.find((module) => String(module.content_type) === '42');

const footerData = (targetModule?.elList || [])
  .map((column) => ({
    ...column,
    child: (column.child || column.childs || []).filter((item) => Number(item.obj_type) === 61),
  }))
  .filter((column) => column.child?.length);

home_visitorcontent_type = 42obj_type = 61 是当前主站页面配置约定,不是 SDK 固定逻辑。其他宿主项目应按自身接口配置筛选,再将最终 elList 传给 footerData

点击事件与控制器

onTrack 接收:

| 字段 | 类型 | 说明 | | --- | --- | --- | | type | 'link' \| 'social' \| 'app' | 点击区域类型。 | | label | string | 链接或应用名称。 | | href | string | 最终跳转地址。 |

mountFooter 返回 FooterEmbedController

| 方法 | 参数 | 说明 | | --- | --- | --- | | update(options) | footerDatalocalewebsiteOrigin | 重新渲染 Footer。 | | destroy() | - | 清空挂载容器并移除根 class。 |

社媒、Logo 与 App Store/Google Play 链接为包内静态配置,不在 footerData 中。

SSR

import { getFooterStyle, renderFooterHtml } from '@seaart/footer-embed';

const footerHtml = renderFooterHtml({
  footerData,
  locale: 'zhCN',
  websiteOrigin: 'https://www.seaart.ai',
});
const footerStyle = getFooterStyle();

footerHtml 输出到服务端模板,并将 footerStyle 放入 <style> 标签。renderFooterHtml 不访问 windowdocument,可安全用于 SSR;mountFooter 仅可用于浏览器。

测试与构建

pnpm --filter @seaart/footer-embed typecheck
pnpm --filter @seaart/footer-embed test
pnpm --filter @seaart/footer-embed build

License

UNLICENSED