Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor -> Migrate from NextJS to Astro #205

Merged
merged 124 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
3fff41c
init
iammatthias Mar 4, 2024
d1fa756
vercel.json
iammatthias Mar 4, 2024
9a51fde
add @astrojs/check
iammatthias Mar 4, 2024
63aaf70
Fix import paths
iammatthias Mar 4, 2024
54d8fac
module resolution
iammatthias Mar 4, 2024
13f314d
Remove a console.log
iammatthias Mar 4, 2024
388685c
Fix import paths
iammatthias Mar 4, 2024
62e77c0
Fix imports and tsconfig
iammatthias Mar 4, 2024
f5f199f
tweak vercel.json
iammatthias Mar 4, 2024
0c06d46
tweak vercel.json
iammatthias Mar 4, 2024
9064226
Fix imports and tsconfig
iammatthias Mar 4, 2024
18335fa
tweak vercel.json
iammatthias Mar 4, 2024
4749417
tweak vercel.json
iammatthias Mar 4, 2024
b62f857
tweak vercel.json
iammatthias Mar 4, 2024
ba7e6ba
tweak vercel.json
iammatthias Mar 4, 2024
4485546
tweak vercel.json
iammatthias Mar 4, 2024
61f9c9c
Update dependencies and add ImportMetaEnv interface
iammatthias Mar 5, 2024
0fda64c
Update Astro configuration and page prerendering
iammatthias Mar 5, 2024
56f0717
skip typechecking for now
iammatthias Mar 5, 2024
a5c2f38
Update tsconfig and vercel.json
iammatthias Mar 5, 2024
d6cede3
remove ssr for now
iammatthias Mar 5, 2024
00364cc
attempting to fix a case issue
iammatthias Mar 5, 2024
74ea115
attempting to fix a case issue
iammatthias Mar 5, 2024
e1ed895
Remove demo stuff
iammatthias Mar 5, 2024
04139ef
Update Astro configuration and remove unused files
iammatthias Mar 5, 2024
abf9716
Update Astro configuration and remove unused files
iammatthias Mar 5, 2024
b9ed3af
Switch to ISR
iammatthias Mar 5, 2024
78f5faa
Fix responsive typography styles
iammatthias Mar 5, 2024
ceb6fff
Refactor error handling and add redirects for 404 pages
iammatthias Mar 5, 2024
f5c55cc
Update Astro configuration and Glass component
iammatthias Mar 5, 2024
7f83850
Update dependencies and fix code formatting. Add tags for all entry t…
iammatthias Mar 6, 2024
70cddad
Update bun.lockb file
iammatthias Mar 6, 2024
f186ad4
Remove default marker from details summary
iammatthias Mar 6, 2024
0b47d2d
Comment out Footer component and add conditional rendering based on e…
iammatthias Mar 7, 2024
48645bb
Remove unnecessary code and filter out unpublished entries in production
iammatthias Mar 7, 2024
f624d11
Update global.css, img.astro, glass.astro, [slug].astro, and index.astro
iammatthias Mar 7, 2024
577dae7
Update styles and links in components and pages
iammatthias Mar 7, 2024
4715f7a
Add a mobile menu
iammatthias Mar 8, 2024
bb7cd62
Refactor navigation component to improve mobile responsiveness
iammatthias Mar 8, 2024
fb7ef3f
Update responsive layout for masonry in glass component and navigation
iammatthias Mar 8, 2024
c425c49
Refactor navigation and image links
iammatthias Mar 8, 2024
3200a64
Add @fontsource-variable/kalnia package and update typography styles
iammatthias Mar 8, 2024
47308a9
Remove unnecessary pointer-events in nav component
iammatthias Mar 8, 2024
74da5b4
Remove unnecessary pointer-events in nav component
iammatthias Mar 8, 2024
71b503e
Update margin-bottom in glass component and remove media query in glo…
iammatthias Mar 8, 2024
aba2ace
Add medium-zoom library for image zooming
iammatthias Mar 8, 2024
49b1d81
Update background color and padding in components
iammatthias Mar 9, 2024
cfaa1bb
Remove image filter and center main content
iammatthias Mar 9, 2024
b9221df
Update styles and fix layout issues
iammatthias Mar 9, 2024
daea8c9
Update styles and content in nav and index pages
iammatthias Mar 10, 2024
4e99045
Update styles and content in nav and index pages
iammatthias Mar 10, 2024
6434355
Update navigation and content paths
iammatthias Mar 10, 2024
e927125
Fix min-height value in global.css
iammatthias Mar 10, 2024
1ae2929
Update blur effect and padding in CSS styles
iammatthias Mar 10, 2024
f1035c8
Update padding in responsive styles
iammatthias Mar 10, 2024
de7a5b5
Add z-index to element for improved layering
iammatthias Mar 10, 2024
f890562
Update colors and borders in index page and global styles
iammatthias Mar 10, 2024
34ade33
Update navigation links and styles
iammatthias Mar 11, 2024
597817d
Update navigation and reading time functionality
iammatthias Mar 11, 2024
e1ce400
Add posthog-js library and track image zoom event
iammatthias Mar 12, 2024
6d415e3
Add new dependencies and update code styling for highlight.js
iammatthias Mar 12, 2024
ecd4773
Add Astro DB integration and update dependencies
iammatthias Mar 13, 2024
6fe0af2
Update tsconfig.json include pattern
iammatthias Mar 13, 2024
57cf2f9
Update build script to use remote build
iammatthias Mar 13, 2024
ad46eb3
Update bun.lockb file
iammatthias Mar 14, 2024
97d1fdc
Update dependencies and fix TypeScript errors. Remove astro-db, go ba…
iammatthias Mar 16, 2024
9e3052b
Update bypassToken value in astro.config.mjs
iammatthias Mar 16, 2024
c2a5b1d
Update Astro config with bypass token
iammatthias Mar 17, 2024
76aaf7c
Add marked-alert package and update box-shadow styles
iammatthias Mar 17, 2024
e385ce5
Add staging file and hash file keys for tags
iammatthias Mar 17, 2024
8fdd97c
Update tag fetching URLs based on environment
iammatthias Mar 17, 2024
8fa7b90
Add getObsidianTags function call in [tag].astro file
iammatthias Mar 17, 2024
1d9b180
Remove unused import and function call in tag pages
iammatthias Mar 17, 2024
daf98ba
Refactor fetchExistingTagsHash to support staging environment
iammatthias Mar 17, 2024
37a2c88
Refactor conditional logic for fetching tags based on environment
iammatthias Mar 17, 2024
411a73d
Update padding and gap in tag masonry layout
iammatthias Mar 17, 2024
dad3619
Add prefetch configuration and update redirects***
iammatthias Mar 18, 2024
8b5a8b3
Refactor date formatting and update reading time calculation
iammatthias Mar 19, 2024
f7460a3
Remove Astro Studio configuration and update Astro config
iammatthias Mar 19, 2024
d54fb8c
Update Vercel workflow to trigger webhook on main branch and specific…
iammatthias Mar 19, 2024
cbf5d89
Update Vercel workflow to trigger deploy on 'astro' branch
iammatthias Mar 19, 2024
5d686ac
Update output to "hybrid" in astro.config.mjs
iammatthias Mar 19, 2024
609a5fd
Update Astro configuration and page files
iammatthias Mar 19, 2024
765900a
Update Astro config and page files
iammatthias Mar 19, 2024
dbbb4f3
Remove Vercel deployment workflow
iammatthias Mar 19, 2024
55ff912
Update Astro config to include ISR settings
iammatthias Mar 19, 2024
82654cd
Update styles and add border to navigation component
iammatthias Mar 21, 2024
0f9b431
Update package.json and astro.config.mjs, delete db/config.ts, and mo…
iammatthias Mar 21, 2024
d451b50
Add max-old-space-size flag to build script
iammatthias Mar 21, 2024
68ecde9
Update build script in package.json
iammatthias Mar 21, 2024
623c58d
Filter out unpublished entries in production environment
iammatthias Mar 21, 2024
f2f0c72
Remove NODE_OPTIONS from build script
iammatthias Mar 21, 2024
e922e1e
Switch back to ISR with vercel adaptor
iammatthias Mar 21, 2024
f845000
Update Astro configuration and page components
iammatthias Mar 21, 2024
1c2c167
Update Squiggle component in index.astro
iammatthias Mar 21, 2024
f0fd246
Add x-vercel-skip-toolbar header to vercel.json
iammatthias Mar 22, 2024
7651503
Add x-vercel-skip-toolbar header to vercel.json
iammatthias Mar 22, 2024
f2ad4e0
Update Vercel configuration to skip toolbar
iammatthias Mar 22, 2024
5801693
Update Vercel configuration to skip toolbar
iammatthias Mar 22, 2024
8c844f4
Update package dependencies and remove unnecessary headers in vercel.…
iammatthias Mar 23, 2024
05ef871
Update dependencies and styles in index.astro and layout.astro
iammatthias Mar 29, 2024
8829aeb
Fix encoding issue in SEO image title
iammatthias Mar 29, 2024
c6880c0
Remove Cache-Control header from og.png.ts
iammatthias Mar 29, 2024
d1b9d7d
Add optional description to SEO metadata and set Cache-Control header…
iammatthias Mar 29, 2024
44d2ccd
Remove favicon.svg and update font URL in og.png.ts
iammatthias Mar 29, 2024
964467b
Add request parameter to console.log in og.png.ts
iammatthias Mar 29, 2024
0d73bed
Refactor SEO image generation logic
iammatthias Mar 29, 2024
1e5287c
Remove commented out code and update image URL in layout.astro
iammatthias Mar 30, 2024
796ea4c
Add console.log statement and move resume page
iammatthias Mar 30, 2024
be89fd0
Update SEO image URL based on environment
iammatthias Mar 30, 2024
3ea3a17
Update base_url and comment out prerender in 404, index, and resume p…
iammatthias Mar 30, 2024
69e0881
Update astro.config.mjs and layout.astro files
iammatthias Mar 30, 2024
6b967f9
Update dependencies and add view transitions
iammatthias Mar 30, 2024
c33d226
Update README.md and layout.astro
iammatthias Mar 30, 2024
a09852b
Update README.md and layout.astro files
iammatthias Mar 30, 2024
a70b8d8
Update index.astro file
iammatthias Mar 31, 2024
1f10b85
Refactor social media links and update styling
iammatthias Apr 1, 2024
c474295
Add Squiggle component to index.astro
iammatthias Apr 1, 2024
c61cee0
Update dependencies and fix code formatting
iammatthias Apr 6, 2024
7d66bce
Update hitCounter component styling and add hitCounter to index page
iammatthias Apr 6, 2024
7bf59b4
Update hitCounter styles and remove commented code
iammatthias Apr 6, 2024
5c17ded
Update hitCounter position
iammatthias Apr 6, 2024
414bd0d
Update hitCounter component styling
iammatthias Apr 6, 2024
1a36d33
Refactor nonce handling in increment-page-view API
iammatthias Apr 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

