UNPKG

tuture

Version:

Write tutorials from the future, with the power of Git and community.

29 lines (28 loc) 858 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Generate HTML code for user profile. */ function generateUserProfile(github) { const matched = github.match(/github.com\/(.+)\/(.+)/); if (!matched) { return ''; } const user = matched[1]; const avatarUrl = `/images/avatars/${user}.jpg`; const homepageUrl = `https://github.com/${user}`; return `<div class="profileBox"> <div class="avatarBox"> <a href="${homepageUrl}"><img src="${avatarUrl}" alt="" class="avatar"></a> </div> <div class="rightBox"> <div class="infoBox"> <a href="${homepageUrl}"><p class="nickName">@${user}</p></a> </div> <div class="codeBox"> <a href="${github}"><span class="codeText">查看代码</span></a> </div> </div> </div>`; } exports.generateUserProfile = generateUserProfile;