Skip to content

Commit fdcd277

Browse files
committedFeb 18, 2025
Reduced JPGs, implemented robots & added yarn sitemap
Integrated @astrojs/sitemap with a filter to exclude pages with query parameters. Added robots meta tag to blog posts to prevent indexing, subsequently updating the Layout.astro to support optional robots meta tag configuration. Finally, I compressed some blog post images to ensure they are not too large when turned into webp's.
1 parent c527a20 commit fdcd277

7 files changed

+87
-17
lines changed
 

‎astro.config.ts

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
import mdx from '@astrojs/mdx'
22
import preact from '@astrojs/preact'
3+
import sitemap from '@astrojs/sitemap'
34
import { defineConfig } from 'astro/config'
45
import { h } from 'hastscript'
56
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
67
import rehypeSlug from 'rehype-slug'
78
import rehypeKatex from 'rehype-katex'
89
import remarkMath from 'remark-math'
910
import remarkGfm from 'remark-gfm'
10-
import inspectUrls from "@jsdevtools/rehype-url-inspector";
11+
import inspectUrls from '@jsdevtools/rehype-url-inspector'
1112

1213
// https://astro.build/config
1314
export default defineConfig({
1415
integrations: [
1516
mdx(),
1617
preact(),
18+
sitemap({
19+
filter: (page) => {
20+
// Exclude any pages we don't want in the sitemap, like search pages
21+
return !page.includes('?')
22+
}
23+
})
1724
],
1825
site: 'https://juxt.pro/',
1926
markdown: {
@@ -58,18 +65,18 @@ export default defineConfig({
5865
[
5966
inspectUrls,
6067
{
61-
selectors: ["a[href]"],
68+
selectors: ['a[href]'],
6269
inspectEach: (url) => {
63-
// Ignore hash links
64-
if (url.node.properties.href.startsWith("#")) {
65-
return;
66-
}
67-
var href = new URL(url.node.properties.href, "https://juxt.pro/");
68-
// Add target blank to external links
69-
if (href.host !== "juxt.pro") {
70-
url.node.properties.target = "_blank";
71-
url.node.properties.rel = "noopener noreferrer";
72-
}
70+
// Ignore hash links
71+
if (url.node.properties.href.startsWith('#')) {
72+
return
73+
}
74+
var href = new URL(url.node.properties.href, 'https://juxt.pro/')
75+
// Add target blank to external links
76+
if (href.host !== 'juxt.pro') {
77+
url.node.properties.target = '_blank'
78+
url.node.properties.rel = 'noopener noreferrer'
79+
}
7380
}
7481
}
7582
]
@@ -78,7 +85,7 @@ export default defineConfig({
7885
vite: {
7986
build: {
8087
rollupOptions: {
81-
external: ['/pagefind/pagefind.js'],
88+
external: ['/pagefind/pagefind.js']
8289
}
8390
}
8491
}

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"dependencies": {
4747
"@astrojs/check": "^0.2.0",
4848
"@astrojs/rss": "^3.0.0",
49+
"@astrojs/sitemap": "^3.2.1",
4950
"@jsdevtools/rehype-url-inspector": "^2.0.2",
5051
"@preact/compat": "npm:@preact/compat",
5152
"@tailwindui/react": "^0.1.1",
-2.63 MB
Loading

‎src/assets/blog/oliver-xt24.jpg

-2.93 MB
Loading

‎src/layouts/BlogPost.astro

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ const categoryHref = `/blog?${encodeURI(
186186
ogTitle={`JUXT Blog: ${title}`}
187187
ogDescription={description}
188188
ogImage={heroImageFilename}
189+
robots='noindex,follow'
189190
>
190191
<DraftBanner draft={draft} pageName='Blog' />
191192
<main

‎src/layouts/Layout.astro

+12-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type LayoutProps = {
1313
ogTitle?: string
1414
ogDescription?: string
1515
noFooter?: boolean
16+
robots?: string
1617
}
1718
1819
const url = new URL(Astro.request.url)
@@ -29,8 +30,16 @@ type Metadata = {
2930
seo: Record<string, { description: string; image?: string }>
3031
}
3132
32-
const { title, navbar, navbarNoBg, ogImage, ogTitle, ogDescription, noFooter } =
33-
Astro.props as LayoutProps
33+
const {
34+
title,
35+
navbar,
36+
navbarNoBg,
37+
ogImage,
38+
ogTitle,
39+
ogDescription,
40+
noFooter,
41+
robots
42+
} = Astro.props as LayoutProps
3443
3544
const [{ seo }] = await Astro.glob<Metadata>('../data/metadata.json')
3645
@@ -188,6 +197,7 @@ const metaTitle = ogTitle ?? title ?? currentPageName
188197
defer
189198
data-website-id='4a088aa2-1e6f-4f97-9e95-9619983468de'
190199
src='https://bunseki.juxt.pro/t.js'></script>
200+
{robots && <meta name='robots' content={robots} />}
191201
</head>
192202
<body class='bg-gray-50 transition-colors'>
193203
{navbar && <Navbar navbarNoBg={navbarNoBg} />}

‎yarn.lock

+53-2
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@
143143
fast-xml-parser "^4.2.7"
144144
kleur "^4.1.5"
145145

146+
"@astrojs/sitemap@^3.2.1":
147+
version "3.2.1"
148+
resolved "https://registry.yarnpkg.com/@astrojs/sitemap/-/sitemap-3.2.1.tgz#ed3874861fbca83f9ca3e66ac24a0f7ae3f9cf49"
149+
integrity sha512-uxMfO8f7pALq0ADL6Lk68UV6dNYjJ2xGUzyjjVj60JLBs5a6smtlkBYv3tQ0DzoqwS7c9n4FUx5lgv0yPo/fgA==
150+
dependencies:
151+
sitemap "^8.0.0"
152+
stream-replace-string "^2.0.0"
153+
zod "^3.23.8"
154+
146155
"@astrojs/telemetry@3.0.3":
147156
version "3.0.3"
148157
resolved "https://registry.yarnpkg.com/@astrojs/telemetry/-/telemetry-3.0.3.tgz#a7a87a40de74bfeaae78fc4cbec1f6ec1cbf1c36"
@@ -790,7 +799,7 @@
790799
picocolors "^1.0.0"
791800
tslib "^2.6.0"
792801

793-
"@preact/compat@npm:@preact/compat", "react-dom@npm:@preact/compat", "react@npm:@preact/compat":
802+
"@preact/compat@npm:@preact/compat":
794803
version "17.1.2"
795804
resolved "https://registry.yarnpkg.com/@preact/compat/-/compat-17.1.2.tgz#928756713b07af6faf7812f6a56840d8ce6fed37"
796805
integrity sha512-7pOZN9lMDDRQ+6aWvjwTp483KR8/zOpfS83wmOo3zfuLKdngS8/5RLbsFWzFZMGdYlotAhX980hJ75bjOHTwWg==
@@ -1016,6 +1025,11 @@
10161025
dependencies:
10171026
undici-types "~5.25.1"
10181027

1028+
"@types/node@^17.0.5":
1029+
version "17.0.45"
1030+
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.45.tgz#2c0fafd78705e7a18b7906b5201a522719dc5190"
1031+
integrity sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==
1032+
10191033
"@types/node@^18.16.3":
10201034
version "18.18.6"
10211035
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.18.6.tgz#26da694f75cdb057750f49d099da5e3f3824cb3e"
@@ -1031,6 +1045,13 @@
10311045
resolved "https://registry.yarnpkg.com/@types/ps-tree/-/ps-tree-1.1.4.tgz#762883fb62e03080ced3fc15e702321968bf0009"
10321046
integrity sha512-CJyu2BqU/aZN/s8Ili3jiMctqXfTjCaWXirEcjRD8y1lUQZJ8eNohnal8+LXeWFs1VbdAOrCIdgATFsv+lnQ5Q==
10331047

1048+
"@types/sax@^1.2.1":
1049+
version "1.2.7"
1050+
resolved "https://registry.yarnpkg.com/@types/sax/-/sax-1.2.7.tgz#ba5fe7df9aa9c89b6dff7688a19023dd2963091d"
1051+
integrity sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==
1052+
dependencies:
1053+
"@types/node" "*"
1054+
10341055
"@types/semver@^7.5.0":
10351056
version "7.5.4"
10361057
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.4.tgz#0a41252ad431c473158b22f9bfb9a63df7541cff"
@@ -1317,7 +1338,7 @@ anymatch@~3.1.2:
13171338
normalize-path "^3.0.0"
13181339
picomatch "^2.0.4"
13191340

1320-
arg@^5.0.2:
1341+
arg@^5.0.0, arg@^5.0.2:
13211342
version "5.0.2"
13221343
resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c"
13231344
integrity sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==
@@ -5142,11 +5163,21 @@ rc@^1.2.7:
51425163
minimist "^1.2.0"
51435164
strip-json-comments "~2.0.1"
51445165

5166+
"react-dom@npm:@preact/compat":
5167+
version "17.1.2"
5168+
resolved "https://registry.yarnpkg.com/@preact/compat/-/compat-17.1.2.tgz#928756713b07af6faf7812f6a56840d8ce6fed37"
5169+
integrity sha512-7pOZN9lMDDRQ+6aWvjwTp483KR8/zOpfS83wmOo3zfuLKdngS8/5RLbsFWzFZMGdYlotAhX980hJ75bjOHTwWg==
5170+
51455171
react-hook-form@^7.43.1:
51465172
version "7.51.1"
51475173
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.51.1.tgz#3ce5f8b5ef41903b4054a641cef8c0dc8bf8ae85"
51485174
integrity sha512-ifnBjl+kW0ksINHd+8C/Gp6a4eZOdWyvRv0UBaByShwU8JbVx5hTcTWEcd5VdybvmPTATkVVXk9npXArHmo56w==
51495175

5176+
"react@npm:@preact/compat":
5177+
version "17.1.2"
5178+
resolved "https://registry.yarnpkg.com/@preact/compat/-/compat-17.1.2.tgz#928756713b07af6faf7812f6a56840d8ce6fed37"
5179+
integrity sha512-7pOZN9lMDDRQ+6aWvjwTp483KR8/zOpfS83wmOo3zfuLKdngS8/5RLbsFWzFZMGdYlotAhX980hJ75bjOHTwWg==
5180+
51505181
read-cache@^1.0.0:
51515182
version "1.0.0"
51525183
resolved "https://registry.yarnpkg.com/read-cache/-/read-cache-1.0.0.tgz#e664ef31161166c9751cdbe8dbcf86b5fb58f774"
@@ -5612,6 +5643,16 @@ sisteransi@^1.0.5:
56125643
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
56135644
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==
56145645

5646+
sitemap@^8.0.0:
5647+
version "8.0.0"
5648+
resolved "https://registry.yarnpkg.com/sitemap/-/sitemap-8.0.0.tgz#eb6ea48f95787cd680b83683c555d6f6b5a903fd"
5649+
integrity sha512-+AbdxhM9kJsHtruUF39bwS/B0Fytw6Fr1o4ZAIAEqA6cke2xcoO2GleBw9Zw7nRzILVEgz7zBM5GiTJjie1G9A==
5650+
dependencies:
5651+
"@types/node" "^17.0.5"
5652+
"@types/sax" "^1.2.1"
5653+
arg "^5.0.0"
5654+
sax "^1.2.4"
5655+
56155656
slash@^3.0.0:
56165657
version "3.0.0"
56175658
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
@@ -5683,6 +5724,11 @@ stream-parser@~0.3.1:
56835724
dependencies:
56845725
debug "2"
56855726

5727+
stream-replace-string@^2.0.0:
5728+
version "2.0.0"
5729+
resolved "https://registry.yarnpkg.com/stream-replace-string/-/stream-replace-string-2.0.0.tgz#e49fd584bd1c633613e010bc73b9db49cb5024ad"
5730+
integrity sha512-TlnjJ1C0QrmxRNrON00JvaFFlNh5TTG00APw23j74ET7gkQpTASi6/L2fuiav8pzK715HXtUeClpBTw2NPSn6w==
5731+
56865732
streamx@^2.15.0:
56875733
version "2.15.1"
56885734
resolved "https://registry.yarnpkg.com/streamx/-/streamx-2.15.1.tgz#396ad286d8bc3eeef8f5cea3f029e81237c024c6"
@@ -6680,6 +6726,11 @@ zod@3.21.1:
66806726
resolved "https://registry.yarnpkg.com/zod/-/zod-3.21.1.tgz#ac5bb7cf68876281ebd02f95ac4bb9a080370282"
66816727
integrity sha512-+dTu2m6gmCbO9Ahm4ZBDapx2O6ZY9QSPXst2WXjcznPMwf2YNpn3RevLx4KkZp1OPW/ouFcoBtBzFz/LeY69oA==
66826728

6729+
zod@^3.23.8:
6730+
version "3.24.2"
6731+
resolved "https://registry.yarnpkg.com/zod/-/zod-3.24.2.tgz#8efa74126287c675e92f46871cfc8d15c34372b3"
6732+
integrity sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==
6733+
66836734
zwitch@^2.0.0, zwitch@^2.0.4:
66846735
version "2.0.4"
66856736
resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-2.0.4.tgz#c827d4b0acb76fc3e685a4c6ec2902d51070e9d7"

0 commit comments

Comments
 (0)
Please sign in to comment.