52 changes: 17 additions & 35 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,46 +1,28 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# build output
dist/
.vercel/

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build
# generated types
.astro/

# misc
.DS_Store
*.pem
# dependencies
node_modules/

# debug
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# local env files
# environment variables
.env
.env*
.env.production

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
# macOS-specific files
.DS_Store

# feeds
public/feed
# blank tags file
tags.json

# next-video
videos/*
!videos/*.json
!videos/*.js
!videos/*.ts
public/_next-video
# Allow vercel.json
!vercel.json
13 changes: 13 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// .prettierrc.mjs
/** @type {import("prettier").Config} */
export default {
plugins: ["prettier-plugin-astro"],
overrides: [
{
files: "*.astro",
options: {
parser: "astro",
},
},
],
};
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
49 changes: 27 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
```
___ ___
/ /
/ / ___ _ __
/ / // ) ) // ) ) ) )
/ / // / / // / / / /
__/ /___ ((___( ( // / / / /


/| //| |
//| // | | ___ __ ___ __ ___ / __ ( ) ___ ___
// | // | | // ) ) / / / / // ) ) / / // ) ) (( ) )
// | // | | // / / / / / / // / / / / // / / \ \
// |// | | ((___( ( / / / / // / / / / ((___( ( // ) )
::::::::::: ::: ::: :::
:+: :+: :+: :+:+: :+:+:
+:+ +:+ +:+ +:+ +:+:+ +:+
+#+ +#++:++#++: +#+ +:+ +#+
+#+ +#+ +#+ +#+ +#+
#+# #+# #+# #+# #+#
########### ### ### ### ###

::: ::: ::: ::::::::::: ::::::::::: ::: ::: ::::::::::: ::: ::::::::
:+:+: :+:+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+:
+:+ +:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+
+#+ +:+ +#+ +#++:++#++: +#+ +#+ +#++:++#++ +#+ +#++:++#++: +#++:++#++
+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+#
### ### ### ### ### ### ### ### ########### ### ### ########
```

