2014-08-27 102 views
0

有沒有辦法將博客文章直接鏈接到pdf,而不是轉到html頁面。Jekyll博客文章鏈接到PDF?

{% for post in site.posts %} 
     <li> 
     <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span> 
     <h2> 
      <a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a> 
     </h2> 
     {{ post.excerpt }} 
     </li> 
{% endfor %} 

我想用一個不同的URL爲post.url現場,這樣如果用戶點擊鏈接後,他就直接進入到PDF。

回答

2

您可以在需要鏈接到文檔的帖子中添加自定義變量,然後有條件地鏈接到帖子或文檔。

您的文章

--- 
layout: post 
title: "Post one" 
docurl: assets/pdf/test.pdf 
--- 

this the post excerpt 

this is the maybe useless post body 

您的文章列表:

<ul> 
    {% for post in site.posts %} 
    {% if post.docurl %} 
     <li><a href="{{ site.baseurl }}{{ post.docurl }}">{{ post.title }}</a></li> 
    {% else %} 
     <li><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></li> 
    {% endif %} 
    {{ post.excerpt }} 
    {% endfor %} 
</ul> 

但我認爲,在其他問題就出來了:關於用戶體驗(UX)是什麼? 您確實需要清楚地表明您的鏈接將打開PDF而不是頁面。

相關問題