Get title automatically from first markdown title if not set in meta
This commit is contained in:
parent
ec37ff4e75
commit
dee3ec7cfe
1 changed files with 13 additions and 1 deletions
14
lib/pico.php
14
lib/pico.php
|
@ -164,6 +164,18 @@ class Pico {
|
|||
}
|
||||
|
||||
if($headers['date']) $headers['date_formatted'] = date($config['date_format'], strtotime($headers['date']));
|
||||
|
||||
if(empty($headers['title'])){
|
||||
preg_match('/^(.+?)[ ]*\n(=+|-+)[ ]*\n+/imu',$content,$matches);
|
||||
if(count($matches) > 0){
|
||||
$headers['title'] = $matches[1];
|
||||
}else{
|
||||
preg_match('/^\#{1}([^\#].*)$/imu',$content,$matches);
|
||||
if(count($matches) > 0){
|
||||
$headers['title'] = $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
@ -336,4 +348,4 @@ class Pico {
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Add table
Reference in a new issue