diff --git a/.gitignore b/.gitignore index 76a0bf1..54abb61 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ -_site -.sass-cache -Gemfile.lock +_site/ +.sass-cache/ +.jekyll-cache/ +.jekyll-metadata +node_modules/ +dist/ +.env +__pycache__/ +*.log +.DS_Store \ No newline at end of file diff --git a/_tests/author_display_test.rb b/_tests/author_display_test.rb new file mode 100644 index 0000000..cdb52c2 --- /dev/null +++ b/_tests/author_display_test.rb @@ -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 \ No newline at end of file diff --git a/index.html b/index.html index 6fbffb3..573ec99 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,22 @@ --- +layout: default --- - {% for post in site.posts limit:site.data.theme.num_home_posts %}