1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-22 09:13:35 +01:00
🍭 My blog kremalicious.com built with Astro. Neat. https://kremalicious.com
Go to file
dependabot[bot] af0a76e21e
Bump @vitest/coverage-v8 from 1.3.1 to 1.6.0 (#924)
Bumps [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) from 1.3.1 to 1.6.0.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v1.6.0/packages/coverage-v8)

---
updated-dependencies:
- dependency-name: "@vitest/coverage-v8"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-10 12:15:34 +01:00
.config Bump stylelint and stylelint-config-standard (#886) 2024-01-26 11:45:26 +00:00
.github ci tweaks 2024-03-12 23:21:48 +00:00
content lint fix 2023-12-12 20:08:18 +00:00
public update robots.txt to block more AI bots 2024-03-29 13:43:37 +00:00
scripts test fixes 2023-11-06 13:37:27 +00:00
src update tests 2024-03-14 13:29:08 +00:00
test update tests 2024-03-14 13:29:08 +00:00
.editorconfig add prettier-plugin-sort-imports 2023-01-29 21:58:19 +00:00
.env.sample api url tweaks 2023-11-05 11:48:00 +00:00
.eslintrc.json Gatsby → Astro (#829) 2023-09-18 02:16:53 +01:00
.gitignore Switch to astro-redirect-from (#830) 2023-09-23 21:32:18 +01:00
.nvmrc switch to Node.js v20, package updates 2024-03-12 20:13:00 +00:00
.prettierrc.json Gatsby → Astro (#829) 2023-09-18 02:16:53 +01:00
LICENSE cleanup 2018-08-29 00:17:24 +02:00
package-lock.json Bump @vitest/coverage-v8 from 1.3.1 to 1.6.0 (#924) 2024-06-10 12:15:34 +01:00
package.json Bump @vitest/coverage-v8 from 1.3.1 to 1.6.0 (#924) 2024-06-10 12:15:34 +01:00
README.md lint fix 2023-12-12 20:08:18 +00:00
tsconfig.json test fixes 2023-11-06 13:37:27 +00:00

GitHub Header

🍭 My blog built with Astro + TypeScript. Neat.

kremalicious.com

CI workflow badge CodeClimate maintainability badge CodeClimate coverage badge



🎉 Features

The whole blog is a statically exported site built with Astro and TypeScript. Almost all components are Astro or native Web Components, with some React components loaded client-side.

Styling happens through a combination of basic global styles and on components level either through CSS modules or CSS in <style> tags within Astro components.

Content lives under content/ and Astro creates a content collection for each subfolder, which are then queried in components. Every post is a folder with a markdown file and all respective post assets co-located inside.

Retrieving content collections will enrich every post's frontmatter metadata, like extracting date and slug from the post folder name, or exif extraction for photos.

🌅 Image handling

Uses Astro's native astro:assets feature, all required image sizes are automatically generated from source images, working in combination with my own custom <picture> component. Making heavy use of Astro's getImage() and custom markup results in full image sizing control and properly object-fit images with varying aspect ratios.

Teaser images are all defined in a post's frontmatter image key, which is then passed to the <Picture /> component for display.

If you want to know how this works, have a look at the respective files:

🎆 EXIF extraction

Automatically extracts EXIF & IPTC metadata from my photos and adds it to markdown frontmatter of respective photo posts. For minimal overhead, fast-exif & node-iptc is used to parse every JPG file whenever a content collection is accessed.

In the end looks like this, including location display with pigeon-maps:

screen shot 2018-10-14 at 20 27 39

If you want to know how this works, have a look at the respective files:

💰 Cryptocurrency donation via Web3 browser wallets

Lets visitors say thanks with Ether, any ERC-20, or Bitcoin. The Web3 wallet integration uses RainbowKit for wallet connection, my own custom web3 API to fetch wallet token balances and metadata, and wagmi for sending transactions.

Screenshot 2023-11-05 at 20 18 50 Screenshot 2023-11-05 at 20 20 04

If you want to know how this works, have a look at the respective feature under

A global search is provided with fuse.js. Whenever search is opened, all posts metadata is fetched, which is then queried against when the search field is used. This prevents a huge search index from being bundled in the site build.

screen shot 2018-11-18 at 19 44 30

If you want to know how this works, have a look at the respective feature under

Under each post a list of related posts is displayed which are based on the tags and other metadata of the currently viewed post, also done with fuse.js.

screen shot 2018-10-11 at 21 03 03

If you want to know how this works, have a look at the respective component under

📝 GitHub Changelog Rendering

Adds ability to show contents of a changelog, rendered from a CHANGELOG.md on GitHub from the given repository. The use case is to enhance release posts about projects hosted on GitHub. Makes use of the GitHub GraphQL API.

Adding this to a post's YAML frontmatter:

changelog: kremalicious/gatsby-plugin-matomo

will render this at the end of the post:

screen shot 2018-11-21 at 23 03 38

See it live e.g. on Matomo plugin for Gatsby.

If you want to know how this works, have a look at the respective component under

🌗 Theme Switcher

Includes a theme switcher which allows user to toggle between a light and a dark theme. Switching between them also happens automatically based on user's system preferences.

If you want to know how, have a look at the respective components:

💎 SVG assets as components

All SVG assets under src/images/ and from select iconset dependencies are converted to Astro & React components before building the site. Compiled components are placed under src/images/components/ and all include the cleaned SVGs as inline HTML.

All SVGs can then be imported from @images/components in all Astro or React components.

If you want to know how this works, have a look at the script:

astro-redirect-from

Still a remnant of the old Jekyll days, which survived in gatsby-redirect-from and now works in Astro with astro-redirect-from.

For all post slugs defined in a redirect_from frontmatter key, redirects will be put in place by Astro.

RSS & JSON feeds

Generates rss & json feeds upon build time.

If you want to know how this works, have a look at the respective files:

Development

git clone git@github.com:kremalicious/blog.git
cd blog/

# required env vars
cp .env.sample .env
vi .env

npm i
npm start

🔮 Linting

ESlint, Prettier, and Stylelint are setup for all linting purposes:

npm run lint

To automatically format all code files:

npm run format

🔮 Type Checking

Type checking can be invoked to check all TypeScript code, including within .astro files:

npm run typecheck

👩‍🔬 Testing

Test suite is setup with Vitest, react-testing-library, and Playwright.

All unit test files live beside the respective component with naming pattern *.test.ts(x). Integration test files live under ./test/e2e/ exclusively, with naming pattern *.spec.ts.

Testing setup, fixtures, and mocks shared between unit & integration tests can be found in ./test folder.

To run all unit tests:

npm run test:unit

# watch mode
npm run test:unit:watch

For End-to-End integration testing, ideally run against the production build:

npm run build && npm run preview

# mapping `playwright` command
npm run test:e2e
npm run test:e2e -- --ui
npm run test:e2e -- path/to/file.spec.ts.
npm run test:e2e -- --update-snapshots

🎈 Content creation helpers

Add a new post

npm run new "Hello World"
npm run new "Hello World" 2017-12-27

Create a new photo post with date, title & description pre-filled from EXIF/IPTC data of a given image file:

npm run new photo /path/to/photo.jpg
npm run new photo /path/to/photo.jpg "Hello Photo Post"

🚚 Deployment

Every branch or Pull Request is automatically deployed by Vercel with their GitHub integration. A link to a preview deployment will appear under each Pull Request. Vercel is not used for the production deployment.

S3 Deployment

The latest deployment of the main branch is automatically deployed to S3 from the GitHub Action as the production deployment, aliased to kremalicious.com. The deploy command simply calls the scripts/deploy-s3.sh script, syncing the contents of the dist/ folder to S3:

npm run deploy:s3

🏛 Licenses

The MIT License (MIT)

EXCEPT FOR:

Posts

Creative Commons License

All post content under ./content/articles & ./content/links is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Photos & images

All photos & image assets are plain ol' copyright.

Copyright (c) 20082023 Matthias Kretschmann

Don't care if you fork & play with it, but you're not allowed to publish anything from it as a whole without my written permission. Also please be aware, the combination of typography, colors & layout makes up my brand identity. So please don't just clone everything, but rather do a remix!