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

Astro rewrite #53

Merged
merged 74 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
b1508d8
feat: work on layout, seo
florian-lefebvre Dec 13, 2023
45f20fc
feat: work on static pages
florian-lefebvre Dec 13, 2023
66ae02c
feat: work on api routes
florian-lefebvre Dec 13, 2023
cdac400
feat: work on post page
florian-lefebvre Dec 13, 2023
7c419ac
feat: work on dynamic og image
florian-lefebvre Dec 13, 2023
c179862
move to cloudflare from vercel
anonrig Dec 15, 2023
2df32ed
fix cloudflare import
anonrig Dec 16, 2023
da46d43
fix base url
anonrig Dec 16, 2023
e80a585
fix: font error on build
florian-lefebvre Dec 27, 2023
1aad1be
chore: upgrade deps
florian-lefebvre Dec 27, 2023
e6e2b84
feat: add post og image to head
florian-lefebvre Dec 27, 2023
82865a1
feat: rework seo
florian-lefebvre Dec 27, 2023
a655942
feat: work on markdown plugins
florian-lefebvre Dec 27, 2023
6954b10
Merge branch 'main' into astro-rewrite
florian-lefebvre Dec 27, 2023
ff3b999
chore: add latest updates
florian-lefebvre Dec 27, 2023
73d4787
feat: refactor blog posts to use astro image
florian-lefebvre Dec 27, 2023
6d4af7c
feat: refactor pages to use astro image
florian-lefebvre Dec 27, 2023
54e03f2
chore: remove type from content entries
florian-lefebvre Dec 27, 2023
07d6357
feat: use astro image whenever possible
florian-lefebvre Dec 27, 2023
5de73be
feat: use astro components whenever possible
florian-lefebvre Dec 27, 2023
5caa2da
fix: code snippets
florian-lefebvre Dec 28, 2023
04d12c2
feat: tweak client directives
florian-lefebvre Dec 28, 2023
7f08217
feat: setup sentry and spotlight
florian-lefebvre Dec 28, 2023
bba1e35
feat: work on cli
florian-lefebvre Dec 28, 2023
61f7367
fix: disable sentry server-side
florian-lefebvre Dec 28, 2023
4743f04
feat: work on seo
florian-lefebvre Dec 28, 2023
fa46302
feat: apply recommendations from a11y audit
florian-lefebvre Dec 28, 2023
c824d43
fix: visual regressions
florian-lefebvre Dec 28, 2023
8ba37c1
feat: move astro from temp to root
florian-lefebvre Dec 28, 2023
cdab405
chore: upgrade deps
florian-lefebvre Dec 28, 2023
42bc0eb
chore: format
florian-lefebvre Dec 28, 2023
61c73cd
fix: use Buffer instead of btoa
florian-lefebvre Dec 28, 2023
fc58440
fix: linkinator action
florian-lefebvre Dec 28, 2023
33fcaf9
feat: apply lighthouse recommendations
florian-lefebvre Dec 28, 2023
e606ea4
feat: use cloudflare image service
florian-lefebvre Dec 28, 2023
8adc66b
Revert "feat: use cloudflare image service"
florian-lefebvre Dec 28, 2023
9a4f819
chore: format
florian-lefebvre Dec 28, 2023
76b6d8a
fix: add .png to opengraph path
florian-lefebvre Dec 28, 2023
08a9fc8
fix: reenable biome security
florian-lefebvre Dec 28, 2023
92e19c2
Update package.json
florian-lefebvre Dec 28, 2023
2373d43
Update package.json
florian-lefebvre Dec 28, 2023
43a4782
Update package.json
florian-lefebvre Dec 28, 2023
57c702f
chore: add format command
florian-lefebvre Dec 28, 2023
19d1ee8
feat: apply recommendations
florian-lefebvre Dec 28, 2023
5dddf4b
feat: remove import alias from image paths in mdx files
florian-lefebvre Dec 28, 2023
718c14b
Update src/content/config.ts
florian-lefebvre Dec 28, 2023
313c1de
feat: extract layout constants to content.ts
florian-lefebvre Dec 28, 2023
dc1b79d
feat: apply recommendations
florian-lefebvre Dec 28, 2023
e1bf65d
fix: get image length
florian-lefebvre Dec 28, 2023
29fceea
refactor cli
anonrig Dec 28, 2023
ee0683b
add biome github workflow
anonrig Dec 28, 2023
394a7cf
enable sentry server-side
anonrig Jan 2, 2024
9ace3c6
fix commonjs issues due to noExternal SSR
anonrig Jan 3, 2024
9b7cc33
update dependencies
anonrig Jan 3, 2024
258b642
feat: catch up with main's changes and upgrade dependencies
florian-lefebvre Jan 14, 2024
42922b3
Merge branch 'astro-rewrite' of https://github.com/anonrig/yagiz.co i…
florian-lefebvre Jan 14, 2024
3101026
feat: enable cloudflare compile image service
florian-lefebvre Jan 14, 2024
6bfb91a
Merge branch 'main' into astro-rewrite
florian-lefebvre Jan 14, 2024
fa79c9d
chore: remove temp file
florian-lefebvre Jan 14, 2024
20d291f
simplify implementation
anonrig Feb 27, 2024
ef62124
refactor content
anonrig Feb 27, 2024
a6fefcd
simplify contents
anonrig Mar 7, 2024
f581061
update dependencies
anonrig Mar 7, 2024
14c2aad
remove .vscode
anonrig Mar 7, 2024
9589aec
update content
anonrig Mar 7, 2024
8f61290
update biome and simplify code
anonrig Mar 8, 2024
6d0b16d
make sticky header an astro component
anonrig Mar 8, 2024
cef5f29
simplify sorting
anonrig Mar 8, 2024
b53c09d
change async function usage
anonrig Mar 8, 2024
c9f7d71
add lucide-astro
anonrig Mar 8, 2024
fe68ecf
remove mobile navigation
anonrig Mar 8, 2024
c83b8f5
add wrangler for preview
anonrig Mar 8, 2024
e5f25a1
Merge branch 'main' into astro-rewrite
anonrig Mar 8, 2024
1009fce
revert unnecessary css
anonrig Mar 8, 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
42 changes: 29 additions & 13 deletions .github/cli/create-blog.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
import fs from 'node:fs'
import path from 'node:path'

