Skip to content

Commit

Permalink
Do not add non-original content to sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
whitep4nth3r committed Aug 5, 2024
1 parent 56bd20a commit bb1d56a
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 80 deletions.
17 changes: 4 additions & 13 deletions src/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@
<link rel="stylesheet" href="/css/main.css" />

<!-- Meta -->
<meta
name="description"
content="This page doesn't exist. Please try another one." />
<meta name="description" content="This page doesn't exist. Please try another one." />

<!-- Favicons -->
<link rel="icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link
rel="apple-touch-icon"
sizes="120x120"
href="/apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/site.webmanifest" />
Expand Down Expand Up @@ -98,13 +93,9 @@ <h2 class="newsletterSignup__title">
in your inbox?
</h2>
<p class="newsletterSignup__para">
Enter the Weird Wide Web Hole to find no answers to questions you
didn't know you had.
Enter the Weird Wide Web Hole to find no answers to questions you didn't know you had.
</p>
<a
href="https://buttondown.email/weirdwidewebhole"
class="newsletterSignup__submit"
target="_blank">
<a href="https://buttondown.email/weirdwidewebhole" class="newsletterSignup__submit" target="_blank">
Subscribe
</a>
</div>
Expand Down
22 changes: 8 additions & 14 deletions src/_sitemap/sitemap.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ function calculateDate(page) {
return page.date.toISOString();
}

function calculateUrl(page) {
if (page.data.eleventyComputed && page.data.eleventyComputed.canonical) {
return page.data.eleventyComputed.canonical(page.data);
}

return `https://${Config.site.domain}${page.url}`;
}

function removeUrlParamsFromLink(url) {
return url.split("?")[0];
}
Expand All @@ -37,12 +29,14 @@ function buildItems(items) {
return `
${items
.map((page) => {
const date = calculateDate(page);
const url = calculateUrl(page);
return /*xml*/ `<url><loc>${removeUrlParamsFromLink(
url,
)}</loc><changefreq>daily</changefreq><lastmod>${date}</lastmod></url>`;
if (page.data.includeInSitemap === true) {
const date = calculateDate(page);
const url = `https://${Config.site.domain}${page.url}`;
return /*xml*/ `<url><loc>${removeUrlParamsFromLink(
url,
)}</loc><changefreq>daily</changefreq><lastmod>${date}</lastmod></url>`;
}
})
.join("")}
`;
Expand Down
1 change: 1 addition & 0 deletions src/about/index.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports.data = {
openGraphImageWidth: OpenGraph.imgWidth,
openGraphImageHeight: OpenGraph.imgHeight,
openGraphUrl: "https://whitep4nth3r.com/about/",
includeInSitemap: true,
};

exports.render = function (data) {
Expand Down
1 change: 1 addition & 0 deletions src/activity/index.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ exports.data = {
const trailing = data.pagination.pageNumber === 0 ? `` : `${data.pagination.pageNumber + 1}/`;
return `activity/${trailing}`;
},
includeInSitemap: true,
eleventyComputed: {
canonical: (data) => calculatePageUrl(data),
openGraphUrl: (data) => calculatePageUrl(data),
Expand Down
1 change: 1 addition & 0 deletions src/blog/blog-pages.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ exports.data = {
eleventyComputed: {
title: (data) => data.post.metaTitle,
slug: (data) => data.post.slug,
includeInSitemap: (data) => data.post.externalUrl === null,
canonical: (data) => data.post.externalUrl || `https://whitep4nth3r.com/blog/${data.post.slug}/`,
metaDescription: (data) => data.post.metaDescription,
openGraphImageUrl: (data) =>
Expand Down
7 changes: 3 additions & 4 deletions src/blog/index.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const OpenGraph = require("../../lib/openGraph");
const pageTitle = "Blogs and tutorials";

function calculatePageUrl(data) {
const suffix =
data.pagination.pageNumber === 0 ? `` : `${data.pagination.pageNumber + 1}/`;
const suffix = data.pagination.pageNumber === 0 ? `` : `${data.pagination.pageNumber + 1}/`;
return `https://whitep4nth3r.com/blog/${suffix}`;
}

