htmly
htmly copied to clipboard
Just a question. How do I import an already made MD into HTMLy?
Before I asked in issues I did look for a forum.
Rick
Please read:
- https://github.com/danpros/htmly#both-online-or-offline
- https://github.com/danpros/htmly#category
- https://github.com/danpros/htmly#file-naming-convention
- https://github.com/danpros/htmly#content-tags
Basically you have to copy and adapt the following code to your needs, add the code to obtain your MD through a form and add a new admin menu item to invoke the importing code from the admin UI. This code will not work for you but I used it in my web site for autoposting:
// Add content function add_my_content($title, $post_tag, $pmid, $content, $description = null, $category, $type) { $post_date = date('Y-m-d-H-i-s');
/* Deal with title */ $post_title = "\n<!--t " . $title . " t-->"; /* Deal with short description */ $post_description = "\n<!--d " . $description . " d-->"; /* Deal with tag */ $posttag = "\n<!--tag " . $post_tag . " tag-->"; /* Deal with desired URL */ $target_URL = preg_replace("/[^A-Za-z0-9]/", '-', $pmid); /* Deal with content */ $post_content = $post_title . $post_description . $posttag . "\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($pmid) && !empty($post_content)) { if (get_magic_quotes_gpc()) { $post_content = stripslashes($post_content); } $filename = $post_date . '_' . $post_tag . '_' . $target_URL . '.md'; $dir = __DIR__ . '/../../content/admin/blog/english/post/'; // We now search if a file with the same pmid had already been posted $matches = glob($dir . '????-??-??-??-??-??_??????_' . $pmid . '.md'); // If $matches == false, then there is no such file in the content database // If $matches != false, there is already a file with this pmid, so we do nothing if ($matches == false) { if (is_dir($dir)) { $resfpc = file_put_contents($dir . $filename, print_r($post_content, true)); if ($resfpc === false) { echo '<br>Failure 1 in writing content at: ' . $dir; die(); } } else { mkdir($dir, 0775, true); $resfpc = file_put_contents($dir . $filename, print_r($post_content, true)); if ($resfpc === false) { echo '<br>Failure 2 in writing content at: ' . $dir; die(); } } // Clear cache $files = glob(__DIR__ . '/../../cache/index/*'); // get all file names foreach ($files as $file) { // iterate files if (is_file($file)) { unlink($file); // delete file } } } } // https://yourdomain2021/08/desiredurl return '/' . date('Y/m') . '/' . $target_URL;}
@AutomationMan808 If your question has been answered, please close this issue. Thanks!