package SCSite::Page;

use IO::All;
use Time::Local qw(timelocal);
use Moo;

with 'SCSite::PageChildren';

has $_ => (is => 'ro') for qw(
  title subtitle description keywords body created path
);

sub published_at {
  $_[0]->created
    ? scalar localtime timelocal
        map +(@{$_}[0..3], $_->[4]-1, $_->[5]-1900),
          [ reverse split '\D+', $_[0]->created ]
    : ''
}

has "_$_" => (is => 'ro', init_arg => $_) for qw(page_set);

sub _page_set_class { ref($_[0]->_page_set) }
sub _top_dir { $_[0]->_page_set->top_dir }
sub _my_path { io->dir($_[0]->_top_dir)->catdir($_[0]->path) }

1;
