mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
Generate alternate url for different locales so search engine could find them all.
This commit is contained in:
parent
c801f9ed46
commit
89f3a5177b
2 changed files with 26 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
var Backbone = require('backbone');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var React = require('react');
|
||||
var _ = require('underscore');
|
||||
|
||||
var assign = require('object-assign');
|
||||
var util = require('../util');
|
||||
|
@ -86,6 +87,22 @@ var vcsModeRefresh = function(eventData) {
|
|||
$('body').toggleClass('hgMode', !isGit);
|
||||
};
|
||||
|
||||
var insertAlternateLinks = function(pageId) {
|
||||
// For now pageId is null, which would link to the main page.
|
||||
// In future if pageId is provided this method should link to a specific page
|
||||
|
||||
// The value of the hreflang attribute identifies the language (in ISO 639-1 format)
|
||||
// and optionally a region (in ISO 3166-1 Alpha 2 format) of an alternate URL
|
||||
var altLinks = _.map(LocaleStore.getSupportedLocales(), function(langCode) {
|
||||
var url = "https://learngitbranching.js.org/?locale=" + langCode;
|
||||
return '<link rel="alternate" hreflang="'+langCode+'" href="' + url +'" />';
|
||||
});
|
||||
var defaultUrl = "https://learngitbranching.js.org/?locale=" + LocaleStore.getDefaultLocale();
|
||||
altLinks.push('<link rel="alternate" hreflang="x-default" href="' + defaultUrl +'" />');
|
||||
$('head').prepend(altLinks);
|
||||
|
||||
};
|
||||
|
||||
var intlRefresh = function() {
|
||||
if (!window.$) { return; }
|
||||
$('span.intl-aware').each(function(i, el) {
|
||||
|
@ -249,6 +266,8 @@ var initDemo = function(sandbox) {
|
|||
tryLocaleDetect();
|
||||
}
|
||||
|
||||
insertAlternateLinks();
|
||||
|
||||
if (params.command) {
|
||||
var command = unescape(params.command);
|
||||
sandbox.mainVis.customEvents.on('gitEngineReady', function() {
|
||||
|
@ -328,4 +347,3 @@ exports.getLevelDropdown = function() {
|
|||
};
|
||||
|
||||
exports.init = init;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue