Jump to content

Module:ChapterLayout

From wikibase
Revision as of 11:33, 22 April 2026 by Design (talk | contribs) (Created page with "local p = {} local mw = mw function p.render(frame) local parent_args = frame:getParent().args local content = parent_args[1] or "" local item = parent_args.item -- Retrieve Wikibase data if item is provided local entity = nil if item and item ~= "" then entity = mw.wikibase.getEntity(item) end -- 1. ChapterNav local nav_args = {item = item or ""} if entity then -- Pass any relevant data to ChapterNav...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:ChapterLayout/doc

local p = {}
local mw = mw

function p.render(frame)
    local parent_args = frame:getParent().args
    local content = parent_args[1] or ""
    local item = parent_args.item
    
    -- Retrieve Wikibase data if item is provided
    local entity = nil
    if item and item ~= "" then
        entity = mw.wikibase.getEntity(item)
    end
    
    -- 1. ChapterNav
    local nav_args = {item = item or ""}
    if entity then
        -- Pass any relevant data to ChapterNav
        nav_args.entity = entity
    end
    
    local nav = frame:expandTemplate{ 
        title = 'ChapterNav', 
        args = nav_args
    }
    
    -- 2. ChapterSynopsis
    local synopsis_args = {item = item or ""}
    if entity then
        synopsis_args.entity = entity
    end
    
    local synopsis = frame:expandTemplate{ 
        title = 'ChapterSynopsis', 
        args = synopsis_args
    }
    
    -- 3. ChapterContributors
    local contributors_args = {item = item or ""}
    if entity then
        contributors_args.entity = entity
    end
    
    local contributors = frame:expandTemplate{ 
        title = 'ChapterContributors', 
        args = contributors_args
    }
    
    -- 4. ChapterCitation
    local citation_args = {item = item or ""}
    if entity then
        citation_args.entity = entity
    end
    
    local citation = frame:expandTemplate{ 
        title = 'ChapterCitation', 
        args = citation_args
    }
    
    -- 5. Main content (imported text)
    local main_content = mw.text.trim(content)
    
    -- Assemble the page structure
    return nav .. "\n\n" .. synopsis .. "\n\n" .. contributors .. "\n\n" .. citation .. "\n\n" .. main_content
end

return p