Skip to content

Commit

Permalink
Merge pull request #85 from curbengh/url_for
Browse files Browse the repository at this point in the history
refactor: utilize url_for
  • Loading branch information
curbengh committed Aug 9, 2020
2 parents a74b9cc + 93d1955 commit 291053b
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions layout/_partial/archive.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ if (page.archive){
<div class="post-content">
<header>
<div class="icon"></div>
<time datetime="<%= item.date.toDate().toISOString() %>"><a href="<%- config.root %><%- item.path %>"><%= item.date.format(config.date_format) %></a></time>
<time datetime="<%= item.date.toDate().toISOString() %>"><a href="<%- url_for(item.path) %>"><%= item.date.format(config.date_format) %></a></time>
<% if (item.link){ %>
<% if (item.title){ %>
<h1 class="title link"><a href="<%- item.link %>" target="_blank"><%= item.title %></a></h1>
<% } else { %>
<h1 class="title link"><a href="<%- item.link %>" target="_blank"><%= item.link %></a></h1>
<% } %>
<% } else { %>
<h1 class="title"><a href="<%- config.root %><%- item.path %>"><%= item.title %></a></h1>
<h1 class="title"><a href="<%- url_for(item.path) %>"><%= item.title %></a></h1>
<% } %>
</header>
</div>
Expand Down
4 changes: 2 additions & 2 deletions layout/_partial/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<header>
<% if (item.layout != 'page'){ %>
<div class="icon"></div>
<time class="dt-published" datetime="<%= item.date.toDate().toISOString() %>"><a href="<%- config.root %><%- item.path %>"><%= item.date.format(config.date_format) %></a></time>
<time class="dt-published" datetime="<%= item.date.toDate().toISOString() %>"><a href="<%- url_for(item.path) %>"><%= item.date.format(config.date_format) %></a></time>
<% } %>
<%- partial('post/title') %>
</header>
Expand All @@ -21,7 +21,7 @@
<% if (index){ %>
<% if (item.excerpt){ %>
<div class="alignleft">
<a href="<%- config.root %><%- item.path %>#more" class="more-link"><%= theme.excerpt_link %></a>
<a href="<%- url_for(item.path) %>#more" class="more-link"><%= theme.excerpt_link %></a>
</div>
<% } %>
<% if (item.comment && config.disqus_shortname){ %>
Expand Down
4 changes: 2 additions & 2 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<meta property="og:image" content="<%= config.cover %>"/>
<% } %>

<link href="<%- config.root %>favicon.png" rel="icon">
<link rel="alternate" href="<% if (theme.rss){ %><%- theme.rss %><% } else { %><%- config.root %>atom.xml<% } %>" title="<%= config.title %>" type="application/atom+xml">
<%- favicon_tag('favicon.png') %>
<link rel="alternate" href="<% if (theme.rss){ %><%- theme.rss %><% } else { %><%- url_for('atom.xml') %><% } %>" title="<%= config.title %>" type="application/atom+xml">
<%- css('css/style.css') %>
<!--[if lt IE 9]><script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script><![endif]-->
<%- partial('google_analytics') %>
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<nav id="main-nav" class="alignright">
<ul>
<% for (var i in theme.menu){ %>
<li><a href="<%- config.root %><%- theme.menu[i] %>"><%= i %></a></li>
<li><a href="<%- url_for(theme.menu[i]) %>"><%= i %></a></li>
<% } %>
</ul>
<div class="clearfix"></div>
Expand Down
4 changes: 2 additions & 2 deletions layout/_partial/pagination.ejs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<nav id="pagination">
<% if (page.prev){ %>
<a href="<%- config.root %><%- page.prev_link %>" class="alignleft prev"><%= __('prev') %></a>
<a href="<%- url_for(page.prev_link) %>" class="alignleft prev"><%= __('prev') %></a>
<% } %>
<% if (page.next){ %>
<a href="<%- config.root %><%- page.next_link %>" class="alignright next"><%= __('next') %></a>
<a href="<%- url_for(page.next_link) %>" class="alignright next"><%= __('next') %></a>
<% } %>
<div class="clearfix"></div>
</nav>
2 changes: 1 addition & 1 deletion layout/_partial/post/category.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%
var cats = [];
item.categories.forEach(function(cat){
cats.push('<a href="' + config.root + cat.path + '">' + cat.name + '</a>');
cats.push('<a href="' + url_for(cat.path) + '">' + cat.name + '</a>');
});
%>
<div class="categories">
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/post/tag.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%
var tags = [];
item.tags.forEach(function(tag){
tags.push('<a href="' + config.root + tag.path + '">' + tag.name + '</a>');
tags.push('<a href="' + url_for(tag.path) + '">' + tag.name + '</a>');
});
%>
<div class="tags">
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/post/title.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<% } %>
<% } else { %>
<% if (index){ %>
<h1 class="title"><a href="<%- config.root %><%- item.path %>"><%= item.title %></a></h1>
<h1 class="title"><a href="<%- url_for(item.path) %>"><%= item.title %></a></h1>
<% } else { %>
<h1 class="p-name title" itemprop="headline name"><%= item.title %></h1>
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/category.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h3 class="title"><%= __('categories') %></h3>
<ul class="entry">
<% site.categories.sort('name').each(function(item){ %>
<li><a href="<%- config.root %><%- item.path %>"><%= item.name %></a><small><%= item.posts.length %></small></li>
<li><a href="<%- url_for(item.path) %>"><%= item.name %></a><small><%= item.posts.length %></small></li>
<% }); %>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/recent_posts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ul class="entry">
<% site.posts.sort('date', -1).limit(5).each(function(post){ %>
<li>
<a href="<%= config.root %><%= post.path %>"><%= post.title %></a>
<a href="<%- url_for(post.path) %>"><%= post.title %></a>
</li>
<% }); %>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/tag.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h3 class="title"><%= __('tags') %></h3>
<ul class="entry">
<% site.tags.sort('name').each(function(item){ %>
<li><a href="<%- config.root %><%- item.path %>"><%= item.name %></a><small><%= item.posts.length %></small></li>
<li><a href="<%- url_for(item.path) %>"><%= item.name %></a><small><%= item.posts.length %></small></li>
<% }); %>
</ul>
</div>
Expand Down

0 comments on commit 291053b

Please sign in to comment.