Skip to content

Commit

Permalink
Better JSON-LD
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed May 2, 2019
1 parent 78bc2e8 commit 6a642e9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions in/character.tt
@@ -1,5 +1,7 @@
[% META title = 'Character' %]

<script type="application/ld+json">
[% character.json_ld %]</script>
<p class="text-muted">[% template.title or 'Literature on TV' %]</p>

<h1 class="display-3">[% character.name %]</h1>
Expand Down
4 changes: 3 additions & 1 deletion lib/Literature/Schema/Result/Actor.pm
Expand Up @@ -139,7 +139,9 @@ sub slug_cols { return qw[name]; }
sub json_ld_type { 'Person' }

sub json_ld_fields {
[ qw[ name ] ]
[ 'name',
{ birthDate => sub { $_[0]->born->strftime('%Y-%m-%d') } },
]
}

# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
5 changes: 4 additions & 1 deletion lib/Literature/Schema/Result/Author.pm
Expand Up @@ -149,7 +149,10 @@ sub slug_cols { return qw[name]; }
sub json_ld_type { 'Person' }

sub json_ld_fields {
[ qw[ name ] ]
[
'name',
{ birthDate => sub { $_[0]->born->strftime('%Y-%m-%d') } },
]
}

# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
8 changes: 7 additions & 1 deletion lib/Literature/Schema/Result/Character.pm
Expand Up @@ -125,10 +125,16 @@ __PACKAGE__->many_to_many("works", "character_appearances", "work");
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2019-04-20 15:23:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DEr25X61p2zl9TDdZeBawQ

with 'Literature::Role::HasSlug';
with 'Literature::Role::HasSlug', 'MooX::Role::JSON_LD';

sub slug_cols { return qw[name]; }

sub json_ld_type { 'Person' }

sub json_ld_fields {
[ qw[ name ] ]
}

# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
1;

0 comments on commit 6a642e9

Please sign in to comment.