Skip to content

Commit

Permalink
Use local path as GUID
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Nov 5, 2024
1 parent 58150bb commit ddf2406
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/playground/data-liberation/docs-importer-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ function import_markdown_files() {

$directory_indexes = [];
foreach(wp_visit_file_tree($root_dir) as $event) {
$is_root = $event->dir->getPathName() === $root_dir;
if($is_root) {
continue;
}
if($event->isExiting()) {
// Clean up stale IDs to save some memory when processing
// large directory trees.
Expand Down Expand Up @@ -54,7 +58,6 @@ function import_markdown_files() {

$parent_path = dirname($event->dir->getRealPath());
$parent_id = $directory_indexes[$parent_path] ?? null;
$relative_path = substr($event->dir->getRealPath(), strlen($root_dir));

if(null !== $directory_index_idx) {
array_splice($files, $directory_index_idx, 1)[0];
Expand All @@ -63,7 +66,7 @@ function import_markdown_files() {
file_get_contents($file->getRealPath()),
$next_post_id,
$parent_id,
$relative_path,
$file->getPathName(),
slug_to_title($file->getFilename()),
);
} else {
Expand All @@ -74,7 +77,7 @@ function import_markdown_files() {
'',
$next_post_id,
$parent_id,
$relative_path,
$event->dir->getPathName(),
slug_to_title($event->dir->getFilename()),
);
}
Expand All @@ -89,7 +92,7 @@ function import_markdown_files() {
file_get_contents($file->getRealPath()),
$next_post_id,
$directory_index_id,
$relative_path,
$file->getPathName(),
$title_fallback
);
++$next_post_id;
Expand Down Expand Up @@ -137,7 +140,7 @@ function import_markdown_file(
$entity_data = array(
'post_id' => $post_id,
'post_type' => 'page',
'guid' => $frontmatter['slug'] ?? 'README',
'guid' => $guid,
'post_title' => $post_title,
'post_content' => $block_markup,
'post_excerpt' => $frontmatter['description'] ?? '',
Expand Down

0 comments on commit ddf2406

Please sign in to comment.