Module:ElementNavigation: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
--[[
--[[
* Module:ElementNavigation
* Name: ElementNavigation
* Provides navigation detection and rendering for sequential content
* Author: Mark W. Datysgeld
*
* Description: Element module that provides navigation detection and rendering for sequential content in Blueprint templates
* This module detects previous/next pages based on naming patterns
* Notes: Automatic detection of previous/next pages based on naming patterns; supports series+number and series+year patterns; configurable field names and styling; designed as Blueprint template system block
* and renders navigation links. It's designed to be used as a block
* in the Blueprint template system.
*
* Features:
* - Automatic detection of previous/next pages based on patterns
* - Support for both series+number and series+year patterns
* - Caching of detection results for performance
* - Configurable field names and styling
* - Blueprint integration as a custom block
]]
]]


Line 75: Line 66:


-- ========== Blueprint Integration ==========
-- ========== Blueprint Integration ==========
-- Helper function to merge two tables. The custom table's values override the base table's.
local function mergeConfigs(base, custom)
    local merged = {}
    for k, v in pairs(base) do
        merged[k] = v
    end
    for k, v in pairs(custom) do
        merged[k] = v
    end
    return merged
end


-- Create a navigation block for Blueprint
-- Create a navigation block for Blueprint
Line 100: Line 103:
         return execute(function()
         return execute(function()
             -- Merge default and template-specific configurations
             -- Merge default and template-specific configurations
             local config = require('Module:TemplateHelpers').mergeConfigs(
             local config = mergeConfigs(p.defaultConfig, template.config.navigation or {})
                p.defaultConfig,
                template.config.navigation or {}
            )


             -- Automatic navigation detection
             -- Automatic navigation detection