Skip to content

Commit deaa98d

Browse files
committed
Add uri() method to file class.
1 parent 34a0be8 commit deaa98d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/App/Aphra/File.pm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use File::Path 'make_path';
77
use File::Copy;
88
use Text::FrontMatter::YAML;
99
use Path::Tiny ();
10+
use URI;
1011

1112
has [qw[path name extension ]] => (
1213
isa => 'Str',
@@ -88,6 +89,19 @@ sub full_name {
8889
return $full_name;
8990
}
9091

92+
sub uri {
93+
my $self = shift;
94+
95+
my $uri = $self->app->uri;
96+
my $path = $self->destination_dir;
97+
my $base = $self->app->site_vars->{base};
98+
$path =~ s/^$base//;
99+
$uri .= $path . $self->output_name;
100+
$uri =~ s/index\.html$//;
101+
102+
return URI->new($uri);
103+
}
104+
91105
sub process {
92106
my $self = shift;
93107

t/data1/site.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
uri : https://example.com/
2+
base : docs

0 commit comments

Comments
 (0)