Expand All @@ -28,10 +27,10 @@ exports.data = {
addAllPagesToCollections: true,
},
permalink: (data) => {
const trailing =
data.pagination.pageNumber === 0 ? `` : `${data.pagination.pageNumber + 1}/`;
const trailing = data.pagination.pageNumber === 0 ? `` : `${data.pagination.pageNumber + 1}/`;
return `blog/${trailing}`;
},
includeInSitemap: true,
eleventyComputed: {
title: (data) => `${pageTitle} — Page ${data.pagination.pageNumber + 1}`,
canonical: (data) => calculatePageUrl(data),
Expand Down
16 changes: 5 additions & 11 deletions src/events/index.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ exports.data = {
layout: "base.html",
title: pageTitle,
activeNav: "events",
metaDescription: "View my Twitch schedule, virtual events and conference speaking schedule. Come and say hi if you meet me somewhere in the world!",
metaDescription:
"View my Twitch schedule, virtual events and conference speaking schedule. Come and say hi if you meet me somewhere in the world!",
openGraphImageUrl: OpenGraph.generateImageUrl({ title: pageTitle }),
openGraphImageAlt: OpenGraph.generateImageAlt(pageTitle),
openGraphImageWidth: OpenGraph.imgWidth,
openGraphImageHeight: OpenGraph.imgHeight,
openGraphUrl: "https://whitep4nth3r.com/events/",
includeInSitemap: true,
};

exports.render = function (data) {
Expand Down Expand Up @@ -56,18 +58,10 @@ exports.render = function (data) {
${event.date}
</span>
</span>
${
event.canceled_until !== null
? `<span class="events__listItemCancelled">CANCELLED</span>`
: ``
}
${event.canceled_until !== null ? `<span class="events__listItemCancelled">CANCELLED</span>` : ``}
</span>
<span class="events__listItemName">${event.name}</span>
${
event.description
? `<p class="events__listshortDescription">${event.description}</p>`
: ""
}
${event.description ? `<p class="events__listshortDescription">${event.description}</p>` : ""}
${
event.canceled_until === null && event.link
? `
Expand Down
1 change: 1 addition & 0 deletions src/index.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exports.data = {
openGraphImageWidth: OpenGraph.imgWidth,
openGraphImageHeight: OpenGraph.imgHeight,
openGraphUrl: "https://whitep4nth3r.com/",
includeInSitemap: true,
};

exports.render = function (data) {
Expand Down
15 changes: 5 additions & 10 deletions src/sponsorships/index.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ var md = require("markdown-it")({
exports.data = {
layout: "base.html",
pageType: "sponsorships",
includeInSitemap: true,
eleventyComputed: {
title: (data) => data.content.metaTitle,
metaDescription: (data) => data.content.metaDescription,
openGraphImageUrl: (data) =>
OpenGraph.generateImageUrl({ title: data.content.metaTitle }),
openGraphImageAlt: (data) =>
OpenGraph.generateImageAlt(data.content.metaTitle),
openGraphImageUrl: (data) => OpenGraph.generateImageUrl({ title: data.content.metaTitle }),
openGraphImageAlt: (data) => OpenGraph.generateImageAlt(data.content.metaTitle),
},
openGraphImageWidth: OpenGraph.imgWidth,
openGraphImageHeight: OpenGraph.imgHeight,
Expand All @@ -43,9 +42,7 @@ exports.render = function (data) {
<section class="sponsorships__content">
<h2>What people say</h2>
<div class="sponsorships__testimonials">
${testimonials
.map((testimonial) => Testimonial({ testimonial }))
.join("")}
${testimonials.map((testimonial) => Testimonial({ testimonial })).join("")}
</div>
</section>
Expand All @@ -58,9 +55,7 @@ exports.render = function (data) {
</div>
<div class="sponsorships__packages">
${content.streamPackagesCollection.items
.map((package) => StreamPackage({ package }))
.join("")}
${content.streamPackagesCollection.items.map((package) => StreamPackage({ package })).join("")}
</div>
<div class="sponsorships__content">
Expand Down
1 change: 1 addition & 0 deletions src/talks/index.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exports.data = {
size: Config.pagination.pageSize,
addAllPagesToCollections: true,
},
includeInSitemap: true,
permalink: (data) => {
const trailing = data.pagination.pageNumber === 0 ? `` : `${data.pagination.pageNumber + 1}/`;
return `talks/${trailing}`;
Expand Down
7 changes: 2 additions & 5 deletions src/talks/talks-pages.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exports.data = {
permalink: (data) => {
return `talks/${data.talk.slug}/`;
},
includeInSitemap: true,
eleventyComputed: {
title: (data) => `${data.talk.title} - Salma Alam-Naylor`,
metaDescription: (data) => data.talk.metaDescription,
Expand Down Expand Up @@ -63,11 +64,7 @@ exports.render = function (data) {
<hr class="post__separator" />
<div class="post__body">
${
talk.recording !== null
? VideoEmbed({ embedUrl: talk.recording.embedUrl, title: talk.recording.title })
: ""
}
${talk.recording !== null ? VideoEmbed({ embedUrl: talk.recording.embedUrl, title: talk.recording.title }) : ""}
<h2 class="post__h2">Slides</h2>
${SpeakerDeckLink({ speakerDeckLink: talk.speakerDeckLink })}
Expand Down
7 changes: 3 additions & 4 deletions src/topics/topics-pages.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ exports.data = {
size: 1,
addAllPagesToCollections: true,
},
includeInSitemap: true,
permalink: (data) => {
return `topics/${data.topic.slug}/`;
},
eleventyComputed: {
title: (data) => `Posts about ${data.topic.name} from Salma Alam-Naylor`,
metaDescription: (data) =>
`Learn about ${data.topic.name} and more from ${Config.meta.jobDescription}.`,
metaDescription: (data) => `Learn about ${data.topic.name} and more from ${Config.meta.jobDescription}.`,
openGraphImageUrl: (data) =>
OpenGraph.generateImageUrl({
title: `Blog posts tagged ${data.topic.name}`,
}),
openGraphImageAlt: (data) =>
OpenGraph.generateImageAlt(`Posts about ${data.topic.name} from Salma Alam-Naylor`),
openGraphImageAlt: (data) => OpenGraph.generateImageAlt(`Posts about ${data.topic.name} from Salma Alam-Naylor`),
openGraphImageWidth: OpenGraph.imgWidth,
openGraphImageHeight: OpenGraph.imgHeight,
openGraphUrl: (data) => `https://whitep4nth3r.com/topics/${data.topic.slug}/`,
Expand Down
6 changes: 2 additions & 4 deletions src/uses/index.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exports.data = {
openGraphImageWidth: OpenGraph.imgWidth,
openGraphImageHeight: OpenGraph.imgHeight,
openGraphUrl: "https://whitep4nth3r.com/uses/",
includeInSitemap: true,
};

exports.render = function (data) {
Expand All @@ -30,10 +31,7 @@ exports.render = function (data) {
(cat) => `
<section id="${cat}">
<h2 class="uses_catHeading">
<img src="/.netlify/images/?url=/img/${cat.replace(
" ",
"-",
)}.png" alt="${cat}" />
<img src="/.netlify/images/?url=/img/${cat.replace(" ", "-")}.png" alt="${cat}" />
</h2>
<ol class="uses__list">
${things[cat]
Expand Down
25 changes: 10 additions & 15 deletions src/video/index.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ exports.data = {
title: pageTitle,
activeNav: "video",
pageType: "video",
metaDescription: "I made some videos to practise making videos. These videos don't mean anything really. Or maybe they do?",
metaDescription:
"I made some videos to practise making videos. These videos don't mean anything really. Or maybe they do?",
openGraphImageUrl: OpenGraph.generateImageUrl({ title: pageTitle }),
openGraphImageAlt: OpenGraph.generateImageAlt(pageTitle),
openGraphImageWidth: OpenGraph.imgWidth,
openGraphImageHeight: OpenGraph.imgHeight,
openGraphUrl: "https://whitep4nth3r.com/video/",
includeInSitemap: true,
};

exports.render = function (data) {
Expand All @@ -35,38 +37,31 @@ exports.render = function (data) {
<div class="video__grid">
${VideoEmbed({
showTitle: false,
embedUrl:
"https://www.youtube.com/embed/jjI6Mzv6XrQ?si=UzY22AMw4726Ix00",
embedUrl: "https://www.youtube.com/embed/jjI6Mzv6XrQ?si=UzY22AMw4726Ix00",
})}
${VideoEmbed({
showTitle: false,
embedUrl:
"https://www.youtube.com/embed/_IZri_2rWyo?si=kFx-J-NCokxQVZTQ",
embedUrl: "https://www.youtube.com/embed/_IZri_2rWyo?si=kFx-J-NCokxQVZTQ",
})}
${VideoEmbed({
showTitle: false,
embedUrl:
"https://www.youtube.com/embed/4HbFQ932R5M?si=ormWKMq4K-f33UIi",
embedUrl: "https://www.youtube.com/embed/4HbFQ932R5M?si=ormWKMq4K-f33UIi",
})}
${VideoEmbed({
showTitle: false,
embedUrl:
"https://www.youtube.com/embed/5Ondq89xYVs?si=1XeQ5wXlud1pAOrN",
embedUrl: "https://www.youtube.com/embed/5Ondq89xYVs?si=1XeQ5wXlud1pAOrN",
})}
${VideoEmbed({
showTitle: false,
embedUrl:
"https://www.youtube.com/embed/7mhcWrZf_7w?si=tho4AOX4gE1mPKbb",
embedUrl: "https://www.youtube.com/embed/7mhcWrZf_7w?si=tho4AOX4gE1mPKbb",
})}
${VideoEmbed({
showTitle: false,
embedUrl:
"https://www.youtube.com/embed/trj6acFLOW0?si=Vu6565KelUA4SU7Z",
embedUrl: "https://www.youtube.com/embed/trj6acFLOW0?si=Vu6565KelUA4SU7Z",
})}
${VideoEmbed({
showTitle: false,
embedUrl:
"https://www.youtube.com/embed/ma9cRUkfiSQ?si=PSbKyqjU-1Lsqidn",
embedUrl: "https://www.youtube.com/embed/ma9cRUkfiSQ?si=PSbKyqjU-1Lsqidn",
})}
</div>
</section>
Expand Down

0 comments on commit bb1d56a

Please sign in to comment.