1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-22 01:03:37 +01:00

Location fetching (#843)

* location component

* fetching with @nanostores/query

* layouts reorg

* typescript plugins cleanup

* location component unit test cases

* fetch only when visible
This commit is contained in:
Matthias Kretschmann 2023-10-04 14:45:54 +01:00 committed by GitHub
parent 956e2030d0
commit 3b25ae2282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 350 additions and 861 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

262
package-lock.json generated
View File

@ -13,7 +13,7 @@
"@astrojs/react": "^3.0.2",
"@astrojs/rss": "^3.0.0",
"@astrojs/sitemap": "^3.0.0",
"@astrojs/ts-plugin": "^1.1.3",
"@nanostores/query": "^0.2.4",
"@nanostores/react": "^0.7.1",
"@rainbow-me/rainbowkit": "^1.0.11",
"astro": "3.2.2",
@ -73,7 +73,6 @@
"svgo": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"typescript-plugin-css-modules": "^5.0.1",
"unist-util-visit": "^5.0.0",
"vite-tsconfig-paths": "^4.2.1",
"vitest": "^0.34.6"
@ -302,18 +301,6 @@
"node": ">=18.14.1"
}
},
"node_modules/@astrojs/ts-plugin": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@astrojs/ts-plugin/-/ts-plugin-1.1.3.tgz",
"integrity": "sha512-nErNpgHGMzOOBHmUdml3cEZv4nxowGpO4G+IfAsPBQXOKLLGbVXzNpIGrdIthk3ryGD3jsYOKBvv2/PrnTkRdA==",
"dependencies": {
"@astrojs/compiler": "1.5.7",
"@jridgewell/sourcemap-codec": "^1.4.15",
"@volar/language-core": "~1.10.0",
"@volar/typescript": "~1.10.0",
"vscode-languageserver-textdocument": "^1.0.8"
}
},
"node_modules/@babel/code-frame": {
"version": "7.22.13",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz",
@ -1993,6 +1980,20 @@
"tslib": "^2.3.1"
}
},
"node_modules/@nanostores/query": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/@nanostores/query/-/query-0.2.4.tgz",
"integrity": "sha512-DCQWQsqjABf4/5eN4opGt9MbD6opNxGyewmR/yRAEB999WCl+Cgz6G6WTy37KiKNRjkBP0yK6GN6BEvgnhDoIQ==",
"dependencies": {
"nanoevents": "7"
},
"engines": {
"node": "^14.0.0 || ^16.0.0 || >=18.0.0"
},
"peerDependencies": {
"nanostores": ">0.7"
}
},
"node_modules/@nanostores/react": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/@nanostores/react/-/react-0.7.1.tgz",
@ -2765,24 +2766,6 @@
"resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz",
"integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g=="
},
"node_modules/@types/postcss-modules-local-by-default": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@types/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.0.tgz",
"integrity": "sha512-0VLab/pcLTLcfbxi6THSIMVYcw9hEUBGvjwwaGpW77mMgRXfGF+a76t7BxTGyLh1y68tBvrffp8UWnqvm76+yg==",
"dev": true,
"dependencies": {
"postcss": "^8.0.0"
}
},
"node_modules/@types/postcss-modules-scope": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/postcss-modules-scope/-/postcss-modules-scope-3.0.1.tgz",
"integrity": "sha512-LNkp3c4ML9EQj2dgslp4i80Jxj72YK3HjYzrTn6ftUVylW1zaKFGqrMlNIyqBmPWmIhZ/Y5r0Y4T49Hk1IuDUg==",
"dev": true,
"dependencies": {
"postcss": "^8.0.0"
}
},
"node_modules/@types/prop-types": {
"version": "15.7.6",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.6.tgz",
@ -5756,7 +5739,8 @@
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.6.tgz",
"integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==",
"devOptional": true,
"optional": true,
"peer": true,
"dependencies": {
"is-what": "^3.14.1"
},
@ -6590,18 +6574,6 @@
"url": "https://github.com/fb55/domutils?sponsor=1"
}
},
"node_modules/dotenv": {
"version": "16.3.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
"dev": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/motdotla/dotenv?sponsor=1"
}
},
"node_modules/dset": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/dset/-/dset-3.1.2.tgz",
@ -6675,6 +6647,7 @@
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz",
"integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==",
"optional": true,
"peer": true,
"dependencies": {
"prr": "~1.0.1"
},
@ -8658,18 +8631,6 @@
"node": ">=0.10.0"
}
},
"node_modules/icss-utils": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz",
"integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==",
"dev": true,
"engines": {
"node": "^10 || ^12 || >= 14"
},
"peerDependencies": {
"postcss": "^8.1.0"
}
},
"node_modules/identity-obj-proxy": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz",
@ -8714,6 +8675,7 @@
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz",
"integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==",
"optional": true,
"peer": true,
"bin": {
"image-size": "bin/image-size.js"
},
@ -8725,7 +8687,8 @@
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.4.tgz",
"integrity": "sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA==",
"devOptional": true
"optional": true,
"peer": true
},
"node_modules/import-fresh": {
"version": "3.3.0",
@ -9299,7 +9262,8 @@
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz",
"integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==",
"devOptional": true
"optional": true,
"peer": true
},
"node_modules/is-wsl": {
"version": "3.1.0",
@ -9775,7 +9739,8 @@
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/less/-/less-4.2.0.tgz",
"integrity": "sha512-P3b3HJDBtSzsXUl0im2L7gTO5Ubg8mEN6G8qoTS77iXxXX4Hvu4Qj540PZDvQ8V6DmX6iXo98k7Md0Cm1PrLaA==",
"devOptional": true,
"optional": true,
"peer": true,
"dependencies": {
"copy-anything": "^2.0.1",
"parse-node-version": "^1.0.1",
@ -9802,6 +9767,7 @@
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"optional": true,
"peer": true,
"dependencies": {
"ms": "^2.1.1"
}
@ -9811,6 +9777,7 @@
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"optional": true,
"peer": true,
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
@ -9823,6 +9790,7 @@
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
"integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==",
"optional": true,
"peer": true,
"dependencies": {
"pify": "^4.0.1",
"semver": "^5.6.0"
@ -9836,6 +9804,7 @@
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"optional": true,
"peer": true,
"bin": {
"mime": "cli.js"
},
@ -9848,6 +9817,7 @@
"resolved": "https://registry.npmjs.org/needle/-/needle-3.2.0.tgz",
"integrity": "sha512-oUvzXnyLiVyVGoianLijF9O/RecZUf7TkBfimjGrLM4eQhXyeJwM6GeAWccwfQ9aa4gMCZKqhAOuLaMIcQxajQ==",
"optional": true,
"peer": true,
"dependencies": {
"debug": "^3.2.6",
"iconv-lite": "^0.6.3",
@ -9865,6 +9835,7 @@
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
"optional": true,
"peer": true,
"engines": {
"node": ">=6"
}
@ -9874,6 +9845,7 @@
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
"optional": true,
"peer": true,
"bin": {
"semver": "bin/semver"
}
@ -9891,15 +9863,6 @@
"node": ">= 0.8.0"
}
},
"node_modules/lilconfig": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz",
"integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==",
"dev": true,
"engines": {
"node": ">=10"
}
},
"node_modules/lines-and-columns": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
@ -10032,12 +9995,6 @@
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"node_modules/lodash.camelcase": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==",
"dev": true
},
"node_modules/lodash.isequal": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
@ -12582,6 +12539,14 @@
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-9.9.0.tgz",
"integrity": "sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg=="
},
"node_modules/nanoevents": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/nanoevents/-/nanoevents-7.0.1.tgz",
"integrity": "sha512-o6lpKiCxLeijK4hgsqfR6CNToPyRU3keKyyI6uwuHRvpRTbZ0wXw51WRgyldVugZqoJfkGFrjrIenYH3bfEO3Q==",
"engines": {
"node": "^14.0.0 || ^16.0.0 || >=18.0.0"
}
},
"node_modules/nanoid": {
"version": "3.3.6",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
@ -13312,7 +13277,8 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz",
"integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==",
"devOptional": true,
"optional": true,
"peer": true,
"engines": {
"node": ">= 0.10"
}
@ -13652,35 +13618,6 @@
"node": "^10 || ^12 || >=14"
}
},
"node_modules/postcss-load-config": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz",
"integrity": "sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==",
"dev": true,
"dependencies": {
"lilconfig": "^2.0.5",
"yaml": "^1.10.2"
},
"engines": {
"node": ">= 10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
"peerDependencies": {
"postcss": ">=8.0.9",
"ts-node": ">=9.0.0"
},
"peerDependenciesMeta": {
"postcss": {
"optional": true
},
"ts-node": {
"optional": true
}
}
},
"node_modules/postcss-media-query-parser": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/postcss-media-query-parser/-/postcss-media-query-parser-0.2.3.tgz",
@ -13688,50 +13625,6 @@
"dev": true,
"optional": true
},
"node_modules/postcss-modules-extract-imports": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz",
"integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==",
"dev": true,
"engines": {
"node": "^10 || ^12 || >= 14"
},
"peerDependencies": {
"postcss": "^8.1.0"
}
},
"node_modules/postcss-modules-local-by-default": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.3.tgz",
"integrity": "sha512-2/u2zraspoACtrbFRnTijMiQtb4GW4BvatjaG/bCjYQo8kLTdevCUlwuBHx2sCnSyrI3x3qj4ZK1j5LQBgzmwA==",
"dev": true,
"dependencies": {
"icss-utils": "^5.0.0",
"postcss-selector-parser": "^6.0.2",
"postcss-value-parser": "^4.1.0"
},
"engines": {
"node": "^10 || ^12 || >= 14"
},
"peerDependencies": {
"postcss": "^8.1.0"
}
},
"node_modules/postcss-modules-scope": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz",
"integrity": "sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==",
"dev": true,
"dependencies": {
"postcss-selector-parser": "^6.0.4"
},
"engines": {
"node": "^10 || ^12 || >= 14"
},
"peerDependencies": {
"postcss": "^8.1.0"
}
},
"node_modules/postcss-nested": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.0.1.tgz",
@ -14068,7 +13961,8 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
"integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==",
"optional": true
"optional": true,
"peer": true
},
"node_modules/psl": {
"version": "1.9.0",
@ -15742,12 +15636,6 @@
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
"dev": true
},
"node_modules/reserved-words": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/reserved-words/-/reserved-words-0.1.2.tgz",
"integrity": "sha512-0S5SrIUJ9LfpbVl4Yzij6VipUdafHrOTzvmfazSw/jeZrZtQK303OPZW+obtkaw7jQlTQppy0UvZWm9872PbRw==",
"dev": true
},
"node_modules/resolve": {
"version": "1.22.6",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.6.tgz",
@ -16254,7 +16142,8 @@
"version": "1.68.0",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.68.0.tgz",
"integrity": "sha512-Lmj9lM/fef0nQswm1J2HJcEsBUba4wgNx2fea6yJHODREoMFnwRpZydBnX/RjyXw2REIwdkbqE4hrTo4qfDBUA==",
"devOptional": true,
"optional": true,
"peer": true,
"dependencies": {
"chokidar": ">=3.0.0 <4.0.0",
"immutable": "^4.0.0",
@ -17232,7 +17121,8 @@
"version": "0.59.0",
"resolved": "https://registry.npmjs.org/stylus/-/stylus-0.59.0.tgz",
"integrity": "sha512-lQ9w/XIOH5ZHVNuNbWW8D822r+/wBSO/d6XvtyHLF7LW4KaCIDeVbvn5DF8fGCJAUCwVhVi/h6J0NUcnylUEjg==",
"devOptional": true,
"optional": true,
"peer": true,
"dependencies": {
"@adobe/css-tools": "^4.0.1",
"debug": "^4.3.2",
@ -17254,7 +17144,8 @@
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
"devOptional": true,
"optional": true,
"peer": true,
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -17274,7 +17165,8 @@
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz",
"integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==",
"devOptional": true,
"optional": true,
"peer": true,
"engines": {
"node": ">= 8"
}
@ -17745,20 +17637,6 @@
}
}
},
"node_modules/tsconfig-paths": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz",
"integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==",
"dev": true,
"dependencies": {
"json5": "^2.2.2",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/tsconfig-resolver": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/tsconfig-resolver/-/tsconfig-resolver-3.0.1.tgz",
@ -17962,33 +17840,6 @@
"semver": "^7.3.8"
}
},
"node_modules/typescript-plugin-css-modules": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/typescript-plugin-css-modules/-/typescript-plugin-css-modules-5.0.1.tgz",
"integrity": "sha512-hKXObfwfjx2/myRq4JeQ8D3xIWYTFqusi0hS/Aka7RFX1xQEoEkdOGDWyXNb8LmObawsUzbI30gQnZvqYXCrkA==",
"dev": true,
"dependencies": {
"@types/postcss-modules-local-by-default": "^4.0.0",
"@types/postcss-modules-scope": "^3.0.1",
"dotenv": "^16.0.3",
"icss-utils": "^5.1.0",
"less": "^4.1.3",
"lodash.camelcase": "^4.3.0",
"postcss": "^8.4.21",
"postcss-load-config": "^3.1.4",
"postcss-modules-extract-imports": "^3.0.0",
"postcss-modules-local-by-default": "^4.0.0",
"postcss-modules-scope": "^3.0.0",
"reserved-words": "^0.1.2",
"sass": "^1.58.3",
"source-map-js": "^1.0.2",
"stylus": "^0.59.0",
"tsconfig-paths": "^4.1.2"
},
"peerDependencies": {
"typescript": ">=4.0.0"
}
},
"node_modules/uc.micro": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
@ -19793,15 +19644,6 @@
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="
},
"node_modules/yaml": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz",
"integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==",
"dev": true,
"engines": {
"node": ">= 6"
}
},
"node_modules/yargs": {
"version": "17.7.2",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",

View File

@ -12,7 +12,7 @@
"preview": "astro preview",
"typecheck:astro": "astro check",
"typecheck:tsc": "tsc --noEmit --pretty",
"typecheck": "astro sync && run-p typecheck:astro typecheck:tsc",
"typecheck": "npm run typecheck:astro && npm run typecheck:tsc",
"prebuild": "run-p --silent --continue-on-error create:symlinks create:icons move:downloads",
"test:unit": "vitest run --config './test/vitest.config.ts' --coverage",
"test:e2e": "playwright test --config './test/playwright.config.ts'",
@ -35,7 +35,7 @@
"@astrojs/react": "^3.0.2",
"@astrojs/rss": "^3.0.0",
"@astrojs/sitemap": "^3.0.0",
"@astrojs/ts-plugin": "^1.1.3",
"@nanostores/query": "^0.2.4",
"@nanostores/react": "^0.7.1",
"@rainbow-me/rainbowkit": "^1.0.11",
"astro": "3.2.2",
@ -95,7 +95,6 @@
"svgo": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"typescript-plugin-css-modules": "^5.0.1",
"unist-util-visit": "^5.0.0",
"vite-tsconfig-paths": "^4.2.1",
"vitest": "^0.34.6"

View File

@ -9,7 +9,7 @@ type Props = {
const { links } = Astro.props
---
<p>
<section class={styles.networks}>
{
links.map((link: string) => (
<a class={styles.link} href={link} title={link} rel="me">
@ -25,4 +25,4 @@ const { links } = Astro.props
</a>
))
}
</p>
</section>

View File

@ -1,3 +1,7 @@
.networks {
margin-top: calc(var(--spacer) / 2);
}
.link {
text-align: center;
width: 2rem;

View File

@ -1,6 +1,7 @@
---
import { Image } from 'astro:assets'
import Networks from './Networks.astro'
import Location from '../Location'
import avatar from '@images/avatar.jpg'
import config from '@config/blog.config'
import styles from './Vcard.module.css'
@ -19,10 +20,12 @@ const links = [mastodon, github, rss, jsonfeed]
/>
<p class={styles.description}>
{config.siteDescription.replace(name, '')}{' '}
{config.siteDescription.replace(name, '')}<br />
<a class="fn" rel="author" href={url}>
{name}
</a>
</p>
<Location client:visible />
<Networks links={links} />

View File

@ -9,10 +9,9 @@
.description {
font-size: var(--font-size-h5);
margin-top: 0;
margin-bottom: calc(var(--spacer) / var(--line-height));
margin: 0;
}
.description a {
display: block;
display: inline-block;
}

View File

@ -21,7 +21,7 @@ const { name, url, github } = config.author
<Github />
View source
</a>
<a href="/thanks/" class={styles.btc}>
<a href="/thanks/">
<Bitcoin />
Say Thanks
</a>

View File

@ -11,42 +11,31 @@
position: fixed;
width: 100%;
border: 0;
will-change: transform;
z-index: 0;
bottom: 0;
box-shadow: none;
}
}
.btc code {
font-size: 0.6rem;
background: none;
color: var(--link-color);
padding: 0;
.copyright {
margin-top: calc(var(--spacer) / var(--line-height));
font-size: var(--font-size-mini);
color: var(--text-color-light);
}
.copyright p {
margin-bottom: 0;
font-size: var(--font-size-mini);
}
.copyright a,
.copyright button code {
.copyright a {
color: var(--text-color-light);
}
.copyright a,
.copyright button {
margin-left: var(--spacer);
}
.copyright a:hover,
.copyright button code {
.copyright a:hover {
color: var(--link-color);
}
.copyright a:first-child,
.copyright button:first-child {
.copyright a:first-child {
margin-left: 0;
}

View File

@ -0,0 +1,23 @@
import styles from './index.module.css'
type Props = {
country: {
name: string
code: string
}
}
export function Flag({ country }: Props) {
// offset between uppercase ascii and regional indicator symbols
const OFFSET = 127397
const emoji = country?.code.replace(/./g, (char) =>
String.fromCodePoint(char.charCodeAt(0) + OFFSET)
)
return (
<span role="img" aria-label={country?.name} className={styles.emoji}>
{emoji}
</span>
)
}

View File

@ -0,0 +1,32 @@
import type { ReactElement } from 'react'
import { Flag } from './Flag'
type LocationProps = {
country: string
countryCode: string
city: string
time: string
showFlag?: boolean
}
export function LocationItem({
country,
countryCode,
city,
time,
showFlag = true
}: LocationProps): ReactElement<LocationProps> {
return (
<>
{showFlag && (
<Flag
country={{
code: countryCode,
name: country
}}
/>
)}
{city} <span>{time}</span>
</>
)
}

View File

@ -0,0 +1,41 @@
.location {
font-size: var(--font-size-mini);
min-height: 36px;
}
.location span {
font-style: italic;
}
.emoji {
display: inline-block;
font-size: 1em;
line-height: 1em;
vertical-align: 'middle';
margin-right: calc(var(--spacer) / 6);
}
.next {
display: inline-block;
margin-left: calc(var(--spacer) / 3);
}
.loading {
display: inline-block;
margin-left: calc(var(--spacer) / 3);
animation: flicker 0.3s linear infinite;
}
@keyframes flicker {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}

View File

@ -0,0 +1,94 @@
import {
describe,
it,
expect,
beforeAll,
afterAll,
vi,
type SpyInstance
} from 'vitest'
import { render, screen } from '@testing-library/react'
import * as nanostores from '@nanostores/react'
import Location from '.'
const mockData = {
now: {
country: 'USA',
country_code: 'US',
city: 'New York'
},
next: {
country: 'Canada',
country_code: 'CA',
city: 'Toronto',
date_start: '2023-10-05'
}
}
describe('Location component', () => {
let useStoreSpy: SpyInstance
beforeAll(() => {
vi.mock('@nanostores/react')
useStoreSpy = vi.spyOn(nanostores, 'useStore')
})
afterAll(() => {
vi.restoreAllMocks()
})
it('renders the location items correctly', () => {
useStoreSpy.mockImplementationOnce(() => ({
data: mockData,
loading: false,
error: null
}))
render(<Location />)
expect(screen.getByLabelText('USA')).toBeInTheDocument()
expect(screen.getByText('New York')).toBeInTheDocument()
expect(screen.getByLabelText('Canada')).toBeInTheDocument()
expect(screen.getByText('Toronto')).toBeInTheDocument()
})
it('renders the loading indicator', () => {
useStoreSpy.mockImplementationOnce(() => ({
data: null,
loading: true,
error: null
}))
render(<Location />)
expect(screen.getByText('...')).toBeInTheDocument()
})
it('renders empty when there is no data', () => {
useStoreSpy.mockImplementationOnce(() => ({
data: null,
loading: false,
error: null
}))
render(<Location />)
expect(screen.queryByLabelText('Location')).toBeEmptyDOMElement()
})
it('renders nothing and logs error when error is encountered', () => {
const consoleErrorSpy = vi.spyOn(console, 'error')
useStoreSpy.mockImplementationOnce(() => ({
data: null,
loading: false,
error: 'Error'
}))
render(<Location />)
expect(screen.queryByLabelText('Location')).not.toBeInTheDocument()
expect(consoleErrorSpy).toHaveBeenCalledWith(
'Failed to fetch location: Error'
)
})
})

View File

@ -0,0 +1,45 @@
import { useStore } from '@nanostores/react'
import { $location } from '@stores/location'
import { formatDistanceToNowStrict } from 'date-fns'
import { LocationItem } from './LocationItem'
import styles from './index.module.css'
export default function Location() {
const { data, loading, error } = useStore($location)
if (error) {
console.error(`Failed to fetch location: ${error}`)
return null
}
return (
<section aria-label="Location" className={styles.location}>
{loading && !data ? (
<span className={styles.loading}>...</span>
) : data?.now?.city ? (
<>
<LocationItem
country={data.now.country}
countryCode={data.now.country_code}
city={data.now.city}
time="now"
/>
<div className={styles.next}>
{data.next?.city && (
<LocationItem
country={data.next.country}
countryCode={data.next.country_code}
city={data.next.city}
time={formatDistanceToNowStrict(
new Date(data.next.date_start),
{ addSuffix: true }
)}
showFlag={data.now.country !== data.next.country}
/>
)}
</div>
</>
) : null}
</section>
)
}

View File

@ -1,5 +1,5 @@
---
import PostTitle from '../layouts/Post/Title.astro'
import PostTitle from '@layouts/Post/Title.astro'
import styles from './index.module.css'
import Picture from '@components/Picture/index.astro'
import type { CollectionEntry } from 'astro:content'

View File

@ -1,41 +0,0 @@
---
import styles from './PrevNext.module.css'
import { ChevronLeft, ChevronRight } from '@images/components'
interface Node {
title: string
slug: string
}
type Props = {
prev: Node
next: Node
}
const { prev, next } = Astro.props
---
<nav class={styles.prevnext}>
<div>
{
prev && (
<a href={prev.slug}>
<ChevronLeft />
<p class={styles.label}>Newer</p>
<h3 class={styles.title}>{prev.title}</h3>
</a>
)
}
</div>
<div>
{
next && (
<a href={next.slug}>
<p class={styles.label}>Older</p>
<h3 class={styles.title}>{next.title}</h3>
<ChevronRight />
</a>
)
}
</div>
</nav>

View File

@ -1,50 +0,0 @@
.prevnext {
margin-top: calc(var(--spacer) * 2);
padding-top: calc(var(--spacer) * 2);
display: grid;
gap: var(--spacer);
grid-template-columns: 1fr 1fr;
}
.prevnext svg {
stroke: var(--text-color-light);
margin-top: -0.05rem;
position: absolute;
left: 0.1rem;
top: calc(var(--spacer) * 1.1);
}
.prevnext > div {
position: relative;
}
.prevnext > div:first-child {
padding-left: var(--spacer);
}
.prevnext > div:last-child {
padding-right: var(--spacer);
text-align: right;
}
.prevnext > div:last-child svg {
right: 0.1rem;
left: auto;
}
.title {
font-size: var(--font-size-large);
margin: 0;
color: var(--brand-grey-light) !important;
}
a:hover .title {
color: var(--link-color) !important;
}
.label {
margin-bottom: calc(var(--spacer) / 4);
font-size: var(--font-size-small);
color: var(--text-color-light);
opacity: 0.65;
}

View File

@ -1,6 +1,6 @@
---
import '../../../styles/global.css'
import '../../../styles/imports.css'
import '../../styles/global.css'
import '../../styles/imports.css'
import type { ImageMetadata } from 'astro'
import type { CollectionEntry } from 'astro:content'

View File

@ -68,7 +68,5 @@ const { linkurl } = data as CollectionEntry<'links'>['data']
{collection !== 'photos' && <Actions githubLink={githubLink as string} />}
<RelatedPosts isPhotos={collection === 'photos'} post={Astro.props} />
{/* <PrevNext prev={prev} next={next} /> */}
</article>
</LayoutBase>

View File

@ -3,8 +3,6 @@ import LayoutPost from '@layouts/Post/index.astro'
import { getAllPosts } from '@lib/astro'
import type { InferGetStaticPropsType } from 'astro'
type Props = InferGetStaticPropsType<typeof getStaticPaths>
export async function getStaticPaths() {
const allPosts = await getAllPosts()
@ -19,6 +17,8 @@ export async function getStaticPaths() {
})
}
type Props = InferGetStaticPropsType<typeof getStaticPaths>
const { entry } = Astro.props
const { Content, remarkPluginFrontmatter } = await entry.render()
---

View File

@ -1,7 +1,7 @@
---
import { loadAndFormatCollection } from '@lib/astro'
import type { GetStaticPathsOptions, InferGetStaticPropsType } from 'astro'
import LayoutArchive from '@components/layouts/Archive.astro'
import LayoutArchive from '@layouts/Archive.astro'
import config from '@config/blog.config'
type Props = InferGetStaticPropsType<typeof getStaticPaths>

View File

@ -1,7 +1,7 @@
---
import type { GetStaticPathsOptions, InferGetStaticPropsType } from 'astro'
import { loadAndFormatCollection } from '@lib/astro'
import LayoutArchive from '@components/layouts/Archive.astro'
import LayoutArchive from '@layouts/Archive.astro'
import config from '@config/blog.config'
type Props = InferGetStaticPropsType<typeof getStaticPaths>

View File

@ -6,7 +6,7 @@ import type {
Page
} from 'astro'
import { getAllTags, getPostsByTag } from '@lib/astro'
import LayoutArchive from '@components/layouts/Archive.astro'
import LayoutArchive from '@layouts/Archive.astro'
type Props = InferGetStaticPropsType<typeof getStaticPaths> & {
page: Page<CollectionEntry<'photos'>>

View File

@ -1,7 +1,7 @@
---
import { getAllTags } from '@lib/astro'
import Tag from '@components/Tag.astro'
import LayoutBase from '@components/layouts/Base/index.astro'
import LayoutBase from '@layouts/Base/index.astro'
const allTags = await getAllTags()
---

6
src/stores/fetcher.ts Normal file
View File

@ -0,0 +1,6 @@
import { nanoquery } from '@nanostores/query'
export const [createFetcherStore, createMutatorStore] = nanoquery({
fetcher: (...keys: (string | number)[]) =>
fetch(keys.join('')).then((r) => r.json())
})

24
src/stores/location.ts Normal file
View File

@ -0,0 +1,24 @@
import { createFetcherStore } from './fetcher'
export type Location = {
country: string
city: string
country_code: string
date_start: string
date_end: string
}
export type LocationStore =
| {
now: Location
next: Location
previous: Location
}
| undefined
const url = 'https://location.kremalicious.com'
export const $location = createFetcherStore<LocationStore>([url], {
refetchOnReconnect: true,
refetchOnFocus: true
})

View File

@ -2,26 +2,21 @@
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"jsx": "react-jsx",
"plugins": [
{ "name": "typescript-plugin-css-modules" },
{ "name": "@astrojs/ts-plugin" }
],
"jsxImportSource": "react",
"baseUrl": ".",
"paths": {
"@config/*": [".config/*"],
"@components/*": ["src/components/*"],
"@layouts/*": ["src/components/layouts/*"],
"@layouts/*": ["src/layouts/*"],
"@images/*": ["src/images/*"],
"@lib/*": ["src/lib/*"],
"@hooks/*": ["src/hooks/*"],
"@stores/*": ["src/stores/*"],
"@content/*": ["content/*"],
"@test/*": ["test/*"]
},
"typeRoots": ["./src/@types", "./node_modules/@types"]
},
"exclude": ["node_modules", "dist", ".cache", "src/images/components"],
"exclude": ["src/images/components", "src/content"],
"include": [
"src/**/*",
"content/**/*",