完整示例

profile-graphics.yml
provider:
  type: github
  user: octocat
  include_private: false

charts: [streak, summary, langs, calendar]

output:
  dir: profile-graphics
  format: svg
  layout: separate
  raster_background: auto

calendar:
  mode: rolling
  timezone: Europe/Berlin
  locale: en

theme:
  mode: auto
  native: true
  dark_mode_pair: false

svg:
  frame: border
  frame_radius: 8
  frame_title: ""
  hide_title: false
  number_format: short
  animation: none
  accessibility: true

cards:
  langs:
    style: donut
    count: 6
    exclude: [HTML, CSS]
  summary:
    metrics: [stars, commits, prs, reviews]
  calendar:
    weeks: 52
    show_months: true

选项分组

分组 选项
provider type, user, token, base_url, source, include_private, include_forks, exclude_repos, affiliations, merge
output dir, prefix, format, layout, columns, raster_background
calendar mode, year, timezone, locale
theme preset, custom, mode, native, dark_mode_pair, background, colors
svg frame, frame_radius, frame_title, hide_title, number_format, animation, animation_duration, accessibility
cards activity, langs, streak, summary, productive_time, punch_card, calendar, calendar_3d, profile_details, profile_card, trophy, repos, coding_time, coding_list, views

charts 按顺序列出要渲染的卡片。每张卡片及其 cards 下的选项见卡片。

calendar.timezone 是 IANA 名称,例如 Europe/Berlin(默认 UTC)。它决定事件属于哪一天、连续记录何时结束,以及高效时段卡片统计哪个小时。

