Compare commits

...

3 Commits

9 changed files with 173 additions and 70 deletions

View File

@ -81,6 +81,7 @@
"luoli",
"luxon",
"mboker",
"microflash",
"minagi",
"miui",
"mmwebid",

View File

@ -2,7 +2,9 @@ import mdx from '@astrojs/mdx';
import zeabur from '@zeabur/astro-adapter/serverless';
import { uploader } from 'astro-uploader';
import { defineConfig, envField } from 'astro/config';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeExternalLinks from 'rehype-external-links';
import rehypeSlug from 'rehype-slug';
import options from './options';
import { astroImage } from './plugins/images';
@ -38,7 +40,11 @@ export default defineConfig({
integrations: [
mdx({
remarkPlugins: [astroImage],
rehypePlugins: [[rehypeExternalLinks, { rel: 'nofollow', target: '_blank' }]],
rehypePlugins: [
[rehypeExternalLinks, { rel: 'nofollow', target: '_blank' }],
rehypeSlug,
[rehypeAutolinkHeadings, { behavior: 'append', properties: {} }],
],
}),
uploader({
paths: ['images', 'og', 'cats'],

157
package-lock.json generated
View File

@ -28,7 +28,7 @@
"@napi-rs/canvas": "^0.1.56",
"@types/lodash": "^4.17.9",
"@types/luxon": "^3.4.2",
"@types/node": "^22.6.1",
"@types/node": "^22.7.2",
"@types/pg": "^8.11.10",
"@types/qrcode-svg": "^1.1.5",
"@types/unist": "^3.0.3",
@ -39,7 +39,9 @@
"prettier-plugin-astro": "^0.14.1",
"prettier-plugin-astro-organize-imports": "^0.4.9",
"prettier-plugin-organize-imports": "^4.1.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-external-links": "^3.0.0",
"rehype-slug": "^6.0.0",
"resize-sensor": "^0.0.6",
"rimraf": "^6.0.1",
"sharp": "^0.33.5",
@ -2290,44 +2292,44 @@
]
},
"node_modules/@shikijs/core": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.18.0.tgz",
"integrity": "sha512-VK4BNVCd2leY62Nm2JjyxtRLkyrZT/tv104O81eyaCjHq4Adceq2uJVFJJAIof6lT1mBwZrEo2qT/T+grv3MQQ==",
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.19.0.tgz",
"integrity": "sha512-314J5MPdS1wzfjuD856MXvbAI2wN03ofMnUGkZ5ZDBOza/d38paLwd+YVyuKrrjxJ4hfPMjc4tRmPkXd6UDMPQ==",
"license": "MIT",
"dependencies": {
"@shikijs/engine-javascript": "1.18.0",
"@shikijs/engine-oniguruma": "1.18.0",
"@shikijs/types": "1.18.0",
"@shikijs/engine-javascript": "1.19.0",
"@shikijs/engine-oniguruma": "1.19.0",
"@shikijs/types": "1.19.0",
"@shikijs/vscode-textmate": "^9.2.2",
"@types/hast": "^3.0.4",
"hast-util-to-html": "^9.0.3"
}
},
"node_modules/@shikijs/engine-javascript": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-1.18.0.tgz",
"integrity": "sha512-qoP/aO/ATNwYAUw1YMdaip/YVEstMZEgrwhePm83Ll9OeQPuxDZd48szZR8oSQNQBT8m8UlWxZv8EA3lFuyI5A==",
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-1.19.0.tgz",
"integrity": "sha512-D1sioU61n7fLWfDzTC9JNS19zEYZMr7qxkSVzv6ziEWDxnwzy2PvYoKPedJV4qUf+2VnrYPSaArDz2W0XgGB7A==",
"license": "MIT",
"dependencies": {
"@shikijs/types": "1.18.0",
"@shikijs/types": "1.19.0",
"@shikijs/vscode-textmate": "^9.2.2",
"oniguruma-to-js": "0.4.3"
}
},
"node_modules/@shikijs/engine-oniguruma": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.18.0.tgz",
"integrity": "sha512-B9u0ZKI/cud+TcmF8Chyh+R4V5qQVvyDOqXC2l2a4x73PBSBc6sZ0JRAX3eqyJswqir6ktwApUUGBYePdKnMJg==",
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.19.0.tgz",
"integrity": "sha512-/JxwIefNVLGB4EmpB8i6P4JB/oVYRuzSixbqvx7m6iPW0lQ1T97c/0wmA+JlKbngEiExckSuPwa48fajlShB7A==",
"license": "MIT",
"dependencies": {
"@shikijs/types": "1.18.0",
"@shikijs/types": "1.19.0",
"@shikijs/vscode-textmate": "^9.2.2"
}
},
"node_modules/@shikijs/types": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.18.0.tgz",
"integrity": "sha512-O9N36UEaGGrxv1yUrN2nye7gDLG5Uq0/c1LyfmxsvzNPqlHzWo9DI0A4+fhW2y3bGKuQu/fwS7EPdKJJCowcVA==",
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.19.0.tgz",
"integrity": "sha512-NZvVp3k1bP4MTRUbmnkGhYzPdoNMjNLSAwczMRUbtUl4oj2LlNRNbwERyeIyJt56Ac9fvPVZ2nn13OXk86E5UQ==",
"license": "MIT",
"dependencies": {
"@shikijs/vscode-textmate": "^9.2.2",
@ -2474,9 +2476,9 @@
}
},
"node_modules/@types/node": {
"version": "22.6.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.6.1.tgz",
"integrity": "sha512-V48tCfcKb/e6cVUigLAaJDAILdMP0fUW6BidkPK4GpGjXcfbnoHasCZDwz3N3yVt5we2RHm4XTQCpv0KJz9zqw==",
"version": "22.7.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.2.tgz",
"integrity": "sha512-866lXSrpGpgyHBZUa2m9YNWqHDjjM0aBTJlNtYaGEw4rqY/dcD7deRVTbBBAJelfA7oaGDbNftXF/TL/A6RgoA==",
"devOptional": true,
"license": "MIT",
"dependencies": {
@ -3257,9 +3259,9 @@
}
},
"node_modules/browserslist": {
"version": "4.23.3",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.3.tgz",
"integrity": "sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==",
"version": "4.24.0",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.0.tgz",
"integrity": "sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A==",
"funding": [
{
"type": "opencollective",
@ -3276,8 +3278,8 @@
],
"license": "MIT",
"dependencies": {
"caniuse-lite": "^1.0.30001646",
"electron-to-chromium": "^1.5.4",
"caniuse-lite": "^1.0.30001663",
"electron-to-chromium": "^1.5.28",
"node-releases": "^2.0.18",
"update-browserslist-db": "^1.1.0"
},
@ -3301,9 +3303,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001663",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001663.tgz",
"integrity": "sha512-o9C3X27GLKbLeTYZ6HBOLU1tsAcBZsLis28wrVzddShCS16RujjHp9GDHKZqrB3meE0YjhawvMFsGb/igqiPzA==",
"version": "1.0.30001664",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz",
"integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==",
"funding": [
{
"type": "opencollective",
@ -3828,9 +3830,9 @@
}
},
"node_modules/devalue": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/devalue/-/devalue-5.0.0.tgz",
"integrity": "sha512-gO+/OMXF7488D+u3ue+G7Y4AA3ZmUnB3eHJXmBTgNHvr4ZNzl36A0ZtG+XCRNYCkYx/bFmw4qtkoFLa+wSrwAA==",
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/devalue/-/devalue-5.1.1.tgz",
"integrity": "sha512-maua5KUiapvEwiEAe+XnlZ3Rh0GD+qI1J/nb9vrJc3muPXvcF/8gXYTWF76+5DAqHyDUtOIImEuo0YKE9mshVw==",
"license": "MIT"
},
"node_modules/devlop": {
@ -3998,9 +4000,9 @@
"license": "MIT"
},
"node_modules/electron-to-chromium": {
"version": "1.5.28",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.28.tgz",
"integrity": "sha512-VufdJl+rzaKZoYVUijN13QcXVF5dWPZANeFTLNy+OSpHdDL5ynXTF35+60RSBbaQYB1ae723lQXHCrf4pyLsMw==",
"version": "1.5.29",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.29.tgz",
"integrity": "sha512-PF8n2AlIhCKXQ+gTpiJi0VhcHDb69kYX4MtCiivctc2QD3XuNZ/XIOlbGzt7WAjjEev0TtaH6Cu3arZExm5DOw==",
"license": "ISC"
},
"node_modules/emmet": {
@ -4663,6 +4665,20 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-heading-rank": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/hast-util-heading-rank/-/hast-util-heading-rank-3.0.0.tgz",
"integrity": "sha512-EJKb8oMUXVHcWZTDepnr+WNbfnXKFNf9duMesmr4S8SXTJBJ9M4Yok08pu9vxdJwdlGRhVumk9mEhkEvKGifwA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-is-element": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-3.0.0.tgz",
@ -4826,6 +4842,20 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-to-string": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/hast-util-to-string/-/hast-util-to-string-3.0.0.tgz",
"integrity": "sha512-OGkAxX1Ua3cbcW6EJ5pT/tslVb90uViVkcJ4ZZIMW/R33DX/AkcJcRrPebPwJkHYwlDHXz4aIwvAAaAdtrACFA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-to-text": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-4.0.2.tgz",
@ -7556,6 +7586,25 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-autolink-headings": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/rehype-autolink-headings/-/rehype-autolink-headings-7.1.0.tgz",
"integrity": "sha512-rItO/pSdvnvsP4QRB1pmPiNHUskikqtPojZKJPPPAVx9Hj8i8TwMBhofrrAYRhYOOBZH9tgmG5lPqDLuIWPWmw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"@ungap/structured-clone": "^1.0.0",
"hast-util-heading-rank": "^3.0.0",
"hast-util-is-element": "^3.0.0",
"unified": "^11.0.0",
"unist-util-visit": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-external-links": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/rehype-external-links/-/rehype-external-links-3.0.0.tgz",
@ -7605,6 +7654,24 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-slug": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/rehype-slug/-/rehype-slug-6.0.0.tgz",
"integrity": "sha512-lWyvf/jwu+oS5+hL5eClVd3hNdmwM1kAC0BUvEGD19pajQMIzcNUd/k9GsfQ+FfECvX+JE+e9/btsKH0EjJT6A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"github-slugger": "^2.0.0",
"hast-util-heading-rank": "^3.0.0",
"hast-util-to-string": "^3.0.0",
"unist-util-visit": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-stringify": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-10.0.0.tgz",
@ -8181,15 +8248,15 @@
}
},
"node_modules/shiki": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-1.18.0.tgz",
"integrity": "sha512-8jo7tOXr96h9PBQmOHVrltnETn1honZZY76YA79MHheGQg55jBvbm9dtU+MI5pjC5NJCFuA6rvVTLVeSW5cE4A==",
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-1.19.0.tgz",
"integrity": "sha512-Ng7Gd6XgWFLsv4Z3so65hOyXjV78qz1M117MuZHwdPQD6fgb5wR2IoLMvSlM/Ml14EXH7n+/YxIpTD74i7kDdw==",
"license": "MIT",
"dependencies": {
"@shikijs/core": "1.18.0",
"@shikijs/engine-javascript": "1.18.0",
"@shikijs/engine-oniguruma": "1.18.0",
"@shikijs/types": "1.18.0",
"@shikijs/core": "1.19.0",
"@shikijs/engine-javascript": "1.19.0",
"@shikijs/engine-oniguruma": "1.19.0",
"@shikijs/types": "1.19.0",
"@shikijs/vscode-textmate": "^9.2.2",
"@types/hast": "^3.0.4"
}
@ -8869,9 +8936,9 @@
}
},
"node_modules/vite": {
"version": "5.4.7",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.7.tgz",
"integrity": "sha512-5l2zxqMEPVENgvzTuBpHer2awaetimj2BGkhBPdnwKbPNOlHsODU+oiazEZzLK7KhAnOrO+XGYJYn4ZlUhDtDQ==",
"version": "5.4.8",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.8.tgz",
"integrity": "sha512-FqrItQ4DT1NC4zCUqMB4c4AZORMKIa0m8/URVCZ77OZ/QSNeJ54bU1vrFADbDsuwfIPcgknRkmqakQcgnL4GiQ==",
"license": "MIT",
"dependencies": {
"esbuild": "^0.21.3",

View File

@ -61,7 +61,7 @@
"@napi-rs/canvas": "^0.1.56",
"@types/lodash": "^4.17.9",
"@types/luxon": "^3.4.2",
"@types/node": "^22.6.1",
"@types/node": "^22.7.2",
"@types/pg": "^8.11.10",
"@types/qrcode-svg": "^1.1.5",
"@types/unist": "^3.0.3",
@ -72,7 +72,9 @@
"prettier-plugin-astro": "^0.14.1",
"prettier-plugin-astro-organize-imports": "^0.4.9",
"prettier-plugin-organize-imports": "^4.1.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-external-links": "^3.0.0",
"rehype-slug": "^6.0.0",
"resize-sensor": "^0.0.6",
"rimraf": "^6.0.1",
"sharp": "^0.33.5",

View File

@ -242,14 +242,14 @@ if (typeof comments !== 'undefined' && comments !== null) {
}
const scrollIntoView = (elem) => {
let top = 0;
if (elem === undefined || elem === null) {
return;
}
const rect = elem.getBoundingClientRect();
const elemTop = rect.top + window.scrollY;
top = elemTop - (window.innerHeight / 2 - rect.height / 2);
const scrollOptions = {
top,
top: elemTop,
left: 0,
behavior: 'smooth',
};
@ -258,7 +258,7 @@ const scrollIntoView = (elem) => {
};
// Highlighting the selected comment.
const focusComment = () => {
const focusContent = () => {
if (location.hash.startsWith('#atk-comment-')) {
for (const li of document.querySelectorAll('.comment-body')) {
li.classList.remove('active');
@ -269,10 +269,25 @@ const focusComment = () => {
scrollIntoView(li);
li.querySelector('.comment-body').classList.add('active');
}
} else {
// Try to find the ID on heading
if (location.hash.startsWith('#')) {
scrollIntoView(document.getElementById(decodeURIComponent(location.hash).substring(1)));
}
}
};
window.addEventListener('hashchange', focusComment);
window.addEventListener('load', focusComment);
window.addEventListener('load', focusContent);
// TOC Support
for (const anchor of document.querySelectorAll('a[href^="#"]')) {
anchor.addEventListener('click', (e) => {
e.preventDefault();
const href = anchor.getAttribute('href');
location.hash = `${href}`;
scrollIntoView(document.querySelector(anchor.getAttribute('href')));
});
}
// Add like button for updating likes.
const likeButton = document.querySelector('button.post-like');

View File

@ -2427,6 +2427,26 @@ a:hover .overlay {
margin: 2rem 0 2rem;
}
.post-content h1 a,
.post-content h2 a,
.post-content h3 a,
.post-content h4 a,
.post-content h5 a,
.post-content h6 a {
margin-left: 0.8rem;
text-decoration: none;
color: var(--color-muted);
}
.post-content h1 a:hover,
.post-content h2 a:hover,
.post-content h3 a:hover,
.post-content h4 a:hover,
.post-content h5 a:hover,
.post-content h6 a:hover {
color: var(--color-primary);
}
.post-content h2 {
position: relative;
padding: 0 0 0 1.5rem;
@ -2511,12 +2531,6 @@ a:hover .overlay {
.post-content dd > a,
.post-content td a,
.post-content th a,
.post-content h1 a,
.post-content h2 a,
.post-content h3 a,
.post-content h4 a,
.post-content h5 a,
.post-content h6 a,
.post-content em a,
.post-content strong a {
-webkit-box-shadow: 0 -1px 0 0 var(--color-primary) inset;
@ -2531,12 +2545,6 @@ a:hover .overlay {
.post-content dd > a:hover,
.post-content td a:hover,
.post-content th a:hover,
.post-content h1 a:hover,
.post-content h2 a:hover,
.post-content h3 a:hover,
.post-content h4 a:hover,
.post-content h5 a:hover,
.post-content h6 a:hover,
.post-content em a:hover,
.post-content strong a:hover {
opacity: 1;

View File

@ -6,7 +6,8 @@
url('iconfont.ttf?t=1629473213677') format('truetype');
}
.iconfont {
.iconfont,
.icon {
font-family: 'iconfont' !important;
font-style: normal;
-webkit-font-smoothing: antialiased;

View File

@ -20,7 +20,7 @@ const image = (fallbackImage: string) =>
.string()
.optional()
.default(fallbackImage)
.transform(async (arg) => await imageMetadata(arg));
.transform((file) => imageMetadata(file));
// Categories Collection
const categoriesCollection = defineCollection({

View File

@ -10,7 +10,10 @@ const postsCollection = await getCollection('posts');
const tagsCollection = await getCollection('tags');
// Redefine the types from the astro content.
export type Category = (typeof categoriesCollection)[number]['data'] & { counts: number; permalink: string };
export type Category = (typeof categoriesCollection)[number]['data'] & {
counts: number;
permalink: string;
};
export type Friend = (typeof friendsCollection)[number]['data'][number];
export type Page = (typeof pagesCollection)[number]['data'] & {
slug: string;
@ -59,7 +62,7 @@ export const posts: Post[] = postsCollection
const b = right.date.getTime();
return options.settings.post.sort === 'asc' ? a - b : b - a;
});
export const categories: Category[] = categoriesCollection.map((cat) => ({
export const categories: Category[] = categoriesCollection.map(async (cat) => ({
counts: posts.filter((post) => post.category === cat.data.name).length,
permalink: `/cats/${cat.data.slug}`,
...cat.data,