@ -312,7 +312,7 @@ sub do_blog_page_edit ( $c ) {
my ( $blog_page ) = grep { $_->rel_path eq $rel_path } @{$blog_pages};
if ( ! $c->stash->{blog_page} ) {
if ( ! $blog_page ) {
$c->redirect_to( $c->url_for( 'show_dashboard_blog_pages', { id => $blog->id } ) );
return;
}
@ -360,7 +360,7 @@ sub do_blog_page ( $c ) {
my $jekyll = $c->jekyll($blog->domain->name);
my $page = $jekyll->new_page( $path );
my $page = $jekyll->new_page( "/$path.markdown" );
$page->set_headers_from_string( $headers );
$page->markdown( $content );
@ -6,8 +6,15 @@
<form method="POST" action="<%= $c->url_for( 'do_dashboard_blog_page' ) %>">
<div class="mt-3 mb-3">
<label for="pagePath" class="col-sm-2 col-form-label">File Path</label>
<input type="text" class="form-control" id="pagePath" name="pagePath" value="">
<label for="pagePath" class="col-form-label">
File Path -
The path for the page, for example enter <span class="fw-bolder">about</span> for a URL like about.html (then, if you want, use permLink: /about/ in Page Headers for a clean url)
</label>
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">https://<%= $blog->domain->name %>/</span>
<span class="input-group-text" id="basic-addon2">.html</span>
</div>
<div class="mb-3">
@ -48,7 +48,7 @@
<tbody>
% for my $page ( @{$blog_pages} ) {
<tr>
<td><%= $page->filename %></td>
<td><%= $page->rel_path %></td>
<td><a class="btn btn-sm btn-primary" href="<%= $c->url_for( 'show_dashboard_blog_page_edit', { id => $blog->id } )->query( file => $page->rel_path ) %>">Edit Page</a></td>
<td>
<form style="margin-top: 1.5em; display: inline;" method="POST" action="<%= $c->url_for( 'do_dashboard_blog_page_remove' ) %>">
@ -1,6 +1,7 @@
package MJB::Backend::Jekyll::MarkdownFile;
use Moo;
use YAML::XS qw( Load Dump );
use Mojo::File;
# File path we are read/write from
has path => (
@ -92,6 +93,9 @@ sub write {
$file ||= $self->path;
# Make directory if it doesn't exist.
Mojo::File->new( $file )->dirname->make_path;
open my $sf, ">", $file
or die "Failed to open $file for writing: $!";