Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
_site
.sass-cache
Gemfile.lock
_site/
.sass-cache/
.jekyll-cache/
.jekyll-metadata
node_modules/
dist/
.env
__pycache__/
*.log
.DS_Store
45 changes: 45 additions & 0 deletions _tests/author_display_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'jekyll'
require 'minitest/autorun'

class AuthorDisplayTest < Minitest::Test
def setup
@site = Jekyll::Site.new(Jekyll.configuration({
'source' => '.',
'destination' => './_site'
}))
@site.read
@site.generate
end

def test_post_specific_author
post_with_author = @site.posts.docs.find { |post| post.data['author'] }
if post_with_author
assert_includes post_with_author.output, "By #{post_with_author.data['author']}",
"Post with specific author should display author name"
end
end

def test_fallback_site_author
# Simulate a scenario with site-wide author
@site.config['author'] = 'Site Admin'
@site.generate

post_without_author = @site.posts.docs.find { |post| !post.data['author'] }
if post_without_author
assert_includes post_without_author.output, "By Site Admin",
"Posts without author should use site-wide author"
end
end

def test_anonymous_author
# Remove site-wide author
@site.config.delete('author')
@site.generate

post_without_author = @site.posts.docs.find { |post| !post.data['author'] }
if post_without_author
assert_includes post_without_author.output, "By Anonymous",
"Posts without author and no site-wide author should show Anonymous"
end
end
end
17 changes: 13 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
---
layout: default
---


{% for post in site.posts limit:site.data.theme.num_home_posts %}
<div class="post-header-home">
<h1 class="post-title-home">
<a href="{{ post.url }}">{{ post.title }}</a>
</h1>
{% include post-header-home.html %}
<div class="post-meta-home">
{% if post.author %}
<span class="post-author">By {{ post.author }}</span>
{% elsif site.author %}
<span class="post-author">By {{ site.author }}</span>
{% else %}
<span class="post-author">By Anonymous</span>
{% endif %}
{% include post-header-home.html %}
</div>
</div>
<div class="post-excerpt-home">
{% assign excerpt_content = post.content | replace: '_By Al Morris_', '' | replace: 'By Al Morris', '' | replace: '*By Al Morris*', '' | strip_html | truncatewords: 50 %}
Expand All @@ -17,5 +26,5 @@ <h1 class="post-title-home">
{% endfor %}
<hr>
<div class="home-read-more">
<a href="{{ "/archive" }}" class="btn btn-primary btn-block btn-lg">View All {{ site.posts | size }} Articles →</a>
</div>
<a href="{{ "/archive" }}" class="btn btn-primary btn-block btn-lg">View All {{ site.posts | size }} Articles →</a>
</div>