How resume.github.com Differentiates Between User and Organization Accounts
The application checks the type property in the GitHub API response, rendering views/resume.html for personal accounts and views/resumeOrgs.html for organizations.
The resume.github.com project generates visual resumes from GitHub profiles by consuming the GitHub API. To properly differentiate between User and Organization accounts, the application relies on a specific field in the API payload that identifies the account type at runtime.
How the GitHub API Identifies Account Types
When the application fetches profile data from GitHub's API, the response includes a type property that distinguishes account categories. This field returns the string "User" for personal GitHub accounts and "Organization" for collective accounts. The JavaScript core logic in js/githubresume.js reads this value from data.type to drive all subsequent rendering decisions.
Template Selection Logic in githubresume.js
The core client-side logic resides in js/githubresume.js, where the application evaluates the account type to determine which HTML template to load.
Detecting Account Type from API Data
After fetching the profile data, the application extracts the account type from the nested data object:
github_user(username, function(data) {
data = data.data; // GitHub wraps payload in .data
var accountType = data.type; // "User" or "Organization"
// …
});
Choosing the Appropriate Resume Template
The application uses a ternary operator to select between two distinct Mustache templates based on the data.type value:
var resume = (data.type == 'User'
? 'views/resume.html'
: 'views/resumeOrgs.html');
$.ajax({
url: resume,
dataType: 'html',
success: function(tpl) {
$('#resume').html(Mustache.to_html(tpl, view));
}
});
When the account type is "Organization", the UI renders views/resumeOrgs.html, which displays organization-specific sections such as member repositories. Personal users receive the standard views/resume.html template.
Rendering Differences Between Users and Organizations
Beyond template selection, the account type triggers specific handling for avatars and view data preparation.
Avatar URL Handling
Organizations require different Gravatar URL formatting. The application checks data.type before manipulating the avatar URL:
var avatar = '';
if (data.type == 'Organization') {
// Organizations use a Gravatar URL that falls back to the default GitHub avatar
avatar = data.avatar_url
.match(/https:\/\/secure.gravatar.com\/avatar\/[0-9a-z]+/)[0];
avatar += '?s=140&d=https://github.com/images/gravatars/gravatar-140.png';
}
View Data Preparation
The application exposes the account type to the Mustache template through the view object, allowing templates to conditionally display "User" or "Organization" labels:
var view = {
type: data.type,
// … other view properties
};
Summary
- The application differentiates between User and Organization accounts by reading the
typeproperty from the GitHub API response. - In
js/githubresume.js, thedata.typevalue drives template selection, choosingviews/resume.htmlfor Users andviews/resumeOrgs.htmlfor Organizations. - Organization accounts receive special handling for avatar URL formatting to ensure proper Gravatar fallback images.
- The account type is passed to Mustache templates via the
viewobject, enabling conditional rendering based on whether the profile represents a User or Organization.
Frequently Asked Questions
How does resume.github.com determine if a GitHub profile is a User or Organization?
The application examines the type field in the GitHub API response. When fetching profile data, the API returns "User" for personal accounts and "Organization" for collective accounts. The JavaScript code in js/githubresume.js checks data.type to make this determination at runtime.
What templates are used for User versus Organization accounts?
Personal User accounts render using views/resume.html, while Organization accounts use views/resumeOrgs.html. This selection occurs in js/githubresume.js through a conditional check: var resume = (data.type == 'User' ? 'views/resume.html' : 'views/resumeOrgs.html');.
Why does the application handle avatar URLs differently for Organizations?
Organizations require specific Gravatar URL formatting with fallback parameters to ensure the default GitHub avatar displays correctly when no custom image exists. The code in js/githubresume.js specifically checks if (data.type == 'Organization') before applying regex matching and appending the ?s=140&d= query parameters to the avatar URL.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →