Skip to content

Commit 2013603

Browse files
committed
Clean up broken links from validator output on build, refinements to site URL routine
1 parent 4109725 commit 2013603

11 files changed

Lines changed: 59 additions & 61 deletions

File tree

‎.github/helpers/build-actions.sh‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎.github/workflows/deployment-production.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
- name: Vercel build (production)
6363
env:
6464
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
65+
NODE_ENV: production
6566
run: vercel build --prod --token=${VERCEL_TOKEN}
6667

6768
##

‎_TODO.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,4 @@ Right now we're using string literals to define HTML email templates for site ma
5555

5656
Vercel AI Gateway, maybe could use for a chatbot:
5757

58-
Vercel AI Gateway, maybe could use for a chatbot:
59-
6058
https://vercel.com/kevin-browns-projects-dd474f73/astro-webstackbuilders-com/ai-gateway

‎astro.config.ts‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import AstroPWA from '@vite-pwa/astro'
22
import db from '@astrojs/db'
33
import icon from 'astro-icon'
4-
import linkValidator from 'astro-link-validator'
54
import lit from '@semantic-ui/astro-lit'
65
import mdx from '@astrojs/mdx'
76
import sentry from '@sentry/astro'
@@ -25,9 +24,11 @@ import {
2524
environmentalVariablesConfig,
2625
getSentryAuthToken,
2726
getSiteUrl,
28-
isGitHub,
27+
isDev,
28+
isProd,
2929
isUnitTest,
3030
isVercel,
31+
linkValidatorPlugin,
3132
markdownConfig,
3233
pwaConfig,
3334
vercelConfig,
@@ -76,12 +77,12 @@ const standardIntegrations = [
7677
exclude: ['downloads', '/articles/demo', 'testing'],
7778
}),
7879
}),
79-
/** Validate links in built site output on astro:build:done integration hook */
80-
linkValidator({
81-
checkExternal: isGitHub(),
82-
failOnBrokenLinks: false,
83-
verbose: true,
84-
}),
80+
/**
81+
* Validate links in built site output on astro:build:done integration hook. Ran locally
82+
* and on GitHub production builds because links can't be determined at build time in
83+
* GitHub preview environments.
84+
*/
85+
...(isDev() || isProd() ? [linkValidatorPlugin] : []),
8586
/** Integration to write pages.json after build so E2E tests can discover what pages exist */
8687
pagesJsonWriter(),
8788
/** Debugging tools for Astro View Transition API */

‎package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@
2929
"servers/*"
3030
],
3131
"scripts": {
32-
"build:action": "FORCE_COLOR=1 bash .github/helpers/build-actions.sh",
3332
"build": "cross-env NODE_ENV=production npx astro build --remote",
34-
"build:ci": "cross-env npm run build",
33+
"build:ci": "cross-env NODE_ENV=production npx astro build",
3534
"check": "npx astro check",
3635
"clean": "FORCE_COLOR=1 npx rimraf dist && FORCE_COLOR=1 npx rimraf .astro",
3736
"containers:down": "FORCE_COLOR=1 docker compose --env-file test/containers/.env -f test/containers/docker-compose.e2e.yml down -v",

‎src/components/Footer/index.astro‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const year = new Date().getFullYear()
151151
{/* Page footer RSS link */}
152152
<span class:list={[styles.footerFeedIcon, 'flex items-center w-12 lg:h-12 lg:w-12']}>
153153
<a
154-
href={`${getSiteUrl()}/feed.xml`}
154+
href={`${getSiteUrl()}/rss.xml`}
155155
title="RSS Feed"
156156
class="text-text [&_.icon]:fill-text! [&_.icon]:stroke-text! [&_.icon]:h-10 [&_.icon]:w-10 hover:[&_.icon]:fill-secondary! hover:[&_.icon]:stroke-secondary! focus:[&_.icon]:fill-secondary! focus:[&_.icon]:stroke-secondary! focus:outline-none"
157157
>
@@ -178,7 +178,7 @@ const year = new Date().getFullYear()
178178
{/* Page footer RSS link */}
179179
<span class:list={[styles.footerFeedIcon, 'flex items-center w-12 lg:h-12 lg:w-12']}>
180180
<a
181-
href={`${getSiteUrl()}/feed.xml`}
181+
href={`${getSiteUrl()}/rss.xml`}
182182
title="RSS Feed"
183183
class="text-text [&_.icon]:fill-text! [&_.icon]:stroke-text! [&_.icon]:h-10 [&_.icon]:w-10 hover:[&_.icon]:fill-secondary! hover:[&_.icon]:stroke-secondary! focus:[&_.icon]:fill-secondary! focus:[&_.icon]:stroke-secondary! focus:outline-none"
184184
>

‎src/lib/config/environmentServer.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ export const isCI = () => {
3131
}
3232

3333
export const isDev = () => {
34-
return !isVercel()
34+
return !isVercel() && !isGitHub()
3535
}
3636

3737
export const isProd = () => {
38-
return isVercel()
38+
return isVercel() || process.env['NODE_ENV'] === 'production'
3939
}
4040

4141
/**

‎src/lib/config/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export {
1111
isVercel,
1212
} from './environmentServer'
1313
export { getSiteUrl } from './siteUrlServer'
14+
export { linkValidatorPlugin } from './linkValidator'
1415
export { markdownConfig } from './markdown'
1516
export { pwaConfig } from './pwa'
1617
export { vercelConfig } from './vercel'

‎src/lib/config/linkValidator.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import linkValidator from 'astro-link-validator'
2+
3+
export const linkValidatorPlugin = linkValidator({
4+
checkExternal: true,
5+
exclude: [
6+
/**
7+
* Company social network links are manually maintained, rated
8+
* limited in CI so hard to check automatically
9+
*/
10+
'https://bsky.app/profile/webstackdev.bsky.social',
11+
'https://codepen.io/webstackdev',
12+
'https://github.com/webstackdev',
13+
'https://k8s.social/@webstackdev',
14+
'https://webmention.io/www.webstackbuilders.com',
15+
'https://www.facebook.com/webstackbuilders',
16+
'https://www.instagram.com/webstackbuilders/',
17+
'https://www.linkedin.com/company/webstack-builders',
18+
'https://www.youtube.com/@webstackbuilders',
19+
'https://x.com/WebstackDev',
20+
/** Requires HEAD request, not GET */
21+
'https://outlook.office.com/calendar/0/deeplink/compose',
22+
/** Rate-limited URLs that will always fail */
23+
'https://www.npmjs.com',
24+
/** Dummy link in demo page */
25+
'/path/to#my-blob',
26+
],
27+
failOnBrokenLinks: false,
28+
verbose: true,
29+
})

‎src/lib/config/siteUrlServer.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
* Server-side method to determine correct URL
33
*/
44
import { BuildError } from '../errors/BuildError'
5-
import { isVercel } from './environmentServer'
5+
import {
6+
isProd,
7+
isVercel
8+
} from './environmentServer'
69

710
const devServerPort = process.env['DEV_SERVER_PORT']?.trim()
811
const resolvedDevServerPort = devServerPort && devServerPort.length > 0 ? devServerPort : '4321'
@@ -17,5 +20,9 @@ export const getSiteUrl = (): string => {
1720
)
1821
}
1922

23+
if (isProd()) {
24+
return 'https://www.webstackbuilders.com'
25+
}
26+
2027
return `http://localhost:${resolvedDevServerPort}`
2128
}

0 commit comments

Comments
 (0)