### hi

The current iteration of my personal website is a multi-tenant experiment.
After a few years on NextJS with various content backends (Contentful, Hygraph, Sanity, Tina, etc.), I've embraced a new approach.

One code base, one deployment, multiple websites with unique content.
The front-end is built with [Astro](https://astro.build/), and the content is authored in [Obsidian](https://obsidian.md/). The markdown files are stored in a private repo on Github, and pulled into the Astro site through the Github GraphQL API.

- iammatthias.com
- iammatthias.xyz
- iammatthias.art
Images that are added to the markdown in Obsidian are uploaded to a [Cloudflare R2](https://www.cloudflare.com/developer-platform/r2/) bucket, and the URLs are replaced in the markdown files. In Astro, these images are optimized and cached through [WSRV](https://wsrv.nl/).

The beauty of this system is that I can add new `tenants` at any point. Specific endpoints tied to specific domains for specific content.
The site is hosted on [Vercel](https://vercel.com/), and I'm using [PostHog](https://posthog.com/) for some basic analytics.

It is rough around the edges, but perfectly serviceable for my needs at the moment.
> The code is provided as-is, and I'm not planning to provide support for this setup. Feel free to use it as inspiration for your own projects.

### how it works
### built with

Within our root `page.tsx` we are checking the `host` header and rendering the appropriate tenant dynamically. This adds a slight delay to the initial load, but in practice it is not noticeable due to caching. Downstream data fetching is handled within `<Suspense />`.
- [Astro](https://astro.build/)
- [Obsidian](https://obsidian.md/)
- [PostHog](https://posthog.com/)
- [Vercel](https://vercel.com/)
- [WSRV](https://wsrv.nl/)
- [Cloudflare R2](https://www.cloudflare.com/developer-platform/r2/)
12 changes: 6 additions & 6 deletions additional.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare module "uuid";
declare module "alpinejs-masonry";

declare module "lodash.debounce";

declare module "rss";

declare module "@mapbox/rehype-prism";
interface ImportMetaEnv {
readonly github: string;
readonly r2_key: string;
readonly r2_secret: string;
}
53 changes: 53 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { defineConfig } from "astro/config";
import alpine from "@astrojs/alpinejs";
import vercel from "@astrojs/vercel/serverless";

// https://astro.build/config
export default defineConfig({
integrations: [alpine()],
output: "server",
adapter: vercel({
isr: {
// F16
bypassToken: "01123581321345589144233377610987",
expiration: 60 * 60 * 24 * 30, // cache for 30 days
},
}),
prefetch: {
prefetchAll: true,
},
redirects: {
"./post/1563778800000": {
status: 302,
destination: "./notes/1563778800000-flatframe",
},
"./post/1587970800000": {
status: 302,
destination: "./notes/1587970800000-sourdough",
},
"./post/1687071600000": {
status: 302,
destination: "./notes/1687071600000-feels-like-summer",
},
"./post/1681369200000": {
status: 302,
destination: "./posts/1681369200000-ai-legion-on-bluesky",
},
"./post/1670659200001": {
status: 302,
destination: "./posts/1670659200001-obsidian-as-a-cms",
},
"./post/1691436904927": {
status: 302,
destination: "./posts/1691436904927-deploy-html-on-replit",
},
"./post/1699332127006": {
status: 302,
destination: "./posts/1699332127006-revisiting-obsidian-as-a-cms",
},
"./post/*": {
status: 302,
destination: "./posts",
},
},
});
Binary file added bun.lockb
Binary file not shown.
61 changes: 0 additions & 61 deletions next.config.mjs

This file was deleted.

Loading
Loading