Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

Commit

Permalink
feat(ngdocs): adds image option to the navbar for custom image
Browse files Browse the repository at this point in the history
This feature adds an image to the top navbar as well as an optional link
url for the title and image.
  • Loading branch information
steelsojka committed Sep 5, 2013
1 parent 9564faf commit 1e2a8f7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ ngdocs: {
html5Mode: true,
startPage: '/api',
title: "My Awesome Docs",
image: "path/to/my/image.png",
imageLink: "http://my-domain.com",
titleLink: "/api",
analytics: {
account: 'UA-08150815-0',
domainName: 'my-domain.com'
Expand Down Expand Up @@ -96,6 +99,17 @@ Set first page to open.
[default] 'true'
Whether or not to enable `html5Mode` in the docs application. If true, then links will be absolute. If false, they will be prefixed by `#/`.

####image
A URL or relative path to an image file to use in the top navbar.

####titleLink
[default] no anchor tag is used
Wraps the title text in an anchor tag with the provided URL.

####imageLink
[default] no anchor tag is used
Wraps the navbar image in an anchor tag with the provided URL.

####animation
[default] 'false' or 'true' for the included angularjs, angularjs 1.1.5+ from CDN or a folder like /vendor/angular-1.1.5/angular.js.
Set to 'true' to enable animations in the sidebar.
Expand Down
9 changes: 9 additions & 0 deletions src/templates/css/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ img.AngularJS-small {
line-height: 18px
}

.header img {
max-height: 40px;
padding-right: 20px;
}

.header img+.brand {
padding: 10px 20px 10px 10px;
}

.clear-navbar {
margin-top: 60px;
}
Expand Down
13 changes: 11 additions & 2 deletions src/templates/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,17 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<% if (title) { %>
<a class="brand"><%= title %></a>
<% if (image) { %>
<% if (imageLink) { %>
<a href="<%= imageLink %>">
<% } %>
<img class="pull-left" src="<%= image %>">
<% if (imageLink) { %>
</a>
<% } %>
<% } %>
<% if (title) {%>
<a <% if (titleLink) { %> href="<%= titleLink %>" <% } %> class="brand"><%= title %></a>
<% } %>
<ul class="nav">
<li ng-repeat="(url, name) in sections" ng-class="{active: isActivePath(url)}">
Expand Down
10 changes: 10 additions & 0 deletions tasks/grunt-ngdocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ module.exports = function(grunt) {
}
});

if (options.image) {
if (!/^((https?:)?\/\/|\.\.\/)/.test(options.image)) {
grunt.file.copy(options.image, path.join(options.dest, 'img', options.image));
options.image = "img/" + options.image;
}
}

options.styles = _.map(options.styles, function(file) {
if (/^((https?:)?\/\/|\.\.\/)/.test(file)) {
return file;
Expand Down Expand Up @@ -137,6 +144,9 @@ module.exports = function(grunt) {
analytics: options.analytics,
navContent: options.navContent,
title: options.title,
image: options.image,
titleLink: options.titleLink,
imageLink: options.imageLink,
trackBy: function(id, animation) {
return options.animation ? ' track by ' + id + (animation ? '" ng-animate="' + animation : '') : '';
}
Expand Down

0 comments on commit 1e2a8f7

Please sign in to comment.