Module:InterviewArchive

local utils = require('Module:InterviewUtils') local p = {}

local function generateInterview(interview, frame) local output = {} local year = utils.parse(interview.date) local year, _, _ = utils.parse(interview.date) -- get the year from the date

local function cleanIntervieweeName(interviewee) local cleaned = mw.text.trim(interviewee) cleaned = string.gsub(cleaned, '%[%[(.-)%]%]', '%1') -- remove wikitext link cleaned = string.gsub(cleaned, '', '%2') -- handle template with piped link cleaned = string.gsub(cleaned, '', '%1') -- remove template cleaned = string.gsub(cleaned, '%[extlink (.-)%]', '%1') -- remove external link cleaned = string.gsub(cleaned, "'", '&#39;') -- replace single quotes with HTML character entity return cleaned end local cleanInterviewees = {} for _, interviewee in ipairs(interview.interviewee) do	   local cleanInterviewee = cleanIntervieweeName(interviewee) table.insert(cleanInterviewees, cleanInterviewee) end local function valueOrDefault(value, default) if value == nil or value == '' then return default else return value end end

table.insert(output, '') table.insert(output, ' ') if interview.cover ~= '' then table.insert(output, '') else table.insert(output, '') end table.insert(output, ' ') table.insert(output, ' ') table.insert(output, ' ') table.insert(output, '') table.insert(output, ' ') table.insert(output, ' ') if interview.display then table.insert(output, frame:preprocess("")) else table.insert(output, frame:preprocess("")) end table.insert(output, ' ') table.insert(output, ' ') if interview.translation then table.insert(output, frame:preprocess('<' .. interview.translation .. ' >'))   end if interview.transcript then table.insert(output, frame:preprocess('<' .. interview.transcript .. '2 >'))   end table.insert(output, frame:preprocess('<' .. interview.media .. ' >'))   table.insert(output, frame:preprocess('<' .. interview.type .. ' >'))   table.insert(output, frame:preprocess('right')) table.insert(output, ' 👤 ') for i, person in ipairs(interview.interviewee) do	 if i > 1 then table.insert(output, ", ") end table.insert(output, frame:preprocess(person)) end

table.insert(output, ' ') table.insert(output, ' 📜 ') for _, tag in ipairs(interview.tags) do       table.insert(output, frame:preprocess('<' .. tag .. ' >'))   end table.insert(output, '    ') return table.concat(output) end

-- Export the generateInterview function so it can be used from outside the module function p.generateInterview(frame) -- Extract the interview title from frame.args[1] local interviewTitle = frame.args[1]

-- Load the interviews from JSON data local interviewsJson = mw.loadJsonData('JoJo Wiki:Interviews').interviews

-- Find the interview with the matching title local interview = nil for i, v in ipairs(interviewsJson) do       if v.title == interviewTitle then interview = v           break end end

-- If we found the interview, generate it   if interview ~= nil then -- Rest of your code... return generateInterview(interview, frame) else return "Interview not found" end end

function p.generateArchive(frame) local content = mw.loadJsonData('JoJo Wiki:Interviews').interviews local html = {' '} -- Start the div with the ID 'interview-container' for _, interview in ipairs(content) do       table.insert(html, generateInterview(interview, frame)) end

table.insert(html, ' ') -- End the div with the ID 'interview-container' return table.concat(html) end

return p