I'm looking for a way to generate a static version of specified nodes ( in my case they are book nodes pages).
I want to do it periodically in my custom Drupal cronjob,
most of the Drupal static modules are obsolete and there is no version for Drupal 9.
I found TOME module but looks like it's mostly for generating full website static generation through admin panel or drush
command line.
I tried drush tome:static-export-path /mybookpath --uri=localhost:8080
but it's blindly going through all the links on the pages and download all of them.
with digging more into the documentation I found this which is good to use tome services. in this case, there is no URI parameter option( it's only available for drush command) and it does not replace URLs ( image,link, style ( css) urls) and use the main version.
<?php
$static = \Drupal::service('tome_static.generator');
$request_preparer = \Drupal::service('tome_static.request_preparer');
$request_preparer->prepareForRequest();
$invoke_paths = $static->requestPath('/foo');
$invoke_paths = $static->exportPaths($invoke_paths);
foreach ($invoke_paths as $path) {
if (pathinfo($path, PATHINFO_EXTENSION)) {
$request_preparer->prepareForRequest();
$static->requestPath($path);
}
}
My question: What is the best solution to generate static HTML files will all assets of specific Drupal nodes?