extends ../layout-wide
block content
  iframe#wikiFrame(frameborder='no')
  script.
    var wikiUrl = '//freecodecamp.github.io/wiki';
    var wikiOrigin = /https?:\/\/freecodecamp.github.io/;
    var requestedPath = !{JSON.stringify(path) || ''};
    if (requestedPath !== '' && requestedPath.slice(-1) !== '/') {
      requestedPath += '/';
    }
    var lang = window.location.toString().match(/\/\w{2}\//);
    lang = (lang) ? lang[0] : '/en/';
    $('#wikiFrame').attr(
      'src',
      wikiUrl + (requestedPath ? requestedPath : lang)
    );
    window.addEventListener('message', function(e) {
      if (!wikiOrigin.test(e.origin)) {
        return null;
      }
      history.replaceState(history.state, null, e.data);
      return null;
    });