import { cancel, group, outro, select, spinner, text } from '@clack/prompts'
import { format } from 'date-fns'

import { allBlogs, allTags } from '../../.contentlayer/generated/index.mjs'
/**
* Converts a date into `YYYY-MM-DD` format.
* @param {Date} date
* @return {string}
*/
function format(date) {
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')

return `${year}-${month}-${day}`
}

const contentFolder = path.resolve('./src/content')
const allTags = fs
.readdirSync(path.join(contentFolder, 'tags'))
.map((f) => path.basename(f, path.extname(f)))

const folder = new URL('../../content', import.meta.url).pathname
/**
* Returns a template for the blog post.
* @param {{ title: string; description: string; tag: string; status: string; }} param0
* @return {string}
*/
const getTemplateFor = ({ title, description, tag, status }) =>
`
---
title: '${title}'
description: >-
${description}
type: Blog
date: '${format(new Date(), 'yyyy-MM-dd')}'
date: '${format(new Date())}'
tag: ${tag}
status: ${status}
---
`.trim()
`.trimStart()

export async function createBlog() {
const { title, slug, description, tag, status } = await group(
Expand All @@ -42,8 +60,7 @@ export async function createBlog() {
return 'Value is required'
}

const file = path.join(folder, `${value}.mdx`)
if (fs.existsSync(file)) {
if (fs.existsSync(path.join(contentFolder, `blog/${value}.mdx`))) {
return 'Slug is already used'
}

Expand All @@ -65,9 +82,8 @@ export async function createBlog() {
message: 'Select a tag',
required: true,
options: allTags.map((tag) => ({
value: `tags/${tag.slug}.mdx`,
label: tag.title,
hint: `${allBlogs.filter((b) => b.tag.slug === tag.slug).length} blogs written`,
value: tag,
label: tag,
})),
}),
status: () =>
Expand Down Expand Up @@ -96,8 +112,8 @@ export async function createBlog() {
})
const creating = spinner()
creating.start('Creating the document')
const documentPath = path.join(folder, `blog/${slug}.mdx`)
await fs.promises.writeFile(documentPath, template.trim(), 'utf-8')
const documentPath = path.join(contentFolder, `blog/${slug}.mdx`)
fs.writeFileSync(documentPath, template.trim(), 'utf-8')
creating.stop()

outro(`Blog post is created at ${documentPath}`)
Expand Down
33 changes: 21 additions & 12 deletions .github/cli/send-email.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import fs from 'node:fs'
import path from 'node:path'
import mjml2html from 'mjml'
import Mailjet from 'node-mailjet'

import { cancel, confirm, group, select, spinner } from '@clack/prompts'
import { compareDesc } from 'date-fns'
import Handlebars from 'handlebars'
import { allBlogs } from '../../.contentlayer/generated/index.mjs'

const publishedBlogs = allBlogs
.filter((b) => b.status === 'published')
.sort((a, b) => compareDesc(new Date(a.date), new Date(b.date)))
import { readSync } from 'to-vfile'
import { matter } from 'vfile-matter'

const blogPath = path.resolve('./src/content/blog')
const publishedBlogs = fs
.readdirSync(blogPath)
.map((file) => {
const slug = path.basename(file, path.extname(file))
const contents = readSync(path.join(blogPath, file))
matter(contents)
return { slug, data: contents.data.matter }
})
.filter((b) => b.data.status === 'published')
.sort((a, b) => +new Date(b.data.date) - +new Date(a.data.date))

const { pathname: templatePath } = new URL('../blog.mjml', import.meta.url)
const templatePath = path.resolve('./.github/blog.mjml')
const template = await fs.promises.readFile(templatePath, 'utf-8')

export async function sendEmail() {
Expand All @@ -21,7 +30,7 @@ export async function sendEmail() {
select({
message: 'Which blog post do you want to write about?',
options: publishedBlogs.map((blog) => ({
label: blog.title,
label: blog.data.title,
value: blog.slug,
})),
}),
Expand All @@ -34,7 +43,7 @@ export async function sendEmail() {
},
)

const blog = allBlogs.find((b) => b.slug === slug)
const blog = publishedBlogs.find((b) => b.slug === slug)
const { errors, html } = mjml2html(template, {
validationLevel: 'strict',
preprocessors: [
Expand All @@ -43,8 +52,8 @@ export async function sendEmail() {
return handle({
heading: 'Engineering with Yagiz',
imageUrl: 'https://www.yagiz.co/family.png',
title: blog.title,
description: blog.description,
title: blog.data.title,
description: blog.data.description,
url: `https://www.yagiz.co/${blog.slug}`,
})
},
Expand Down Expand Up @@ -109,7 +118,7 @@ export async function sendEmail() {
Name: 'Yagiz Nizipli',
},
],
Subject: `New post: ${blog.title}`,
Subject: `New post: ${blog.data.title}`,
HTMLPart: html,
TrackOpens: 'enabled',
TrackClicks: 'enabled',
Expand Down
5 changes: 3 additions & 2 deletions .github/cli/update-sponsorships.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Go to https://github.com/sponsors/anonrig/dashboard/your_sponsors
// Click to Export button and save it to .github/sponsorships.json

