Nicola1971/ampx

[tip] sidebar navigation on google cached pages (for faster amp pages loading)

Closed this issue · 2 comments

late night idea not tested:
tip: sidebar navigation on google cached pages (for faster amp pages loading)

ie:

wayfinder row tpl

for http sites:

  • credits:
    https://ampbyexample.com/advanced/using_the_google_amp_cache/

    Example:
    https://cdn.ampproject.org/c/tattoocms.it/amp.html?ampid=172

  • Snippet

    <?php
    /* ampcache_path Snippet
    * [[ampcache_path]] for http sites
    * [[ampcache_path? &secure=`1`]] for https sites
    */
    $secure = isset($secure) ? $secure : '0';
    $httpcachepath = "https://cdn.ampproject.org/c/";
    $httpscachepath = "https://cdn.ampproject.org/c/s/";
    $siteurl = $modx->config['site_url'];
    $host = parse_url($siteurl, PHP_URL_HOST);
    $host = preg_replace('/^(www\.)/i', '', $host);
    if ($secure == '1'){
        $cachepath = $httpscachepath.$host."/";
    }
    else { $cachepath = $httpcachepath.$host."/";
    }
    $ampcache_path = $cachepath;
    return $ampcache_path;
    ?>
    

    Wayfinder row tpl

    <li [+wf.classes+]><a href="[[ampcache_path]][~[*id*]~]?ampid=[+id+]
    

    It is not very useful because Google amp cached pages always opens links with target="_blank