Class: Willamette::Builders::AuthorExtension

Inherits:
Bridgetown::Builder
  • Object
show all
Defined in:
lib/willamette/builders/author_extension.rb

Instance Method Summary collapse

Instance Method Details

#author_nameObject

rubocop:todo Metrics/CyclomaticComplexity



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/willamette/builders/author_extension.rb', line 7

def author_name # rubocop:todo Metrics/CyclomaticComplexity
  anon = "Anonymous"
  return anon unless resource

  resource_author = resource.data.author
  found_author = case resource_author
                 when String
                   site.signals.authors ?
                     site.signals.authors[resource_author]&.name :
                     resource_author
                 when Hash
                   resource_author.name
                 end

  found_author ||  || anon
end

#buildObject



3
4
5
# File 'lib/willamette/builders/author_extension.rb', line 3

def build
  define_resource_method :author_name
end

#default_metadataObject



24
25
26
27
28
29
30
31
# File 'lib/willamette/builders/author_extension.rb', line 24

def 
  case site..author
  when String
    site..author
  when Hash
    site..author.name
  end
end