Skip to content

Commit

Permalink
Merge branch 'feature/create-sitemap' of https://github.com/manya706/…
Browse files Browse the repository at this point in the history
…virtualcoffee.io into feature/create-sitemap
  • Loading branch information
manya706 committed Oct 11, 2024
2 parents 5fc7a6c + a350b4e commit bfefd8a
Showing 1 changed file with 39 additions and 35 deletions.
74 changes: 39 additions & 35 deletions scripts/generate-sitemap.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,54 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

function sitemap() {
return [
{
url: 'https://virtualcoffee.io',
lastModified: new Date(),
changeFrequency: 'yearly',
priority: 1,
},
{
url: 'https://virtualcoffee.io/about',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.8,
},
{
url: 'https://virtualcoffee.io/events',
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 0.6,
},
{
url: 'https://virtualcoffee.io/podcast',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.7,
},
{
url: 'https://virtualcoffee.io/contact',
lastModified: new Date(),
changeFrequency: 'yearly',
priority: 0.4,
},
]
return [
{
url: 'https://virtualcoffee.io',
lastModified: new Date(),
changeFrequency: 'yearly',
priority: 1,
},
{
url: 'https://virtualcoffee.io/about',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.8,
},
{
url: 'https://virtualcoffee.io/events',
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 0.6,
},
{
url: 'https://virtualcoffee.io/podcast',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.7,
},
{
url: 'https://virtualcoffee.io/contact',
lastModified: new Date(),
changeFrequency: 'yearly',
priority: 0.4,
},
];
}

console.log('Generating sitemap...');

const sitemapContent = sitemap().map(entry => `
const sitemapContent = sitemap()
.map(
(entry) => `
<url>
<loc>${entry.url}</loc>
<lastmod>${entry.lastModified.toISOString()}</lastmod>
<changefreq>${entry.changeFrequency}</changefreq>
<priority>${entry.priority}</priority>
</url>
`).join('');
`,
)
.join('');

const sitemapXml = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
Expand All @@ -58,4 +62,4 @@ const sitemapXml = `<?xml version="1.0" encoding="UTF-8"?>

const outputPath = path.join(__dirname, '../public/sitemap.xml');
fs.writeFileSync(outputPath, sitemapXml, 'utf8');
console.log(`Sitemap generated successfully at ${outputPath}`);
console.log(`Sitemap generated successfully at ${outputPath}`);

0 comments on commit bfefd8a

Please sign in to comment.