The quick and dirty answer would be something like this:
function custom_admin_menu_links() {
$user = wp_get_current_user();
if ( $user->has_cap( 'manage_options' ) ) {
$type = 'book';
$page = get_page_by_title('home','object',$type);
if (!empty($page)) {
add_menu_page( 'Home', 'Home', 'edit_posts', 'post.php?post='.$page->ID.'&action=edit', '', 'dashicons-admin-home', 1);
}
$page = get_page_by_title('About','object',$type);
if (!empty($page)) {
add_menu_page( 'About', 'About', 'edit_posts', 'post.php?post=8&action=edit', '', 'dashicons-id', 2);
}
$page = get_page_by_title('Contact','object',$type);
if (!empty($page)) {
add_menu_page( 'Contact', 'Contact', 'edit_posts', 'post.php?post=10&action=edit', '', 'dashicons-phone', 3);
}
}
}
add_action( 'admin_menu', 'custom_admin_menu_links' );
But you are running a lot of queries on every admin page load. You really should work out a way to cache the results. Something like:
function cache_custom_admin_menu_links($post_ID, $post) {
$links = get_option('my_menu_links');
$keys = array(
'home',
'about',
'contact'
);
if (in_array($post->post_name,$keys)) {
$links[$post->post_name] = $post_ID;
update_option('my_menu_links',$links);
}
}
add_action('save_post','cache_custom_admin_menu_links',10,2);
function custom_admin_menu_links() {
$user = wp_get_current_user();
if ( $user->has_cap( 'manage_options' ) ) {
$type = 'book';
$links = get_option('my_menu_links');
$i = 1;
foreach ($links as $k=>$v) {
add_menu_page( $k, ucfirst($k), 'edit_posts', 'post.php?post='.$v.'&action=edit', '', 'dashicons-phone', $i);
$i++;
}
}
}
add_action( 'admin_menu', 'custom_admin_menu_links' );
Then you just have to resave your posts rather than edit the code. I am sure even that could be automated if you needed it to be.