in src/PageSections/FrontMatter.hack [23:58]
public function getMarkdown(): ?string {
$config = $this->context->getConfiguration()['frontMatter'] ?? null;
if ($config === null) {
return null;
}
$fields = $config['constantFields'] ?? dict[];
$def = $this->documentable['definition'];
$fields['title'] = $def->getName();
$path = get_path_for_documentable(
$this->context->getPathProvider(),
$this->documentable,
);
if ($path is nonnull) {
// Docusaurus
$fields['id'] = \basename($path)
|> Str\strip_suffix($$, '.md')
|> Str\strip_suffix($$, '.html');
// Jekyll
$fields['docid'] = $fields['id'];
$pp = $config['permalinkPrefix'] ?? null;
if ($pp !== null) {
if ($path !== null) {
$fields['permalink'] = $pp.$path
|> Str\strip_suffix($$, '.md')
|> Str\strip_suffix($$, '.html')
|> $$.'/';
}
}
}
return Dict\map_with_key($fields, ($k, $v) ==> $k.': '.$v)
|> Str\join($$, "\n")
|> "---\n".$$."\n---\n";
}