“模板:Template shortcut/doc”与“MediaWiki:Mainpage.js”:页面之间的差异

来自NebulaeWiki
< 模板:Template shortcut(页面间差异)
(已保护“模板:Template shortcut/doc”([编辑=仅允许管理员](无限期)[移动=仅允许管理员](无限期)))
 
无编辑摘要
标签手工回退
 
第1行: 第1行:
{{Documentation}}
$(function(){
{{tsh|tsh}}
    /* 头图 */
 
    var page = document.querySelector("body");
This template displays one or more of a template's shortcuts (that is, redirects, also known as aliases, as in the box appearing at the right. {{tl|Tsh}} is a shortcut to this template, {{<nowiki />template shortcut}}, and can be used in its place. See [[Wikipedia:Template:Template shortcut]] for more details. Note that there are no optional parameter in this template.
    if (page.classList.contains('page-首页')) {
 
        var mwBody = document.getElementById('content');
== Usage ==
        var newDiv = document.createElement('div');
Place this template and its list of few to one, carefully selected shortcut(s) at the top of the template documentation page's [[Wikipedia:Wikipedia:Wikitext|wikitext]], right underneath {{tl|Documentation}}. In the saved, rendered text, those shortcuts will appear in this template's Shortcut(s) box, whose title will reflect the number of list items by automatically being singular or plural in form.
        newDiv.setAttribute('class', 'header-image');
 
        newDiv.innerHTML = '<div class="header-image" style="background-image: linear-gradient(to top, var(--color-surface-0), transparent 50%), url(https://wiki.knebulae.com/images/title.png);background-size: cover;background-position: top;height: 36vh;margin-bottom: -37vh;"></div>';
===Which ones to display here===
        mwBody.parentNode.insertBefore(newDiv, mwBody);
Although the template can show up to ten shortcuts, you are ''encouraged to choose well'' which ones to display in this template's box. Even if many redirects exist, ''two or three at the most'' is almost always enough. By keeping the number of redirects presented in the Shortcut box small, it makes it easier to remember them, and the documentation is kept well organized.
    }
 
}());
===Where to list any others===
List others in the Redirects section of the template documentation. Again, not all of them need to be listed; some shortcuts are there just for historical reasons, and others differ only in minor points such as white spaces or capitalization. Such shortcut-name variations are unnecessary to list at all—just list the standard, most common version of such a variation.
 
<includeonly>
[[Category:Internal link templates|{{PAGENAME}}]]
[[Category:Template documentation]]</includeonly>

2024年1月3日 (三) 16:27的最新版本

$(function(){
    /* 头图 */
    var page = document.querySelector("body");
    if (page.classList.contains('page-首页')) {
        var mwBody = document.getElementById('content');
        var newDiv = document.createElement('div');
        newDiv.setAttribute('class', 'header-image');
        newDiv.innerHTML = '<div class="header-image" style="background-image: linear-gradient(to top, var(--color-surface-0), transparent 50%), url(https://wiki.knebulae.com/images/title.png);background-size: cover;background-position: top;height: 36vh;margin-bottom: -37vh;"></div>';
        mwBody.parentNode.insertBefore(newDiv, mwBody);
    }
}());