| 143 | } |
| 144 | |
| 145 | private onText(text: string) { |
| 146 | if (this.currentTag === 'loc') { |
| 147 | if (this.rootTagName === 'sitemapindex') { |
| 148 | this.push({ type: 'sitemapUrl', url: text.trim() } satisfies SitemapItem); |
| 149 | } |
| 150 | |
| 151 | if (this.rootTagName === 'urlset') { |
| 152 | this.url ??= {}; |
| 153 | this.url.loc = text.trim(); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | text = text.trim(); |
| 158 | |
| 159 | if (this.currentTag === 'lastmod') { |
| 160 | this.url.lastmod = new Date(text); |
| 161 | } |
| 162 | |
| 163 | if (this.currentTag === 'priority') { |
| 164 | this.url.priority = Number(text); |
| 165 | } |
| 166 | |
| 167 | if (this.currentTag === 'changefreq') { |
| 168 | if (['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'].includes(text)) { |
| 169 | this.url.changefreq = text as SitemapUrl['changefreq']; |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | export interface ParseSitemapOptions { |