@@ -34,30 +34,33 @@ async function generateSitemap() {
3434
3535 fs . writeFileSync ( tempScriptPath , `
3636 import { resources } from '../src/data/resources.js';
37+ import { dataTypesOntology } from '../src/data/ontology.js';
3738 const clinicalTrialResources = resources.filter(resource => resource.dataTypes.includes('Clinical trials'));
3839 const bodyDonationResources = resources.filter(resource => resource.dataTypes.includes('Organ') || resource.dataTypes.includes('Body') || resource.dataTypes.includes('Tissue'));
3940
4041 const clinicalTrialCountries = Array.from(new Set(clinicalTrialResources.flatMap(r => r.countries || []))).sort();
4142 const bodyDonationCountries = Array.from(new Set(bodyDonationResources.flatMap(r => r.countries || []))).sort();
4243
4344 console.log(JSON.stringify({
44- resources: resources.map(r => ({
45- slug: r.slug
46- })),
45+ resources: resources.map(r => ({ slug: r.slug })),
46+ dataTypes: dataTypesOntology.map(dt => ({ slug: dt.slug })),
4747 clinicalTrialCountries: clinicalTrialCountries,
4848 bodyDonationCountries: bodyDonationCountries
4949 }));
5050 ` ) ;
5151
5252 // Execute the temporary script to get resource data
5353 const output = execFileSync ( 'node' , [ '--experimental-modules' , tempScriptPath ] ) . toString ( ) ;
54- const { resources : resourcesData , clinicalTrialCountries, bodyDonationCountries } = JSON . parse ( output ) ;
54+ const { resources : resourcesData , dataTypes : dataTypesData , clinicalTrialCountries, bodyDonationCountries } = JSON . parse ( output ) ;
5555
5656 // Delete the temporary script
5757 fs . unlinkSync ( tempScriptPath ) ;
5858
5959 const staticPages = [
6060 { url : `${ SITE_URL } /` , priority : '1.0' , changefreq : 'weekly' , file : 'src/app/page.js' , isDataDriven : true } ,
61+ { url : `${ SITE_URL } /resources` , priority : '0.9' , changefreq : 'weekly' , file : 'src/app/resources/page.js' , isDataDriven : true } ,
62+ { url : `${ SITE_URL } /explore` , priority : '0.9' , changefreq : 'weekly' , file : 'src/app/explore/page.js' , isDataDriven : true } ,
63+ { url : `${ SITE_URL } /data-types` , priority : '0.9' , changefreq : 'weekly' , file : 'src/app/data-types/page.js' , isDataDriven : true } ,
6164 { url : `${ SITE_URL } /data` , priority : '0.9' , changefreq : 'weekly' , file : 'src/app/data/page.js' , isDataDriven : true } ,
6265 { url : `${ SITE_URL } /clinical-trials` , priority : '0.9' , changefreq : 'weekly' , file : 'src/app/clinical-trials/page.js' , isDataDriven : true } ,
6366 { url : `${ SITE_URL } /organ-body-tissue-donation` , priority : '0.9' , changefreq : 'weekly' , file : 'src/app/organ-body-tissue-donation/page.js' , isDataDriven : true } ,
@@ -153,13 +156,26 @@ async function generateSitemap() {
153156 </url>` ;
154157 } ) ;
155158
159+ const dataTypeTemplateLastMod = getLastModified ( 'src/app/data-types/[slug]/page.js' ) || dataDrivenLastMod ;
160+ const lastModForDataTypes = dataDrivenLastMod > dataTypeTemplateLastMod ? dataDrivenLastMod : dataTypeTemplateLastMod ;
161+
162+ dataTypesData . forEach ( dt => {
163+ sitemap += `
164+ <url>
165+ <loc>${ SITE_URL } /data-types/${ dt . slug } </loc>
166+ <lastmod>${ lastModForDataTypes } </lastmod>
167+ <changefreq>weekly</changefreq>
168+ <priority>0.8</priority>
169+ </url>` ;
170+ } ) ;
171+
156172 sitemap += `
157173</urlset>` ;
158174
159175 const sitemapPath = path . join ( __dirname , '../public/sitemap.xml' ) ;
160176 fs . writeFileSync ( sitemapPath , sitemap ) ;
161177
162- console . log ( `Sitemap with ${ staticPages . length + markdownPages . length + clinicalTrialCountries . length + bodyDonationCountries . length + resourcesData . length } total URLs written to ${ sitemapPath } ` ) ;
178+ console . log ( `Sitemap with ${ staticPages . length + markdownPages . length + clinicalTrialCountries . length + bodyDonationCountries . length + resourcesData . length + dataTypesData . length } total URLs written to ${ sitemapPath } ` ) ;
163179 return true ;
164180 } catch ( error ) {
165181 console . error ( 'Error generating sitemap:' , error ) ;
@@ -176,6 +192,14 @@ async function generateSitemap() {
176192 <loc>${ SITE_URL } /resources</loc>
177193 <priority>0.9</priority>
178194 </url>
195+ <url>
196+ <loc>${ SITE_URL } /explore</loc>
197+ <priority>0.9</priority>
198+ </url>
199+ <url>
200+ <loc>${ SITE_URL } /data-types</loc>
201+ <priority>0.9</priority>
202+ </url>
179203 <url>
180204 <loc>${ SITE_URL } /yourselftoscience.pdf</loc>
181205 <priority>0.8</priority>
0 commit comments