markdown-it-git-graph
Version:
一个markdown-it插件,用于生成git提交图
28 lines (27 loc) • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTable = getTable;
const git_js_1 = require("./git.js");
const svg_js_1 = require("./svg.js");
function getTable(idx, branchs, options) {
const commits = (0, git_js_1.getSortedCommits)(branchs);
return {
columns: options.theme.columns,
commits,
svg: (0, svg_js_1.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>`;
},
};
}