Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Main

From Landrace.Wiki - The Landrace Cannabis Wiki

This is a documentation subpage for Main. It contains usage information, categories, and other content that is not part of the original template.

This module backs {{Main}}, the hatnote pointing readers to the main article or articles on a topic. It takes any number of page-name arguments and renders them as a list with proper comma and "and" separators (no Oxford comma) and a label that pluralises with the count.

Usage

The module is invoked from {{Main}}:

{{#invoke:Main|main}}

End users do not call the module directly. They use the template:

{{Main|Page name}}
{{Main|First page|Second page}}
{{Main|First page|Second page|Third page}}

Parameters

Positional arguments (1, 2, 3, ...)
Page-name targets for the hatnote links. At least one is required; there is no fixed upper limit. Empty trailing arguments stop the scan.
l1, l2, l3, ...
Optional display labels for the corresponding positional argument. l2=foo sets the display text for the second positional argument. If omitted, the page name is shown as the link text.

Output

Renders a single div with classes main-article-hatnote navigation-not-searchable and ARIA role note. Styled by Template:Main/styles.css.

Label:

  • one target: Main article:
  • two or more targets: Main articles:

Separators between targets:

  • two targets: A and B
  • three or more: A, B and C (no Oxford comma)

Examples

Input Renders as
{{Main|Cannabis in West Bengal}} Main article: Cannabis in West Bengal
{{Main|Cannabis in West Bengal|Religion in West Bengal}} Main articles: Cannabis in West Bengal and Religion in West Bengal
{{Main|Cannabis in West Bengal|Religion in West Bengal|Cuisine of West Bengal}} Main articles: Cannabis in West Bengal, Religion in West Bengal and Cuisine of West Bengal
{{Main|Cannabis in West Bengal|l1=cannabis here}} Main article: cannabis here

When to use

At the top of a section whose subject has a dedicated main article. The hatnote tells the reader the section is a summary and points to fuller treatment elsewhere.

Aggressive deferral via {{Main}} is the standard pattern for hub articles (Cannabis cultivation, Cannabis Botany, country pages). Each body section gives two to four sentences plus a {{Main}} link to the subarticle.

When not to use

Not for a list of merely related pages: that's [[Template:See also|{{See also}}]] (where the link is tangential rather than the section's main subject).

Not for further reading on a subtopic that the section itself covers in full: that's the pattern for [[Template:Further|{{Further}}]].

Not in a lead, except in rare cases where the article itself is a summary stub pointing to a fuller article elsewhere. Lead hatnotes are usually [[Template:About|{{About}}]]-style disambiguation rather than main-article pointers.

Styling

Visual treatment lives in Template:Main/styles.css:

  • italic body text
  • normal-style links inside (italic stripped)
  • 0.95em font size
  • 1.6em left margin (hatnote indent)
  • colour inherits from the article body, so the hatnote sits with surrounding prose

To change colour, font size, or indent globally, edit Template:Main/styles.css. The module's output is class-scoped so changes do not affect other hatnote templates.

See also


-- Module:Main
-- Renders the {{Main}} hatnote. Accepts any number of positional
-- arguments as link targets, with optional |l1=, |l2=, ... display labels.
-- Singular "Main article:" for one target, plural "Main articles:"
-- for two or more. Final separator is " and ", with no Oxford comma.

local p = {}

local function formatLink(target, display)
	if display and display ~= '' then
		return '[[' .. target .. '|' .. display .. ']]'
	end
	return '[[' .. target .. ']]'
end

local function joinList(items)
	local n = #items
	if n == 0 then return '' end
	if n == 1 then return items[1] end
	if n == 2 then return items[1] .. ' and ' .. items[2] end
	-- 3 or more: comma-separated head, " and " before the last item
	return table.concat(items, ', ', 1, n - 1) .. ' and ' .. items[n]
end

function p.main(frame)
	local args = frame:getParent().args

	local items = {}
	local i = 1
	while args[i] and tostring(args[i]):match('%S') do
		local target = tostring(args[i])
		local display = args['l' .. i]
		if display ~= nil then display = tostring(display) end
		table.insert(items, formatLink(target, display))
		i = i + 1
	end

	if #items == 0 then return '' end

	local label = (#items == 1) and 'Main article' or 'Main articles'
	return '<div role="note" class="main-article-hatnote navigation-not-searchable">'
		.. label .. ': ' .. joinList(items) .. '</div>'
end

return p