import fs from 'node:fs'
import { cancel, confirm, isCancel, spinner } from '@clack/prompts'
import open from 'open'
// Go to https://github.com/sponsors/anonrig/dashboard/your_sponsors
// Click to Export button and save it to .github/sponsorships.json

function get_tier(transaction, sponsor) {
if (transaction == null && sponsor.is_yearly) {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- uses: actions/checkout@v4
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
folder-path: 'content'
folder-path: 'src/content'
18 changes: 18 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
name: Linter
jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v1
with:
version: "latest"
- name: Run Biome
run: biome check .
48 changes: 13 additions & 35 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,48 +1,26 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# build output
dist/
# generated types
.astro/

# dependencies
/node_modules
/.pnp
.pnp.js
node_modules/

# testing
/coverage

# next.js
.next
out

# production
/build

# misc
.DS_Store
*.pem

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

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
# vscode
.vscode

.contentlayer

# Dotenv
# environment variables
.env
.env.production

sponsorships.json
# macOS-specific files
.DS_Store

# Sentry Config File
.sentryclirc

sponsorships.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## yagiz.co

This repository contains the source code and content of my personal blog, [yagiz.co](https://www.yagiz.co). The blog is built with Next.js and styled with Tailwind CSS.
This repository contains the source code and content of my personal blog, [yagiz.co](https://www.yagiz.co). The blog is built with [Astro](https://astro.build) and styled with [Tailwind CSS](https://tailwindcss.com).

### Getting started

Expand Down
37 changes: 0 additions & 37 deletions app/[slug]/og/route.tsx

This file was deleted.

Loading