nextjs Data List
- NEXT.JS 기본개념
- NEXT.JS 설치
- NEXT.JS 실행방법
- NEXT.JS 파일 및 구조
- NEXT.JS 데이터 가져오기
- NEXT.JS API 쿼리데이터 생성
- NEXT.JS Components
- NEXT.JS page.js 파라미터 처리
- NEXT.JS app router 방식 client ip 주소 가져오는 방법
- NEXT.JS monaco-editor 사용방법
- NEXT.JS react-quill 사용방법
- NEXT.JS app router 방식 rss feed.xml 간단하게 설정 방법
- NEXT.JS app router 방식 sitemap.xml 간단하게 설정 방법
NEXT.JS app router 방식 sitemap.xml 간단하게 설정 방법
2024-02-29 14:36:00
/ 목차 /
- 파일 생성
- sitemap.tax 소스
- url 테스트
파일 생성
- 폴더생성 src/app/sitemap.tax sitemap.tax 파일만 생성해주면 Nextjs에서 자동으로 sitemap.xml 호출할수 있게 해주고 있습니다.sitemap.tax 소스
code async function getSitemapData() { return 'datas'; } export default async function sitemapdata() { const datas = await getSitemapData(); const currentDate = new Date(); currentDate.setHours(currentDate.getHours() + 9); const formattedDate = currentDate.toISOString(); const sitemapdata = datas.map((data:any) => ({ url: data.주소, lastModified: formattedDate, changeFrequency: 'always', priority: 0.7, })); return sitemapdata; }
getSitemapData() 해당 함수안에 데이터만 가져와주는 코드만 작성해주시면 됩니다.url 테스트
localhost:3000/sitemap.xml
Comment