방식 개편
This commit is contained in:
@@ -29,7 +29,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
const webhookUrl = config.discordWebhookUrl || 'https://discordapp.com/api/webhooks/1557204310369116210/9J4y96kmSbYNGtw5OxRgIz7InWcM8o3f8UX0Ad71-IyofwdS7tWmXkF7dj457-I8Ypiu'
|
||||
const siteName = config.public.siteName || '1:1 맞춤과외'
|
||||
const siteName = config.public.siteName || '새솔 1:1 맞춤과외'
|
||||
const siteDomain = config.public.siteDomain || 'https://aeseo.shop'
|
||||
|
||||
// 한국 시간 (KST)
|
||||
|
||||
@@ -4,24 +4,56 @@ export default defineEventHandler((event) => {
|
||||
const config = useRuntimeConfig()
|
||||
const baseUrl = config.public.siteDomain || 'https://aeseo.shop'
|
||||
const list = regionsData.list as Array<{ sido: string, sigungu: string, dong: string }>
|
||||
const today = new Date().toISOString().split('T')[0]
|
||||
|
||||
const subjects = ['영어', '수학', '국어', '통합과학', '통합사회']
|
||||
const grades = ['중학생', '고등학생']
|
||||
const subjectImages: Record<string, string> = {
|
||||
'수학': `${baseUrl}/img/math-tutoring.png`,
|
||||
'영어': `${baseUrl}/img/english-tutoring.png`,
|
||||
'국어': `${baseUrl}/img/korean-tutoring.png`,
|
||||
'과학': `${baseUrl}/img/science-tutoring.png`,
|
||||
'사회': `${baseUrl}/img/social-studies-tutoring.png`
|
||||
}
|
||||
const subjects = ['수학', '영어', '국어', '과학', '사회']
|
||||
const grades = ['초등학생', '중학생', '고등학생']
|
||||
|
||||
let xml = `<?xml version="1.0" encoding="UTF-8"?>\n`
|
||||
xml += `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n`
|
||||
xml += `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">\n`
|
||||
|
||||
// 메인
|
||||
xml += ` <url>\n <loc>${baseUrl}/</loc>\n <changefreq>daily</changefreq>\n <priority>1.0</priority>\n </url>\n`
|
||||
// 메인 (대표 이미지 + 5대 과목 이미지 모두 포함)
|
||||
xml += ` <url>\n`
|
||||
xml += ` <loc>${baseUrl}/</loc>\n`
|
||||
xml += ` <lastmod>${today}</lastmod>\n`
|
||||
xml += ` <changefreq>daily</changefreq>\n`
|
||||
xml += ` <priority>1.0</priority>\n`
|
||||
xml += ` <image:image><image:loc>${baseUrl}/img/og-main.png</image:loc></image:image>\n`
|
||||
subjects.forEach(sub => {
|
||||
xml += ` <image:image><image:loc>${subjectImages[sub]}</image:loc></image:image>\n`
|
||||
})
|
||||
xml += ` </url>\n`
|
||||
|
||||
// 568개 동별 주요 과목 및 학년 URL 생성
|
||||
// 동별 주요 과목 및 학년 URL 생성
|
||||
list.forEach(r => {
|
||||
// 1. 동 대표
|
||||
xml += ` <url>\n <loc>${baseUrl}/${encodeURIComponent(r.dong)}</loc>\n <changefreq>weekly</changefreq>\n <priority>0.8</priority>\n </url>\n`
|
||||
xml += ` <url>\n`
|
||||
xml += ` <loc>${baseUrl}/${encodeURIComponent(r.dong)}</loc>\n`
|
||||
xml += ` <lastmod>${today}</lastmod>\n`
|
||||
xml += ` <changefreq>weekly</changefreq>\n`
|
||||
xml += ` <priority>0.8</priority>\n`
|
||||
xml += ` <image:image><image:loc>${baseUrl}/img/og-main.png</image:loc></image:image>\n`
|
||||
xml += ` <image:image><image:loc>${baseUrl}/img/math-tutoring.png</image:loc></image:image>\n`
|
||||
xml += ` </url>\n`
|
||||
|
||||
// 2. 동-과목-학년 대표 조합
|
||||
subjects.slice(0, 3).forEach(sub => {
|
||||
xml += ` <url>\n <loc>${baseUrl}/${encodeURIComponent(r.dong)}-${encodeURIComponent(grades[0])}-${encodeURIComponent(sub)}</loc>\n <changefreq>weekly</changefreq>\n <priority>0.7</priority>\n </url>\n`
|
||||
// 2. 동/학년/과목 대표 조합
|
||||
grades.forEach(g => {
|
||||
subjects.forEach(sub => {
|
||||
xml += ` <url>\n`
|
||||
xml += ` <loc>${baseUrl}/${encodeURIComponent(r.dong)}/${encodeURIComponent(g)}/${encodeURIComponent(sub)}</loc>\n`
|
||||
xml += ` <lastmod>${today}</lastmod>\n`
|
||||
xml += ` <changefreq>weekly</changefreq>\n`
|
||||
xml += ` <priority>0.7</priority>\n`
|
||||
xml += ` <image:image><image:loc>${subjectImages[sub]}</image:loc></image:image>\n`
|
||||
xml += ` </url>\n`
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user