markdown-it-git-graph
Version:
一个markdown-it插件,用于生成git提交图
26 lines (25 loc) • 1.07 kB
JavaScript
import { getSortedCommits } from './git.js';
import { getSvg } from './svg.js';
function getTable(idx, branchs, options) {
const commits = getSortedCommits(branchs);
return {
columns: options.theme.columns,
commits,
svg: getSvg(idx, commits, options),
draw(id, theme) {
return `<table class="gg-table"><tbody><tr class="gg-td-svg"><td rowSpan="99999">${this.svg.draw(id, theme)}</td></tr>${this.commits.map(commit => `<tr>${this.columns.map((column) => {
switch (column) {
case 'hash':
return `<td>${commit.hash}</td>`;
case 'message':
return `<td>${commit.message}</td>`;
case 'date':
return `<td>${new Intl.DateTimeFormat('default', options.theme.dateFormat).format(commit.date)}</td>`;
default:
return '';
}
}).join('')}</tr>`).join('')}</tbody></table>`;
},
};
}
export { getTable };