Skip to content

Commit

Permalink
Added JSON-LD to more pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Apr 25, 2019
1 parent cf6a27f commit d2cf4f3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions in/production.tt
@@ -1,5 +1,7 @@
[% META title = 'Production' %]

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

<h1 class="display-3">[% production.title %]</h1>
Expand Down
2 changes: 2 additions & 0 deletions in/work.tt
@@ -1,5 +1,7 @@
[% META title = 'Work' %]

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

<h1 class="display-3">[% work.title %]</h1>
Expand Down
13 changes: 12 additions & 1 deletion lib/Literature/Schema/Result/Production.pm
Expand Up @@ -165,10 +165,21 @@ __PACKAGE__->belongs_to(
# Created by DBIx::Class::Schema::Loader v0.07048 @ 2019-04-25 14:55:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Hszq6UGmkAh+2J8hRr9BzQ

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

sub slug_cols { return qw[title year]; }

sub json_ld_type {
return {
'Film' => 'Movie',
'TV Series' => 'TVSeries',
}->{$_[0]->type};
}

sub json_ld_fields {
return [ { name => 'title' } ];
}

around title => sub {
my $orig = shift;
my $self = shift;
Expand Down
5 changes: 4 additions & 1 deletion lib/Literature/Schema/Result/Work.pm
Expand Up @@ -218,10 +218,13 @@ __PACKAGE__->many_to_many(
# Created by DBIx::Class::Schema::Loader v0.07048 @ 2019-04-25 14:55:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xtnwNE+fA9uoIHf4kCRPeA

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

sub slug_cols { return qw[title]; }

sub json_ld_type { $_[0]->type }
sub json_ld_fields { [ { name => 'title' } ] }

sub asins {
my $self = shift;

Expand Down

0 comments on commit d2cf4f3

Please sign in to comment.