1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-06 06:07:31 +02:00

Fix error with folders transform posts and page

This commit is contained in:
trendschau
2022-04-09 15:29:03 +02:00
parent f2a474a3cc
commit dfb356d902
16 changed files with 155 additions and 12 deletions

View File

@@ -258,9 +258,10 @@ class WriteMeta extends WriteYaml
return $description;
}
public function transformPagesToPosts($folder){
public function transformPagesToPosts($folder)
{
$filetypes = array('md', 'txt', 'yaml');
$result = true;
foreach($folder->folderContent as $page)
{
@@ -294,13 +295,11 @@ class WriteMeta extends WriteYaml
# create new file-name without filetype
$newFile = $this->basePath . 'content' . $folder->path . DIRECTORY_SEPARATOR . $datetime . '-' . $page->slug;
$result = true;
foreach($filetypes as $filetype)
{
$oldFilePath = $oldFile . '.' . $filetype;
$newFilePath = $newFile . '.' . $filetype;
#check if file with filetype exists and rename
if($oldFilePath != $newFilePath && file_exists($oldFilePath))
{
@@ -315,12 +314,15 @@ class WriteMeta extends WriteYaml
}
}
}
return $result;
}
public function transformPostsToPages($folder){
public function transformPostsToPages($folder)
{
$filetypes = array('md', 'txt', 'yaml');
$index = 0;
$result = true;
foreach($folder->folderContent as $page)
{
@@ -337,8 +339,6 @@ class WriteMeta extends WriteYaml
# create new file-name without filetype
$newFile = $this->basePath . 'content' . $folder->path . DIRECTORY_SEPARATOR . $order . '-' . $page->slug;
$result = true;
foreach($filetypes as $filetype)
{
$oldFilePath = $oldFile . '.' . $filetype;
@@ -360,5 +360,20 @@ class WriteMeta extends WriteYaml
$index++;
}
return $result;
}
public function folderContainsFolders($folder)
{
foreach($folder->folderContent as $page)
{
if($page->elementType == 'folder')
{
return true;
}
}
return false;
}
}