Skip to content

Commit

Permalink
Add uri() method to file class.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Jun 14, 2024
1 parent 34a0be8 commit deaa98d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/App/Aphra/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use File::Path 'make_path';
use File::Copy;
use Text::FrontMatter::YAML;
use Path::Tiny ();
use URI;

has [qw[path name extension ]] => (
isa => 'Str',
Expand Down Expand Up @@ -88,6 +89,19 @@ sub full_name {
return $full_name;
}

sub uri {
my $self = shift;

my $uri = $self->app->uri;
my $path = $self->destination_dir;
my $base = $self->app->site_vars->{base};
$path =~ s/^$base//;
$uri .= $path . $self->output_name;
$uri =~ s/index\.html$//;

return URI->new($uri);
}

sub process {
my $self = shift;

Expand Down
1 change: 1 addition & 0 deletions t/data1/site.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
uri : https://example.com/
base : docs

0 comments on commit deaa98d

Please sign in to comment.