Skip to content

Commit

Permalink
Fix #359 on this end too
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Aug 8, 2022
1 parent 80dcf18 commit a271e5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 9 additions & 1 deletion packages/framework/src/Models/Metadata/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected function addMetadataForMarkdownPost(MarkdownPost $page): void
}

if ($page->has('image')) {
$this->add(Meta::property('image', optional($page->image)->getLink()));
$this->add(Meta::property('image', $this->resolveImageLink($page->get('image'))));
}

$this->add(Meta::property('type', 'article'));
Expand All @@ -132,4 +132,12 @@ protected function getPrefixedArray(string $group): array

return $array;
}

protected function resolveImageLink(String $image): string
{
// Since this is run before the page is rendered, we don't have the currentPage property
// but since we know that this is for a blog post we know what the property will be
// since Hyde does not currently support custom Blog post output directories.
return str_starts_with($image, 'http') ? $image : "../$image";
}
}
3 changes: 1 addition & 2 deletions packages/framework/tests/Feature/MetadataViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ public function test_metadata_tags_in_markdown_post_with_flat_front_matter()
'<meta property="og:url" content="http://localhost/posts/test.html">',
'<meta property="og:type" content="article">',
'<meta property="og:article:published_time" content="2022-01-01T00:00:00+00:00">',
// @todo fix #359 '<meta property="og:image" content="../media/image.jpg">',
'<meta property="og:image" content="media/image.jpg">',
'<meta property="og:image" content="../media/image.jpg">',
'<meta itemprop="identifier" content="test">',
'<meta itemprop="url" content="http://localhost/posts/test">',
'<meta itemprop="url" content="../media/image.jpg">',
Expand Down

0 comments on commit a271e5d

Please sign in to comment.