Skip to content

Commit 09d3a6e

Browse files
committed
Update post creator to assemble front matter
1 parent 78797af commit 09d3a6e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

app/Filament/Pages/Experiments/GitHubPostCreator.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function mount(): void
9191
public function create(): void
9292
{
9393
$repository = $this->getRepositoryUrl();
94-
$markdown = $this->content; // Todo assemble front matter
94+
$markdown = "{$this->assembleFrontMatter()}\n\n{$this->content}";
9595
$url = sprintf('%s/new/%s/_posts?%s', $repository, $this->branch, http_build_query([
9696
'filename' => Str::slug($this->postTitle).'.md',
9797
'value' => $markdown,
@@ -133,4 +133,14 @@ protected function feedbackUrl(): string
133133
'labels' => 'feedback',
134134
]);
135135
}
136+
137+
protected function assembleFrontMatter(): string
138+
{
139+
return implode("\n", [
140+
'---',
141+
sprintf("title: '%s'", $this->postTitle),
142+
sprintf("date: '%s'", now()->format('Y-m-d H:i:s')),
143+
'---',
144+
]);
145+
}
136146
}

0 commit comments

Comments
 (0)