모듈:SEO
이터널 리턴 이스포츠 위키
다른 명령
이 모듈에 대한 설명문서는 모듈:SEO/설명문서에서 만들 수 있습니다
-- 모듈:SEO
-- bori.wiki 이터널리턴 이스포츠 위키 SEO 메타데이터 자동 생성
-- WikiSEO 2.7.0 mw.ext.seo.set() API 사용
local p = {}
-------------------------------------------------------------------------------
-- 영→한 용어 매핑
-------------------------------------------------------------------------------
local translationMap = {
-- 시리즈/대회명
["Eternal Return"] = "이터널리턴",
["Masters"] = "마스터즈",
["Invitational"] = "인비테이셔널",
["Open"] = "오픈",
["Championship"] = "챔피언십",
["Final"] = "파이널",
["Qualifier"] = "예선",
["Playoffs"] = "플레이오프",
["Group Stage"] = "조별리그",
-- 시즌/페이즈
["Season"] = "시즌",
["Phase"] = "페이즈",
-- 일반 용어
["Esports"] = "이스포츠",
["Tournament"] = "대회",
["Team"] = "팀",
["Player"] = "선수",
}
-------------------------------------------------------------------------------
-- 기본 키워드
-------------------------------------------------------------------------------
local baseKeywords = "이터널리턴, Eternal Return, 이스포츠, esports, 위키"
-------------------------------------------------------------------------------
-- 유틸리티 함수
-------------------------------------------------------------------------------
-- 영어 시리즈명을 한국어로 변환
local function translateSeries(name)
if not name or name == "" then return "" end
local result = name
for en, ko in pairs(translationMap) do
result = mw.ustring.gsub(result, en, ko)
end
return mw.text.trim(result)
end
-- 프레임 인자에서 파라미터 추출 (한/영 파라미터명 모두 지원)
local function getArg(args, ...)
local keys = {...}
for _, key in ipairs(keys) do
local val = args[key]
if val and val ~= "" then
return mw.text.trim(val)
end
end
return nil
end
-- 키워드 목록 생성 (중복 제거)
local function buildKeywords(items)
local seen = {}
local result = {}
for _, item in ipairs(items) do
if item and item ~= "" then
local trimmed = mw.text.trim(item)
if trimmed ~= "" and not seen[trimmed] then
seen[trimmed] = true
table.insert(result, trimmed)
end
end
end
return table.concat(result, ", ")
end
-- 쉼표로 구분된 문자열을 개별 항목으로 분리
local function splitComma(str)
if not str or str == "" then return {} end
local items = {}
for item in mw.ustring.gmatch(str, "([^,]+)") do
local trimmed = mw.text.trim(item)
if trimmed ~= "" then
table.insert(items, trimmed)
end
end
return items
end
-------------------------------------------------------------------------------
-- SEO 설정 공통 함수
-------------------------------------------------------------------------------
local function setSEO(title, keywords, description)
mw.ext.seo.set({
title = title,
title_mode = "replace",
keywords = keywords,
description = description,
locale = "ko_KR",
type = "article",
})
return ""
end
-------------------------------------------------------------------------------
-- p.player: 선수 페이지 SEO
-------------------------------------------------------------------------------
-- 사용법: {{#invoke:SEO|player|name=OneCircle|realname=한동규|team=FN SEJONG|characters=리 다이린, 쇼이치}}
function p.player(frame)
local args = frame:getParent().args
local name = getArg(args, "name", "이름", "1") or mw.title.getCurrentTitle().text
local realname = getArg(args, "realname", "본명")
local team = getArg(args, "team", "소속", "팀")
local characters = getArg(args, "characters", "캐릭터")
local desc = getArg(args, "description", "설명")
-- 제목 생성
local title
if realname then
title = name .. " (" .. realname .. ") - 이터널리턴 프로게이머"
else
title = name .. " - 이터널리턴 프로게이머"
end
-- 키워드 조합
local kwItems = {"이터널리턴", "Eternal Return", name}
if realname then table.insert(kwItems, realname) end
if team then table.insert(kwItems, team) end
table.insert(kwItems, "프로게이머")
table.insert(kwItems, "선수")
table.insert(kwItems, "이스포츠")
-- 캐릭터 키워드 추가
if characters then
for _, char in ipairs(splitComma(characters)) do
table.insert(kwItems, char)
end
end
local keywords = buildKeywords(kwItems)
-- 설명 자동 생성
if not desc then
local parts = {name}
if realname then
table.insert(parts, "(" .. realname .. ")")
end
if team then
table.insert(parts, "- " .. team .. " 소속")
end
table.insert(parts, "이터널리턴 프로게이머 프로필, 대회 성적, 통계 정보.")
desc = table.concat(parts, " ")
end
return setSEO(title, keywords, desc)
end
-------------------------------------------------------------------------------
-- p.tournament: 대회 페이지 SEO
-------------------------------------------------------------------------------
-- 사용법: {{#invoke:SEO|tournament|series=Masters|season=10|phase=1}}
function p.tournament(frame)
local args = frame:getParent().args
local series = getArg(args, "series", "시리즈", "1")
local season = getArg(args, "season", "시즌")
local phase = getArg(args, "phase", "페이즈")
local stage = getArg(args, "stage", "스테이지")
local desc = getArg(args, "description", "설명")
-- 한국어 시리즈명
local seriesKo = series and translateSeries(series) or ""
local seriesEn = series or ""
-- 제목 생성
local titleParts = {"이터널리턴"}
if seriesKo ~= "" then table.insert(titleParts, seriesKo) end
if season then table.insert(titleParts, "시즌" .. season) end
if phase then table.insert(titleParts, "페이즈" .. phase) end
if stage then table.insert(titleParts, stage) end
local title = table.concat(titleParts, " ")
-- 키워드 조합
local kwItems = {"이터널리턴", "Eternal Return"}
if seriesKo ~= "" then table.insert(kwItems, seriesKo) end
if seriesEn ~= "" and seriesEn ~= seriesKo then
table.insert(kwItems, seriesEn)
end
table.insert(kwItems, "대회")
if season then
table.insert(kwItems, "시즌" .. season)
table.insert(kwItems, "S" .. season)
end
if phase then
table.insert(kwItems, "페이즈" .. phase)
table.insert(kwItems, "P" .. phase)
end
if stage then table.insert(kwItems, stage) end
table.insert(kwItems, "이스포츠")
-- 약칭 키워드 (예: ERM S10P1)
if seriesEn ~= "" and season then
local abbr = ""
if seriesEn == "Masters" then abbr = "ERM"
elseif seriesEn == "Open" then abbr = "ERO"
elseif seriesEn == "Invitational" then abbr = "ERI"
end
if abbr ~= "" then
local abbrFull = abbr .. " S" .. season
if phase then abbrFull = abbrFull .. "P" .. phase end
table.insert(kwItems, abbr)
table.insert(kwItems, abbrFull)
end
end
local keywords = buildKeywords(kwItems)
-- 설명 자동 생성
if not desc then
desc = title .. " 대회 정보, 일정, 결과, 순위, 통계."
end
return setSEO(title, keywords, desc)
end
-------------------------------------------------------------------------------
-- p.team: 팀 페이지 SEO
-------------------------------------------------------------------------------
-- 사용법: {{#invoke:SEO|team|name=FN SEJONG|shortname=FNS}}
function p.team(frame)
local args = frame:getParent().args
local name = getArg(args, "name", "이름", "1") or mw.title.getCurrentTitle().text
local shortname = getArg(args, "shortname", "약칭")
local desc = getArg(args, "description", "설명")
-- 제목 생성
local title = name .. " - 이터널리턴 프로팀"
-- 키워드 조합
local kwItems = {"이터널리턴", "Eternal Return", name}
if shortname then table.insert(kwItems, shortname) end
table.insert(kwItems, "프로팀")
table.insert(kwItems, "팀")
table.insert(kwItems, "이스포츠")
local keywords = buildKeywords(kwItems)
-- 설명 자동 생성
if not desc then
local parts = {name}
if shortname then
table.insert(parts, "(" .. shortname .. ")")
end
table.insert(parts, "- 이터널리턴 프로팀 정보, 선수 명단, 대회 성적.")
desc = table.concat(parts, " ")
end
return setSEO(title, keywords, desc)
end
return p