MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
$(function() { | $(function() { | ||
var | var shortdesc = $('div.shortdescription').text().trim(); | ||
if ( | |||
// | if (shortdesc.length > 0) { | ||
// SHORTDESC exists: replace the old meta description | |||
$('meta[name="description"]').remove(); | $('meta[name="description"]').remove(); | ||
$('<meta>', { | |||
name: 'description', | |||
meta | content: shortdesc | ||
}).appendTo('head'); | |||
} else { | |||
// No SHORTDESC: delete any description tag | |||
$('meta[name="description"]').remove(); | |||
} | } | ||
}); | }); |
Revision as of 22:27, 25 April 2025
/* Any JavaScript here will be loaded for all users on every page load. */
$(function() {
var shortdesc = $('div.shortdescription').text().trim();
if (shortdesc.length > 0) {
// SHORTDESC exists: replace the old meta description
$('meta[name="description"]').remove();
$('<meta>', {
name: 'description',
content: shortdesc
}).appendTo('head');
} else {
// No SHORTDESC: delete any description tag
$('meta[name="description"]').remove();
}
});