theme.background 接受颜色、transparent 或线性渐变(例如 30,#e96443,#904e95);参见渐变背景。

review 预设

charts 中的 review 依次展开为 summary、streak、calendar、langs、punch-card 和 repos:一个词就是一份完整的主页回顾。可以在它前后列出其他卡片;出现两次的卡片只渲染一次。

yaml
charts: [review, activity]

CLI 参数和 Action 输入

大多数选项无需编辑 YAML 即可设置:以 CLI 参数或 GitHub Action 输入的形式传入。参数和输入会覆盖配置文件。charts 等列表用逗号分隔。provider.merge、自定义主题、颜色覆盖和卡片尺寸只能在 YAML 中设置。

配置路径 CLI 参数 Action 输入
provider.type --provider provider
provider.user --user user
provider.token --token token
provider.base_url --base-url base_url
provider.source --source source
provider.include_private --include-private include_private
provider.include_forks --include-forks include_forks
provider.exclude_repos --exclude-repos exclude_repos
provider.affiliations --affiliations affiliations
provider.scope --scope scope
provider.include_orgs --include-orgs include_orgs
provider.exclude_orgs --exclude-orgs exclude_orgs
provider.count_private --count-private count_private
provider.count_own_stars --count-own-stars count_own_stars
charts --charts charts
output.dir --output output
output.prefix --prefix prefix
output.format --format format
output.layout --layout layout
output.columns --dashboard-columns dashboard_columns
output.raster_background --raster-background raster_background
calendar.year --year year
calendar.mode --calendar-mode calendar_mode
calendar.timezone --timezone timezone
calendar.locale --locale locale
theme.preset --theme theme
theme.mode --theme-mode theme_mode
theme.native --native-theme native_theme
theme.dark_mode_pair --dark-mode-pair dark_mode_pair
theme.background --background background
svg.frame --frame frame
svg.frame_radius --frame-radius frame_radius
svg.frame_title --frame-title frame_title
svg.hide_title --hide-title hide_title
svg.animation --animation animation
svg.animation_duration --animation-duration animation_duration
svg.number_format --number-format number_format
svg.accessibility --accessibility accessibility
cards.activity.days --activity-days activity_days
cards.activity.show_grid --activity-grid activity_grid
cards.activity.show_points --activity-points activity_points
cards.activity.show_average --activity-average activity_average
cards.langs.count --langs-count langs_count
cards.langs.style --langs-style langs_style
cards.langs.exclude --langs-exclude langs_exclude
cards.summary.metrics --summary-metrics summary_metrics
cards.streak.mode --streak-mode streak_mode
cards.streak.exclude_days --exclude-days exclude_days
cards.streak.range --streak-range streak_range
cards.summary.show_rank --summary-rank summary_rank
cards.summary.rank_style --rank-style rank_style
cards.punch_card.week_start --week-start week_start
cards.productive_time.hour_format --hour-format hour_format
cards.calendar.weeks --calendar-weeks calendar_weeks
cards.calendar.show_months --calendar-months calendar_months
cards.profile_details.show_chart --profile-chart profile_chart
cards.profile_card.show_avatar --profile-avatar profile_avatar
cards.trophy.columns --trophy-columns trophy_columns
cards.trophy.max --trophy-max trophy_max
cards.repos.source --repos-source repos_source
cards.repos.count --repos-count repos_count
cards.calendar_3d.weeks --calendar-3d-weeks calendar_3d_weeks
cards.coding_time.days --coding-days coding_days
cards.coding_list.count --coding-count coding_count
cards.views.style --views-style views_style
cards.views.label --views-label views_label
cards.views.start --views-start views_start

日历窗口

calendar.mode 设置所有卡片覆盖的日期。current-year(默认)为今年一月到十二月,last-year 覆盖上一年,rolling 显示截至今天的最近十二个月,与 GitHub 主页上的图一样。calendar.year 选择某一年,优先于模式。总数、连续记录和日历卡片都跟随窗口,因此 rolling 能让连续记录跨年延续。

yaml
calendar:
  mode: rolling
  # year: 2025 picks one calendar year instead
  timezone: Europe/Berlin

卡片语言

calendar.locale 是 BCP 47 标签(默认 en-US)。卡片标签已翻译为 30 种语言(阿拉伯语、希伯来语和波斯语从右向左绘制);其他 locale 保留英文标签。数字、日期、月份、星期和时长始终按你设置的 locale 用 Intl 格式化。

英语

英语

yaml
calendar:
  locale: en
俄语

俄语

yaml
calendar:
  locale: ru
德语

德语

yaml
calendar:
  locale: de
西班牙语

西班牙语

yaml
calendar:
  locale: es
法语

法语

yaml
calendar:
  locale: fr
葡萄牙语

葡萄牙语

yaml
calendar:
  locale: pt
日语

日语

yaml
calendar:
  locale: ja
中文

中文

yaml
calendar:
  locale: zh

深浅色配对

使用原生自动主题时,每个 SVG 已经通过 prefers-color-scheme 在浅色和深色之间切换。dark_mode_pair: true 则为每张卡片写出两个文件,例如 streak-light.svg 和 streak-dark.svg,供 <picture> 元素使用。它只适用于原生自动主题;预设或自定义主题每张卡片只写一个文件。

yaml
theme:
  mode: auto
  native: true
  dark_mode_pair: true
README.md
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="profile-graphics/streak-dark.svg" />
  <img alt="Streak" src="profile-graphics/streak-light.svg" />
</picture>

仪表盘

output.layout: dashboard 把 charts 中的所有卡片放进一张图片 dashboard.svg(或 PNG、WebP),而不是每张卡片一个文件。output.columns 设置每行卡片数,1 到 4(默认 2)。

yaml
charts: [streak, summary, langs, calendar]

output:
  layout: dashboard
  columns: 2

边框和标题

svg.frame 决定每张卡片周围的样式。frame_radius 设置圆角(0 到 40,默认 8)。

边框

边框

默认样式:与日历空格子同色的细边框。

yaml
svg:
  frame: border
  frame_radius: 8
窗口

窗口

带红绿灯的窗口栏,可选居中标题。

yaml
svg:
  frame: window
  frame_title: "{user}"
无边框

无边框

只有背景,适合放进你自己的布局中的卡片。

yaml
svg:
  frame: none

frame_title 在卡片上方添加标题(最多 120 个字符)。以下占位符会用你的统计数据填充,数字按日历 locale 格式化:

占位符 值
{user} 用户名
{name} 显示名称;没有时使用用户名
{year} 日历窗口的年份
{total} 窗口内的贡献
{active_days} 至少有一次贡献的天数
{streak} 当前连续天数
{longest_streak} 最长连续天数
{best_day} 单日最多贡献
{best_date} 那一天的日期
{stars} 你的仓库获得的星标
{commits} 窗口内的提交
{followers} 关注者
{top_language} 最常用语言

标题、数字和动画

svg.hide_title: true 隐藏所有带标题卡片的标题。对于单张卡片,title 替换标题,hide_title 隐藏标题;参见卡片标题。

svg.number_format 决定卡片如何书写计数:short(默认)按卡片 locale 简写,例如 1.2K,long 完整写出,例如 1,247。

svg.animation 为 SVG 卡片添加入场动画:fade 让内容淡入,rise 还会让内容上浮几个像素。animation_duration 设置时长,单位为秒(0.2 到 5,默认 0.8)。系统要求减少动态效果的访问者看到的是没有动画的卡片,PNG 和 WebP 文件永远是静态的。默认值为 none。

yaml
svg:
  hide_title: true
  number_format: long
  animation: rise
  animation_duration: 0.8

与 profile-snake 共用一份配置

extends 指向另一个 YAML 或 JSON 文件,路径相对于当前文件。它会先被读取,然后当前文件合并在其上:嵌套的部分逐键合并,列表和值直接替换。把共用的 provider、calendar 和 theme 放在一个 profile.yml 中,然后在 profile-graphics.yml 和 profile-snake.yml 中都扩展它。

profile.yml
provider:
  user: octocat
calendar:
  mode: rolling
  timezone: Europe/Berlin
theme:
  preset: tokyo-night
profile-graphics.yml
extends: ./profile.yml
charts: [streak, summary, langs]

一个工具不认识的键(例如 snake 或 charts)会被另一个工具忽略。最多 8 个文件可以相互扩展;出现循环或文件缺失会以配置错误终止。演练场和 Web 组件只读取单个配置,不会跟随 extends。

编辑器支持

在文件顶部加上这一行,即可在支持 YAML language server 的编辑器中获得自动补全和校验;profile-graphics init 会替你写好。profile-graphics schema 打印包内自带 schema 的路径。

yaml
# yaml-language-server: $schema=https://unpkg.com/profile-graphics/profile-graphics.schema.json
provider:
  user: octocat