Compare commits
42 Commits
4e56bc0d38
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
bb347dab3b
|
|||
|
5e5f13a949
|
|||
|
cd689aba98
|
|||
|
2de3841f7d
|
|||
|
ee3585586d
|
|||
|
6c525bcf98
|
|||
|
7a3059f486
|
|||
|
1b8bd19370
|
|||
|
ca1cf10aa8
|
|||
|
880afe34ab
|
|||
|
c3973e779a
|
|||
|
d605131bda
|
|||
|
2a71d714e8
|
|||
|
a47a537a64
|
|||
|
e36492a692
|
|||
|
9c019351a3
|
|||
|
5e53a213e6
|
|||
|
29b3c89c40
|
|||
|
43a85ac056
|
|||
|
3d0eeb7996
|
|||
|
e466006f81
|
|||
|
12e66a644e
|
|||
|
404c315657
|
|||
|
ac984b320f
|
|||
|
c5c25b6617
|
|||
|
d8fb7fd63f
|
|||
|
428be3170e
|
|||
|
b833065baf
|
|||
|
00218a17ba
|
|||
|
fc73828155
|
|||
|
d06e525385
|
|||
|
b1e1f05886
|
|||
|
14c30a2a30
|
|||
|
8fa4ed1b0d
|
|||
|
4c60081298
|
|||
|
aa33703b8b
|
|||
|
b3e3f48bdb
|
|||
|
3afbc518a5
|
|||
|
7b732de549
|
|||
|
b32c5bc6e9
|
|||
|
c6bc10d6cd
|
|||
|
605d53d590
|
1
.husky/pre-commit
Normal file
1
.husky/pre-commit
Normal file
@ -0,0 +1 @@
|
||||
npx lint-staged
|
||||
@ -1,5 +1,5 @@
|
||||
// @ts-check
|
||||
import { defineConfig } from 'astro/config'
|
||||
import { defineConfig, envField } from 'astro/config'
|
||||
|
||||
import node from '@astrojs/node'
|
||||
import svelte from '@astrojs/svelte'
|
||||
@ -7,12 +7,42 @@ import vue from '@astrojs/vue'
|
||||
import react from '@astrojs/react'
|
||||
import icon from 'astro-icon'
|
||||
|
||||
const ICON2_URL =
|
||||
'https://cdn.passthem.top/sharex/2026/03/%E6%93%A6%E6%B1%97%E5%90%8E_%E6%96%B9%E5%BD%A2.png.upscale.png'
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: node({
|
||||
mode: 'standalone',
|
||||
}),
|
||||
|
||||
integrations: [svelte(), vue(), react(), icon()],
|
||||
site: 'https://passthem.top',
|
||||
redirects: {
|
||||
'/assets/icon-qq-BThBBmjV.jpg': ICON2_URL,
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
external: ['node:crypto', 'buffer', 'keyv'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// 环境变量管理
|
||||
env: {
|
||||
schema: {
|
||||
LEGACY_BACKEND_URL_SSR: envField.string({
|
||||
context: 'server',
|
||||
access: 'secret',
|
||||
default: 'https://legacy.passthem.top/api',
|
||||
}),
|
||||
REDIS_URL: envField.string({
|
||||
context: 'server',
|
||||
access: 'secret',
|
||||
default: '',
|
||||
}),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
43
eslint.config.mjs
Normal file
43
eslint.config.mjs
Normal file
@ -0,0 +1,43 @@
|
||||
import eslintPluginAstro from 'eslint-plugin-astro'
|
||||
import tseslint from '@typescript-eslint/eslint-plugin'
|
||||
import tsparser from '@typescript-eslint/parser'
|
||||
import svelteParser from 'svelte-eslint-parser'
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: ['dist/**', 'node_modules/**', '.astro/**'],
|
||||
plugins: {
|
||||
astro: eslintPluginAstro,
|
||||
'@typescript-eslint': tseslint,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: tsparser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
...eslintPluginAstro.configs.recommended.rules,
|
||||
...tseslint.configs.recommended.rules,
|
||||
'no-console': 'warn',
|
||||
'no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'warn',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.svelte'],
|
||||
languageOptions: {
|
||||
parser: svelteParser,
|
||||
parserOptions: {
|
||||
parser: tsparser,
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
},
|
||||
},
|
||||
]
|
||||
867
package-lock.json
generated
867
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@ -9,7 +9,20 @@
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"astro": "astro"
|
||||
"astro": "astro",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"format": "prettier --write .",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,ts,jsx,tsx,svelte,vue}": [
|
||||
"eslint --fix",
|
||||
"prettier --write"
|
||||
],
|
||||
"*.{astro,css,md,mdx,json}": [
|
||||
"prettier --write"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/node": "^10.0.4",
|
||||
@ -17,16 +30,20 @@
|
||||
"@astrojs/rss": "^4.0.18",
|
||||
"@astrojs/svelte": "^8.0.4",
|
||||
"@astrojs/vue": "^6.0.1",
|
||||
"@iconify-json/material-symbols": "^1.2.65",
|
||||
"@iconify-json/mdi": "^1.2.3",
|
||||
"@keyv/redis": "^5.1.6",
|
||||
"@markdoc/markdoc": "^0.5.7",
|
||||
"@traptitech/markdown-it-katex": "^3.6.0",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@unocss/reset": "^66.6.7",
|
||||
"artalk": "^2.9.1",
|
||||
"astro": "^6.1.0",
|
||||
"astro-icon": "^1.1.5",
|
||||
"axios": "^1.13.6",
|
||||
"katex": "^0.16.43",
|
||||
"keyv": "^5.6.0",
|
||||
"markdown-it": "^14.1.1",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4",
|
||||
@ -37,10 +54,16 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
||||
"@typescript-eslint/parser": "^8.57.2",
|
||||
"eslint": "^10.1.0",
|
||||
"eslint-plugin-astro": "^1.6.0",
|
||||
"eslint-plugin-vue": "^10.8.0",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^16.4.0",
|
||||
"prettier": "^3.8.1",
|
||||
"prettier-plugin-astro": "^0.14.1"
|
||||
"prettier-plugin-astro": "^0.14.1",
|
||||
"prettier-plugin-svelte": "^3.5.1",
|
||||
"svelte-eslint-parser": "^1.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ const config = {
|
||||
tabWidth: 2,
|
||||
semi: false,
|
||||
singleQuote: true,
|
||||
plugins: ['prettier-plugin-astro'],
|
||||
plugins: ['prettier-plugin-astro', 'prettier-plugin-svelte'],
|
||||
overrides: [
|
||||
{
|
||||
files: '*.astro',
|
||||
@ -17,6 +17,12 @@ const config = {
|
||||
parser: 'astro',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: '*.css',
|
||||
options: {
|
||||
tabWidth: 4,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
47
scripts/generate_contact.py
Normal file
47
scripts/generate_contact.py
Normal file
@ -0,0 +1,47 @@
|
||||
import base64
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
raw_contact: list[dict[str, str]] = [
|
||||
{
|
||||
"platform": "Github",
|
||||
"href": "https://github.com/passthem-desu",
|
||||
"name": "passthem-desu",
|
||||
},
|
||||
{
|
||||
"platform": "Wakatime",
|
||||
"href": "https://wakatime.com/@passthem",
|
||||
"name": "@passthem",
|
||||
},
|
||||
{
|
||||
"platform": "Youtube",
|
||||
"href": "https://www.youtube.com/@Passthem183",
|
||||
"name": "@Passthem183",
|
||||
},
|
||||
{
|
||||
"platform": "OtoSite",
|
||||
"href": "https://otomad.site/@passthem",
|
||||
"name": "@passthem",
|
||||
},
|
||||
{
|
||||
"platform": "Email",
|
||||
"href": "mailto:passthem183@gmail.com",
|
||||
"name": "passthem183@gmail.com",
|
||||
},
|
||||
{
|
||||
"platform": "Bilibili",
|
||||
"href": "https://space.bilibili.com/92852604",
|
||||
"name": "passthem",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def hack(raw: str) -> str:
|
||||
return base64.b64encode(raw[::-1].encode()).decode()
|
||||
|
||||
|
||||
hacked_contact = [{k: hack(v) for k, v in c.items()} for c in raw_contact]
|
||||
(Path(__file__).parent / "../src/lib/data").mkdir(exist_ok=True)
|
||||
_ = (Path(__file__).parent / "../src/lib/data/contact.json").write_text(
|
||||
json.dumps(hacked_contact)
|
||||
)
|
||||
BIN
src/assets/blogs-header.webp
Normal file
BIN
src/assets/blogs-header.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
@ -1,6 +1,7 @@
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Bold.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Bold.woff2')
|
||||
format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@ -8,7 +9,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-BoldItalic.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-BoldItalic.woff2')
|
||||
format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@ -16,7 +18,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ExtraBold.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ExtraBold.woff2')
|
||||
format('woff2');
|
||||
font-weight: 800;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@ -24,7 +27,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ExtraBoldItalic.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ExtraBoldItalic.woff2')
|
||||
format('woff2');
|
||||
font-weight: 800;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@ -32,7 +36,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ExtraLight.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ExtraLight.woff2')
|
||||
format('woff2');
|
||||
font-weight: 200;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@ -40,7 +45,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ExtraLightItalic.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ExtraLightItalic.woff2')
|
||||
format('woff2');
|
||||
font-weight: 200;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@ -48,7 +54,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Italic.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Italic.woff2')
|
||||
format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@ -56,7 +63,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Light.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Light.woff2')
|
||||
format('woff2');
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@ -64,7 +72,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-LightItalic.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-LightItalic.woff2')
|
||||
format('woff2');
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@ -72,7 +81,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Medium.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Medium.woff2')
|
||||
format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@ -80,7 +90,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-MediumItalic.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-MediumItalic.woff2')
|
||||
format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@ -88,7 +99,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Regular.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Regular.woff2')
|
||||
format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@ -96,7 +108,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-SemiBold.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-SemiBold.woff2')
|
||||
format('woff2');
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@ -104,7 +117,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-SemiBoldItalic.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-SemiBoldItalic.woff2')
|
||||
format('woff2');
|
||||
font-weight: 600;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@ -112,7 +126,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Thin.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-Thin.woff2')
|
||||
format('woff2');
|
||||
font-weight: 100;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@ -120,19 +135,23 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'Maple Mono';
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ThinItalic.woff2') format('woff2');
|
||||
src: url('https://cdn.passthem.top/fonts/MapleMonoNormal-NF-CN-ThinItalic.woff2')
|
||||
format('woff2');
|
||||
font-weight: 100;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "ZLabsRoundPix 16px M CN";
|
||||
src: url('https://cdn.passthem.top/fonts/ZLabsRoundPix_16px_M_CN.ttf.woff2') format('woff2');
|
||||
font-family: 'ZLabsRoundPix 16px M CN';
|
||||
src: url('https://cdn.passthem.top/fonts/ZLabsRoundPix_16px_M_CN.ttf.woff2')
|
||||
format('woff2');
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
:root {
|
||||
--font-mono: 'Maple Mono NF CN', 'Maple Mono', monospace, var(--font-sans);
|
||||
--font-sans: 'HarmonyOS Sans SC', 'Source Han Sans SC', 'Noto Sans CJK SC', sans-serif;
|
||||
--font-sans:
|
||||
'HarmonyOS Sans SC', 'Source Han Sans SC', 'Noto Sans CJK SC',
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
BIN
src/assets/mainpage_avatars/ice.png
Executable file
BIN
src/assets/mainpage_avatars/ice.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 MiB |
BIN
src/assets/mainpage_avatars/mnk.jpg
Executable file
BIN
src/assets/mainpage_avatars/mnk.jpg
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
BIN
src/assets/mainpage_avatars/passthem.png
Normal file
BIN
src/assets/mainpage_avatars/passthem.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 675 KiB |
94
src/assets/prose.css
Normal file
94
src/assets/prose.css
Normal file
@ -0,0 +1,94 @@
|
||||
.prose {
|
||||
& p,
|
||||
& h1,
|
||||
& h2,
|
||||
& h3,
|
||||
& h4,
|
||||
& h5,
|
||||
& h6 {
|
||||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
& p {
|
||||
margin-block: 0.6em;
|
||||
}
|
||||
|
||||
& h1,
|
||||
& h2,
|
||||
& h3,
|
||||
& h4,
|
||||
& h5,
|
||||
& h6 {
|
||||
font-weight: 700;
|
||||
margin-block: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
& h1 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
& h2 {
|
||||
font-size: 1.8rem;
|
||||
}
|
||||
|
||||
& h3 {
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
|
||||
& h4 {
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
& h5 {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
& h6 {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
& blockquote {
|
||||
background-color: var(--color-bg-1);
|
||||
color: var(--color-fg-1);
|
||||
|
||||
border-radius: 0.5rem;
|
||||
padding-block: 0.5rem;
|
||||
padding-inline: 1.25rem;
|
||||
margin-block: 1.25rem;
|
||||
|
||||
border-inline-start: solid 0.25rem;
|
||||
}
|
||||
|
||||
& pre.shiki {
|
||||
border-radius: 0.5rem;
|
||||
padding-block: 1rem;
|
||||
padding-inline: 1.25rem;
|
||||
margin-block: 1.25rem;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
& a {
|
||||
color: var(--color-blue);
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
& img {
|
||||
border-radius: 0.5rem;
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
& p > code {
|
||||
background-color: var(--color-bg-1);
|
||||
padding: 0.25rem;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
& pre,
|
||||
& code {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
}
|
||||
@ -7,14 +7,23 @@
|
||||
:root {
|
||||
color-scheme: light dark;
|
||||
|
||||
--color-bg-n: light-dark(oklch(100% 0 0), oklch(35% 0.02 270));
|
||||
--color-bg-0: light-dark(oklch(95% 0 0), oklch(30% 0.02 270));
|
||||
--color-bg-n: light-dark(oklch(100% 0 0), oklch(30% 0.025 270));
|
||||
--color-bg-0: light-dark(oklch(95% 0 0), oklch(25% 0.02 270));
|
||||
--color-bg-1: light-dark(oklch(90% 0 0), oklch(20% 0.02 270));
|
||||
--color-bg-2: light-dark(oklch(85% 0 0), oklch(15% 0.02 270));
|
||||
|
||||
--color-fg-0: light-dark(oklch(25% 0.02 270), oklch(90% 0.02 270));
|
||||
--color-bg-1: light-dark(oklch(90% 0 0), oklch(25% 0.02 270));
|
||||
--color-fg-1: light-dark(oklch(35% 0.02 270), oklch(80% 0.02 270));
|
||||
|
||||
--color-blue: light-dark(oklch(40% 0.2 270), oklch(80% 0.2 270));
|
||||
--color-green: light-dark(oklch(50% 0.1 150), oklch(80% 0.15 150));
|
||||
--color-link: var(--color-blue);
|
||||
|
||||
--size-nav: 3rem;
|
||||
|
||||
@media (width < 768px) {
|
||||
--size-nav: 4rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* == 页面设置 == */
|
||||
@ -31,12 +40,14 @@ body {
|
||||
color: var(--color-fg-0);
|
||||
|
||||
font-family: var(--font-sans);
|
||||
|
||||
/* writing-mode: vertical-rl; */
|
||||
}
|
||||
|
||||
/* == 配置默认字体 == */
|
||||
code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: .9rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* == 支持 Shiki 的高亮 == */
|
||||
|
||||
30
src/components/Artalk.svelte
Normal file
30
src/components/Artalk.svelte
Normal file
@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
// https://artalk.js.org/zh/develop/import-framework
|
||||
|
||||
import Artalk from 'artalk'
|
||||
import { onMount, onDestroy } from 'svelte'
|
||||
|
||||
import 'artalk/Artalk.css'
|
||||
|
||||
let el: HTMLElement
|
||||
let artalk: Artalk
|
||||
|
||||
onMount(() => {
|
||||
artalk = Artalk.init({
|
||||
el: el,
|
||||
pageKey: location.pathname,
|
||||
pageTitle: document.title,
|
||||
server: 'https://artalk.sv.passthem.top',
|
||||
site: '小帕的小窝',
|
||||
darkMode: 'auto',
|
||||
})
|
||||
|
||||
onDestroy(() => {
|
||||
if (artalk) {
|
||||
artalk.destroy()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="comment" bind:this={el}></div>
|
||||
165
src/components/BlogCard.astro
Normal file
165
src/components/BlogCard.astro
Normal file
@ -0,0 +1,165 @@
|
||||
---
|
||||
import { Image } from 'astro:assets'
|
||||
import { Icon } from 'astro-icon/components'
|
||||
|
||||
interface Props {
|
||||
link: string
|
||||
title: string
|
||||
featureImage?: string
|
||||
createdAt?: Date
|
||||
updatedAt?: Date
|
||||
author?: {
|
||||
name: string
|
||||
avatar?: string
|
||||
}
|
||||
}
|
||||
|
||||
const { link, title, featureImage, author, createdAt, updatedAt } = Astro.props
|
||||
|
||||
const formatDate = (date: Date) =>
|
||||
`${date.getFullYear()} 年 ${date.getMonth() + 1} 月 ${date.getDate()} 日`
|
||||
---
|
||||
|
||||
<a class="card" href={link}>
|
||||
{
|
||||
featureImage && (
|
||||
<Image
|
||||
class="image"
|
||||
src={featureImage}
|
||||
width={640}
|
||||
height={360}
|
||||
densities={[1.5, 2]}
|
||||
alt="博文的头图"
|
||||
/>
|
||||
)
|
||||
}
|
||||
<div class="info">
|
||||
<h1 class="title">{title}</h1>
|
||||
{
|
||||
author && (
|
||||
<div class="author">
|
||||
<Image
|
||||
class="image"
|
||||
src={author.avatar ?? ''}
|
||||
alt={`用户 ${author.name} 的头像`}
|
||||
width={24}
|
||||
height={24}
|
||||
densities={[1.5, 2]}
|
||||
/>
|
||||
<span class="content">{author.name}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
createdAt && (
|
||||
<div class="iconinfo">
|
||||
<Icon class="icon" name="material-symbols:calendar-add-on-rounded" />
|
||||
<span class="content">{formatDate(createdAt)}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
updatedAt &&
|
||||
(!createdAt || formatDate(createdAt) != formatDate(updatedAt)) && (
|
||||
<div class="iconinfo">
|
||||
<Icon class="icon" name="material-symbols:calendar-check-rounded" />
|
||||
<span class="content">{formatDate(updatedAt)}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
--icon-size: 24px;
|
||||
|
||||
background-color: var(--color-bg-n);
|
||||
|
||||
margin: 1rem;
|
||||
padding-inline: 1rem;
|
||||
padding-block: 1.25rem;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
/* gap: 0.75rem; */
|
||||
border-radius: 2rem;
|
||||
transition: all cubic-bezier(0.4, 1, 0.4, 1) 0.3s;
|
||||
|
||||
@media (width >= 768px) {
|
||||
flex-direction: row;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
outline: solid 0px transparent;
|
||||
&:hover {
|
||||
outline-offset: 4px;
|
||||
outline: solid 4px var(--color-blue);
|
||||
}
|
||||
|
||||
&:has(> .image) {
|
||||
padding-block-start: 1rem;
|
||||
@media (width >= 768px) {
|
||||
padding-block-end: 1rem;
|
||||
}
|
||||
|
||||
& > .image {
|
||||
border-radius: 1rem;
|
||||
aspect-ratio: 16 / 9;
|
||||
object-fit: cover;
|
||||
margin-block-end: 0.75rem;
|
||||
|
||||
@media (width >= 768px) {
|
||||
width: 300px;
|
||||
margin-block-end: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
& > .info {
|
||||
& > h1 {
|
||||
margin-inline: 0.5rem;
|
||||
font-size: larger;
|
||||
font-weight: 600;
|
||||
margin-block-start: 0.25rem;
|
||||
margin-block-end: 0.75rem;
|
||||
|
||||
@media (width < 768px) {
|
||||
margin-inline: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
& > .author,
|
||||
& > .iconinfo {
|
||||
margin-inline: 0.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-block: 0.1rem;
|
||||
|
||||
& > .image {
|
||||
aspect-ratio: 1;
|
||||
object-fit: cover;
|
||||
width: var(--icon-size);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
& > .icon {
|
||||
width: var(--icon-size);
|
||||
height: var(--icon-size);
|
||||
padding: 2px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
& > .content {
|
||||
opacity: 0.5;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
}
|
||||
|
||||
& > .author {
|
||||
margin-block: 0.25rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -2,13 +2,15 @@
|
||||
// 不想写得屎长屎长,所以就用单独的文件写了
|
||||
|
||||
import { Image } from 'astro:assets'
|
||||
import IceAvatar from '../assets/mainpage_avatars/ice.png'
|
||||
import MnkAvatar from '../assets/mainpage_avatars/mnk.jpg'
|
||||
---
|
||||
|
||||
<div class="comments">
|
||||
{
|
||||
[
|
||||
[
|
||||
'https://legacy.passthem.top/assets/ice-BN4Z25mt.jpg',
|
||||
IceAvatar,
|
||||
'超几何冰精',
|
||||
'⑨',
|
||||
<>
|
||||
@ -45,7 +47,7 @@ import { Image } from 'astro:assets'
|
||||
<p>帕,移动</p>,
|
||||
],
|
||||
[
|
||||
'https://legacy.passthem.top/assets/mono-BkJO6fUP.webp',
|
||||
MnkAvatar,
|
||||
'モノクロ子',
|
||||
'全て変えるのなら黒にする。',
|
||||
<>
|
||||
@ -92,6 +94,7 @@ import { Image } from 'astro:assets'
|
||||
src={elements[0] as string}
|
||||
width={48}
|
||||
height={48}
|
||||
densities={[1.5, 2]}
|
||||
alt={`${elements[1]} 的头像`}
|
||||
/>
|
||||
<div class="userinfo">
|
||||
|
||||
98
src/components/MainpageContactMe.svelte
Normal file
98
src/components/MainpageContactMe.svelte
Normal file
@ -0,0 +1,98 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte'
|
||||
import _data from '../lib/data/contact.json'
|
||||
|
||||
/**
|
||||
* 为什么要一个独立的 Contact 组件呢...?这就不得不提到,现在可是有网络爬虫的
|
||||
* 时代!我们得给我们的个人信息做反爬呀!
|
||||
*
|
||||
* 另见:https://spencermortensen.com/articles/email-obfuscation/
|
||||
*/
|
||||
|
||||
let data = $state<{ platform: string; name: string; href: string }[]>([])
|
||||
|
||||
function unhack(raw: string) {
|
||||
return atob(raw).split('').reverse().join('')
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
data = _data
|
||||
})
|
||||
</script>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
{#each data as item}
|
||||
<tr>
|
||||
<td>{unhack(item.platform)}</td>
|
||||
<td><a href={unhack(item.href)}>{unhack(item.name)}</a></td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<style>
|
||||
table {
|
||||
font-family: var(--font-mono);
|
||||
|
||||
& tr {
|
||||
text-align: left;
|
||||
display: grid;
|
||||
grid-template-columns: 6em 16em;
|
||||
gap: 1em;
|
||||
line-height: 2em;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
grid-template-columns: 18em;
|
||||
gap: 0;
|
||||
line-height: 1.8em;
|
||||
margin-block: 1em;
|
||||
}
|
||||
|
||||
& td:nth-child(1) {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
justify-content: left;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: ':';
|
||||
}
|
||||
}
|
||||
|
||||
& td:nth-child(2) {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
justify-content: end;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '[';
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: ']';
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&:has(a:focus) {
|
||||
background-color: var(--color-fg-0);
|
||||
color: var(--color-bg-0);
|
||||
}
|
||||
|
||||
& > a {
|
||||
text-align: center;
|
||||
margin-inline: 1em;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -81,6 +81,13 @@
|
||||
'钻研手工开发',
|
||||
],
|
||||
},
|
||||
{
|
||||
stages: [
|
||||
{ text: '', editing: ['b', 'bw', "bw'v", "bw'vj"] },
|
||||
{ text: '备战', editing: ['k', 'kc', "kc'y", "kc'yj"] },
|
||||
'备战考研',
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
// 状态机定义
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import Markdoc, { type RenderableTreeNode } from '@markdoc/markdoc'
|
||||
import { toMarkdocTree } from '../lib/markdoc'
|
||||
import { renderMarkdocTree } from '../lib/markdoc'
|
||||
import { CodeBlock } from './markdoc/CodeBlock.tsx'
|
||||
|
||||
export const MarkdocContent: React.FC<{
|
||||
@ -11,7 +11,7 @@ export const MarkdocContent: React.FC<{
|
||||
|
||||
useEffect(() => {
|
||||
let active = true
|
||||
toMarkdocTree(content).then((result) => {
|
||||
renderMarkdocTree(content).then((result) => {
|
||||
if (active) setTree(result)
|
||||
})
|
||||
return () => {
|
||||
@ -28,7 +28,7 @@ export const MarkdocTreeRender: React.FC<{
|
||||
tree: RenderableTreeNode
|
||||
}> = ({ tree }) => {
|
||||
return (
|
||||
<div className="markdoc-container">
|
||||
<div className="markdoc-container prose">
|
||||
{Markdoc.renderers.react(tree, React, { components: { CodeBlock } })}
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
---
|
||||
import '../assets/style.css'
|
||||
import '../assets/fonts.css'
|
||||
import '../assets/prose.css'
|
||||
import 'katex/dist/katex.min.css'
|
||||
import '@unocss/reset/tailwind-v4.css'
|
||||
import { ClientRouter } from 'astro:transitions'
|
||||
|
||||
@ -35,6 +35,10 @@ const { title = '小帕的小窝' } = Astro.props
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
& :global(p) {
|
||||
margin-block: 0.25rem;
|
||||
}
|
||||
|
||||
& :global(a) {
|
||||
color: var(--color-link);
|
||||
text-decoration: none;
|
||||
|
||||
@ -4,23 +4,31 @@ import { Icon } from 'astro-icon/components'
|
||||
|
||||
interface Props {
|
||||
title?: string
|
||||
withGap?: boolean
|
||||
}
|
||||
|
||||
const { title = '小帕的小窝' } = Astro.props
|
||||
const { title = '小帕的小窝', withGap = false } = Astro.props
|
||||
---
|
||||
|
||||
<BaseLayout title={title}>
|
||||
<div class="nav-container" transition:persist>
|
||||
<div class="nav-mobile" aria-hidden="true" transition:persist>
|
||||
<button
|
||||
id="nav-mobile-button"
|
||||
onclick="document.getElementById('nav-main').classList.remove('nav-container-hidden')"
|
||||
><Icon name="mdi:menu-close" /></button
|
||||
>
|
||||
<a href="/">小帕的小窝</a>
|
||||
</div>
|
||||
<div
|
||||
id="nav-main"
|
||||
class="nav-container nav-container-hidden"
|
||||
transition:persist
|
||||
>
|
||||
<nav>
|
||||
<ul class="left">
|
||||
<li class="website-logo">
|
||||
<a href="/">小帕的小窝</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://legacy.passthem.top"
|
||||
><Icon name="mdi:history" /> 旧博客系统*</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/blogs"><Icon name="mdi:invoice-text-outline" />文章</a>
|
||||
</li>
|
||||
@ -30,53 +38,179 @@ const { title = '小帕的小窝' } = Astro.props
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="right">Hello!</ul>
|
||||
<ul class="right">
|
||||
<li>
|
||||
<a href="https://legacy.passthem.top"
|
||||
><Icon name="mdi:history" /> 旧博客系统*</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/rss.xml">
|
||||
<Icon name="material-symbols:rss-feed" /> 博客 RSS
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<main transition:animate="slide">
|
||||
<div
|
||||
class="loading-indicator hidden"
|
||||
id="loading-indicator"
|
||||
aria-hidden="true"
|
||||
transition:persist
|
||||
>
|
||||
</div>
|
||||
<main>
|
||||
{withGap && <div aria-hidden="true" class="layout-gap" />}
|
||||
<slot />
|
||||
</main>
|
||||
</BaseLayout>
|
||||
|
||||
<script>
|
||||
const navClose = () => {
|
||||
const navMain = document.getElementById('nav-main')
|
||||
navMain?.classList.add('nav-container-hidden')
|
||||
}
|
||||
|
||||
const navOpen = () => {
|
||||
const navMain = document.getElementById('nav-main')
|
||||
navMain?.classList.remove('nav-container-hidden')
|
||||
}
|
||||
|
||||
document.getElementById('nav-main')?.addEventListener('click', (e) => {
|
||||
const target = e.target as HTMLElement
|
||||
if (target.id == 'nav-main') {
|
||||
document.getElementById('nav-main')?.classList.add('nav-container-hidden')
|
||||
}
|
||||
})
|
||||
|
||||
document.getElementById('nav-main')?.addEventListener('focusin', navOpen)
|
||||
document.getElementById('nav-main')?.addEventListener('focusout', (e) => {
|
||||
if (
|
||||
e.relatedTarget &&
|
||||
!document
|
||||
.getElementById('nav-main')
|
||||
?.contains(e.relatedTarget as HTMLElement)
|
||||
) {
|
||||
navClose()
|
||||
}
|
||||
})
|
||||
|
||||
document.addEventListener('astro:before-preparation', () => {
|
||||
document.getElementById('loading-indicator')?.classList.remove('hidden')
|
||||
})
|
||||
|
||||
document.addEventListener('astro:after-swap', () => {
|
||||
requestAnimationFrame(navClose)
|
||||
document.getElementById('loading-indicator')?.classList.add('hidden')
|
||||
})
|
||||
|
||||
document.addEventListener('astro:page-load', () => {
|
||||
document.querySelectorAll('#nav-main li:has(a)').forEach((li) => {
|
||||
const child = li.querySelector('a')
|
||||
if (!child) {
|
||||
li.classList.add('url-here')
|
||||
return
|
||||
}
|
||||
if (
|
||||
window.location.href.replace(/\/$/, '') == child.href.replace(/\/$/, '')
|
||||
) {
|
||||
li.classList.add('url-here')
|
||||
} else {
|
||||
li.classList.remove('url-here')
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.nav-container {
|
||||
width: 100dvw;
|
||||
height: 3rem;
|
||||
inline-size: 100dvi;
|
||||
block-size: 3rem;
|
||||
position: fixed;
|
||||
z-index: 100;
|
||||
z-index: 10000;
|
||||
backdrop-filter: blur(4px);
|
||||
background-color: rgb(from var(--color-bg-n) r g b / 0.5);
|
||||
|
||||
@media (width < 768px) {
|
||||
block-size: 100dvh;
|
||||
background-color: #00000033;
|
||||
transition:
|
||||
background-color ease 0.2s,
|
||||
backdrop-filter ease 0.2s;
|
||||
}
|
||||
|
||||
&.nav-container-hidden {
|
||||
@media (width < 768px) {
|
||||
backdrop-filter: blur(0px);
|
||||
background-color: transparent;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
& > nav {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
inline-size: 100%;
|
||||
block-size: 100%;
|
||||
padding-inline: 40px;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
max-width: 1400px;
|
||||
max-inline-size: 1400px;
|
||||
margin-inline: auto;
|
||||
|
||||
font-weight: 400;
|
||||
|
||||
@media (width < 768px) {
|
||||
flex-direction: column;
|
||||
padding-block: 5rem;
|
||||
padding-inline: 2rem;
|
||||
align-items: start;
|
||||
inline-size: 70%;
|
||||
background-color: var(--color-bg-n);
|
||||
margin-inline-start: 0;
|
||||
font-size: larger;
|
||||
transition: transform cubic-bezier(0.4, 1, 0.4, 1) 0.4s;
|
||||
}
|
||||
|
||||
.nav-container-hidden & {
|
||||
@media (width < 768px) {
|
||||
transform: translateX(-80dvi);
|
||||
}
|
||||
}
|
||||
|
||||
& > ul {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
@media (width < 768px) {
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
inline-size: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
& li {
|
||||
height: 2rem;
|
||||
|
||||
@media (width < 768px) {
|
||||
height: 3rem;
|
||||
inline-size: 100%;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: rgb(from var(--color-fg-0) r g b / 0.1);
|
||||
}
|
||||
|
||||
&.url-here {
|
||||
color: var(--color-blue);
|
||||
background-color: rgb(from var(--color-blue) r g b / 0.1);
|
||||
}
|
||||
|
||||
& > a {
|
||||
padding-inline: 0.75rem;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
inline-size: 100%;
|
||||
block-size: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
@ -101,4 +235,94 @@ const { title = '小帕的小窝' } = Astro.props
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.nav-mobile {
|
||||
inline-size: 100dvw;
|
||||
block-size: 4rem;
|
||||
position: fixed;
|
||||
z-index: 100;
|
||||
backdrop-filter: blur(4px);
|
||||
background-color: rgb(from var(--color-bg-n) r g b / 0.5);
|
||||
font-size: larger;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding-inline: 1rem;
|
||||
gap: 0.5rem;
|
||||
|
||||
& > button {
|
||||
inline-size: 3rem;
|
||||
aspect-ratio: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 2rem;
|
||||
cursor: pointer;
|
||||
|
||||
&:active,
|
||||
&:hover {
|
||||
background-color: rgb(from var(--color-fg-0) r g b / 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
& > a {
|
||||
font-weight: 600;
|
||||
|
||||
&:active,
|
||||
&:hover {
|
||||
background-color: rgb(from var(--color-fg-0) r g b / 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
@media (width >= 768px) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-indicator {
|
||||
--color1: oklch(from var(--color-blue) 0.7 0.17 h);
|
||||
--color2: oklch(from var(--color-blue) 0.57 0.25 h);
|
||||
--loading-x-size: 2rem;
|
||||
--loading-height: 0.25rem;
|
||||
|
||||
position: fixed;
|
||||
height: var(--loading-height);
|
||||
background-color: var(--color1);
|
||||
inset-inline-start: 0;
|
||||
inset-inline-end: 0;
|
||||
inset-block-start: 0;
|
||||
z-index: 10001;
|
||||
background-image: linear-gradient(
|
||||
-45deg,
|
||||
transparent 0%,
|
||||
transparent 25%,
|
||||
var(--color2) 25%,
|
||||
var(--color2) 75%,
|
||||
transparent 75%,
|
||||
transparent 100%
|
||||
);
|
||||
background-repeat: repeat;
|
||||
background-size: 2rem 100%;
|
||||
|
||||
animation: loading-animation infinite 0.5s linear;
|
||||
transition: inset-block-start cubic-bezier(0.4, 1, 0.4, 1) 0.2s;
|
||||
|
||||
&.hidden {
|
||||
inset-block-start: calc(-1 * var(--loading-height));
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes loading-animation {
|
||||
0% {
|
||||
background-position: 0 0;
|
||||
}
|
||||
100% {
|
||||
background-position: var(--loading-x-size) 0;
|
||||
}
|
||||
}
|
||||
|
||||
.layout-gap {
|
||||
height: var(--size-nav);
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export const legacyClient = axios.create({
|
||||
// baseURL: import.meta.env.SSR
|
||||
// ? 'https://legacy.passthem.top/api'
|
||||
// : '/api/legacy',
|
||||
baseURL: 'https://legacy.passthem.top/api',
|
||||
baseURL: import.meta.env.SSR
|
||||
? ((await import('astro:env/server')) as any)['LEGACY_BACKEND_URL_SSR']
|
||||
: 'https://legacy.passthem.top/api',
|
||||
// baseURL: 'https://legacy.passthem.top/api',
|
||||
timeout: 6000,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
|
||||
@ -5,14 +5,27 @@ export type ListBlogItemType = {
|
||||
title: string
|
||||
|
||||
/** ISO8601 */
|
||||
created_at: string
|
||||
created_at: Date
|
||||
|
||||
/** ISO8601 */
|
||||
updated_at: string
|
||||
updated_at: Date
|
||||
|
||||
featured_image: null | {
|
||||
image_url: string
|
||||
}
|
||||
|
||||
author: {
|
||||
id: number
|
||||
username: string
|
||||
nickname: string
|
||||
avatar: {
|
||||
image_url: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type BlogContentType = ListBlogItemType & {
|
||||
content: string
|
||||
}
|
||||
|
||||
export const listBlogs = async ({
|
||||
@ -23,22 +36,56 @@ export const listBlogs = async ({
|
||||
limit?: number
|
||||
}) => {
|
||||
const resp = await legacyClient.post('/v1/blog/list', { page, limit })
|
||||
return resp.data.data as ListBlogItemType[]
|
||||
return resp.data.data.map((blog: any) => {
|
||||
let _blog = blog
|
||||
if (blog.featured_image) {
|
||||
_blog = {
|
||||
...blog,
|
||||
featured_image: {
|
||||
image_url:
|
||||
'https://legacy.passthem.top' + blog.featured_image.image_url,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
_blog = blog
|
||||
}
|
||||
|
||||
_blog.author.avatar = {
|
||||
image_url: 'https://legacy.passthem.top' + _blog.author.avatar.image_url,
|
||||
}
|
||||
_blog.created_at = new Date(_blog.created_at)
|
||||
_blog.updated_at = new Date(_blog.updated_at)
|
||||
|
||||
return _blog
|
||||
}) as ListBlogItemType[]
|
||||
}
|
||||
|
||||
export const getBlog: (
|
||||
blog_id: number,
|
||||
) => Promise<null | { title: string; content: string }> = async (
|
||||
blog_id: number,
|
||||
) => {
|
||||
) => Promise<null | BlogContentType> = async (blog_id: number) => {
|
||||
const resp = await legacyClient.get(`/v1/blog/${blog_id}`, {
|
||||
validateStatus: (status) => status == 200 || status == 404,
|
||||
})
|
||||
if (resp.status == 404) {
|
||||
return null
|
||||
}
|
||||
return resp.data as {
|
||||
title: string
|
||||
content: string
|
||||
let _blog = resp.data
|
||||
|
||||
if (_blog.featured_image) {
|
||||
_blog = {
|
||||
..._blog,
|
||||
featured_image: {
|
||||
image_url:
|
||||
'https://legacy.passthem.top' + _blog.featured_image.image_url,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
_blog.author.avatar = {
|
||||
image_url: 'https://legacy.passthem.top' + _blog.author.avatar.image_url,
|
||||
}
|
||||
_blog.created_at = new Date(_blog.created_at)
|
||||
_blog.updated_at = new Date(_blog.updated_at)
|
||||
|
||||
return _blog
|
||||
}
|
||||
|
||||
32
src/lib/data/contact.json
Normal file
32
src/lib/data/contact.json
Normal file
@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"platform": "YnVodGlH",
|
||||
"href": "dXNlZC1tZWh0c3NhcC9tb2MuYnVodGlnLy86c3B0dGg=",
|
||||
"name": "dXNlZC1tZWh0c3NhcA=="
|
||||
},
|
||||
{
|
||||
"platform": "ZW1pdGFrYVc=",
|
||||
"href": "bWVodHNzYXBAL21vYy5lbWl0YWthdy8vOnNwdHRo",
|
||||
"name": "bWVodHNzYXBA"
|
||||
},
|
||||
{
|
||||
"platform": "ZWJ1dHVvWQ==",
|
||||
"href": "MzgxbWVodHNzYVBAL21vYy5lYnV0dW95Lnd3dy8vOnNwdHRo",
|
||||
"name": "MzgxbWVodHNzYVBA"
|
||||
},
|
||||
{
|
||||
"platform": "ZXRpU290Tw==",
|
||||
"href": "bWVodHNzYXBAL2V0aXMuZGFtb3RvLy86c3B0dGg=",
|
||||
"name": "bWVodHNzYXBA"
|
||||
},
|
||||
{
|
||||
"platform": "bGlhbUU=",
|
||||
"href": "bW9jLmxpYW1nQDM4MW1laHRzc2FwOm90bGlhbQ==",
|
||||
"name": "bW9jLmxpYW1nQDM4MW1laHRzc2Fw"
|
||||
},
|
||||
{
|
||||
"platform": "aWxpYmlsaUI=",
|
||||
"href": "NDA2MjU4MjkvbW9jLmlsaWJpbGliLmVjYXBzLy86c3B0dGg=",
|
||||
"name": "bWVodHNzYXA="
|
||||
}
|
||||
]
|
||||
4
src/lib/keyv-cache.server.ts
Normal file
4
src/lib/keyv-cache.server.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { REDIS_URL } from 'astro:env/server'
|
||||
import KeyvRedis from '@keyv/redis'
|
||||
|
||||
export const storage = REDIS_URL ? new KeyvRedis(REDIS_URL) : new Map()
|
||||
20
src/lib/markdoc-cache.server.ts
Normal file
20
src/lib/markdoc-cache.server.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import './server-only.ts'
|
||||
|
||||
import type { RenderableTreeNode } from '@markdoc/markdoc'
|
||||
import KeyV from 'keyv'
|
||||
import { createHash } from 'node:crypto'
|
||||
import { storage } from './keyv-cache.server.ts'
|
||||
|
||||
const markdocVersion = '1'
|
||||
|
||||
export const markdocCache = new KeyV<RenderableTreeNode>({
|
||||
store: storage,
|
||||
namespace: `markdoc-cache-${markdocVersion}`,
|
||||
ttl: 1000 * 60 * 60 * 24 * 7,
|
||||
})
|
||||
export const generateCacheKey = (content: string) => {
|
||||
return createHash('sha256')
|
||||
.update(content)
|
||||
.update(markdocVersion)
|
||||
.digest('hex')
|
||||
}
|
||||
21
src/lib/markdoc.server.ts
Normal file
21
src/lib/markdoc.server.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import './server-only.ts'
|
||||
|
||||
import { renderMarkdocTree } from './markdoc.ts'
|
||||
import { generateCacheKey, markdocCache } from './markdoc-cache.server.ts'
|
||||
|
||||
export const getCachedMarkdocTree = async (content: string) => {
|
||||
if (!import.meta.env.SSR) {
|
||||
return await renderMarkdocTree(content)
|
||||
}
|
||||
|
||||
const key = generateCacheKey(content)
|
||||
const cached = await markdocCache.get(key)
|
||||
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
|
||||
const tree = await renderMarkdocTree(content)
|
||||
markdocCache.set(key, tree)
|
||||
return tree
|
||||
}
|
||||
@ -12,6 +12,15 @@ export const markdocConfig: Config = {
|
||||
highlightedHtml: { type: String },
|
||||
},
|
||||
transform(node, config) {
|
||||
/*
|
||||
* 注意力!!!!!!!!!!!!!!
|
||||
* 注意!!!!!!!!!!!!
|
||||
*
|
||||
* 如果改了这里的逻辑,记得更改 `markdoc-cache.ts` 里的版本号
|
||||
* 以让对应的缓存能够被更新
|
||||
*
|
||||
**/
|
||||
|
||||
const attributes = node.transformAttributes(config)
|
||||
|
||||
const highlightedHtml = shikiRender(
|
||||
@ -29,8 +38,10 @@ export const markdocConfig: Config = {
|
||||
},
|
||||
}
|
||||
|
||||
export const toMarkdocTree = async (content: string) => {
|
||||
export const renderMarkdocTree = async (content: string) => {
|
||||
const ast = Markdoc.parse(content)
|
||||
await ensureShikiEngine()
|
||||
return Markdoc.transform(ast, markdocConfig)
|
||||
const tree = Markdoc.transform(ast, markdocConfig)
|
||||
|
||||
return tree
|
||||
}
|
||||
|
||||
@ -32,6 +32,17 @@ const allowed_langs: BundledLanguage[] = [
|
||||
'sh',
|
||||
'mermaid',
|
||||
'cpp',
|
||||
'fish',
|
||||
'zsh',
|
||||
'docker',
|
||||
'dockerfile',
|
||||
'yml',
|
||||
'system-verilog',
|
||||
'sql',
|
||||
'glsl',
|
||||
'mediawiki',
|
||||
'systemd',
|
||||
'ini',
|
||||
]
|
||||
|
||||
export async function ensureShikiEngine() {
|
||||
|
||||
3
src/lib/server-only.ts
Normal file
3
src/lib/server-only.ts
Normal file
@ -0,0 +1,3 @@
|
||||
if (!import.meta.env.SSR) {
|
||||
throw Error('这段代码不可以在客户端执行!')
|
||||
}
|
||||
10
src/pages/404.astro
Normal file
10
src/pages/404.astro
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
import BoringLayout from '../layout/BoringLayout.astro'
|
||||
---
|
||||
|
||||
<BoringLayout title="404 - 小帕的小窝">
|
||||
<h1>网页走丢了!!</h1>
|
||||
<p>不知道为什么就到了这里。。</p>
|
||||
<p><a href="javascript:history.back()">点击这里</a>回到上一页</p>
|
||||
<p>或者<a href="/">点击这里</a>回到主页</p>
|
||||
</BoringLayout>
|
||||
10
src/pages/500.astro
Normal file
10
src/pages/500.astro
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
import BoringLayout from '../layout/BoringLayout.astro'
|
||||
---
|
||||
|
||||
<BoringLayout title="500 - 小帕的小窝">
|
||||
<h1>服务器内部错误</h1>
|
||||
<p>哦不肯定是小帕搞错了什么东西。。</p>
|
||||
<p><a href="javascript:history.back()">点击这里</a>回到上一页</p>
|
||||
<p>或者<a href="/">点击这里</a>回到主页</p>
|
||||
</BoringLayout>
|
||||
5
src/pages/[...slug].astro
Normal file
5
src/pages/[...slug].astro
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
export const prerender = false
|
||||
|
||||
return Astro.redirect('/404')
|
||||
---
|
||||
@ -1,36 +1,13 @@
|
||||
---
|
||||
import BoringLayout from '../layout/BoringLayout.astro'
|
||||
|
||||
const friends = [
|
||||
['https://omega98.top', '核子的博客'],
|
||||
['https://tnot.top', 'TNOT 的博客'],
|
||||
['https://ruusuge.top', 'ルース毛的博客'],
|
||||
['https://akarin.dev/', '宸佬的博客'],
|
||||
['https://wzq02.top', 'wzq02 的博客'],
|
||||
['https://r1kka.one/', "Rikka's Blog"],
|
||||
]
|
||||
---
|
||||
|
||||
<BoringLayout title="关于">
|
||||
<h1>关于<a href="/">这里</a></h1>
|
||||
<p>这里是 passthem 和他朋友们的博客</p>
|
||||
<p>主要由我也就是 passthem 运维这个网站,但是我会接收朋友们的投稿</p>
|
||||
<h1>怎么感觉有点未完成</h1>
|
||||
<p>之前,我心血来潮,写了一个自己的博客系统,但是我把它的源代码搞丢了!</p>
|
||||
<p>正好想重新设计,所以,我打算重构了。但是,重构它很漫长</p>
|
||||
<p>这里的占位的东西,会慢慢填充的!</p>
|
||||
<h1>友链</h1>
|
||||
<p>
|
||||
{
|
||||
friends
|
||||
.map((friend) => {
|
||||
return <a href={friend[0]}>{friend[1]}</a>
|
||||
})
|
||||
.map((block, i) => {
|
||||
if (i == friends.length - 1) {
|
||||
return block
|
||||
} else {
|
||||
return [block, <span>・</span>]
|
||||
}
|
||||
})
|
||||
.flat()
|
||||
}
|
||||
</p>
|
||||
</BoringLayout>
|
||||
|
||||
@ -1,35 +1,68 @@
|
||||
---
|
||||
import FullLayoutV1 from '../layout/FullLayoutV1.astro'
|
||||
import { listBlogs } from '../lib/apis/legacy/blog'
|
||||
import { listBlogs, type ListBlogItemType } from '../lib/apis/legacy/blog'
|
||||
import BlogCard from '../components/BlogCard.astro'
|
||||
import BlogHeaderImage from '../assets/blogs-header.webp'
|
||||
import { Image } from 'astro:assets'
|
||||
|
||||
export const prerender = false
|
||||
|
||||
const _page = parseInt(Astro.url.searchParams.get('page') || '1')
|
||||
const page = isNaN(_page) ? 1 : Math.max(1, _page)
|
||||
|
||||
const blogs = await listBlogs({ page })
|
||||
let blogs: ListBlogItemType[] = []
|
||||
|
||||
try {
|
||||
blogs = await listBlogs({ page, limit: 100 })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return Astro.redirect('/500')
|
||||
}
|
||||
---
|
||||
|
||||
<FullLayoutV1>
|
||||
<div class="__dev__caution">
|
||||
<FullLayoutV1 withGap title="博客列表 - 小帕的小窝">
|
||||
<!-- <div class="__dev__caution">
|
||||
<h1>仍在开发中,界面会崩坏</h1>
|
||||
</div> -->
|
||||
<div class="container">
|
||||
<section class="blogs-header">
|
||||
<Image
|
||||
class="image"
|
||||
src={BlogHeaderImage}
|
||||
alt="博客列表的头图,一个悬挂在空中的 LCD1602,上面写着一些示例文本"
|
||||
width={960}
|
||||
height={540}
|
||||
densities={[1.5, 2]}
|
||||
/>
|
||||
<div class="description">
|
||||
<h1>博客列表</h1>
|
||||
<h2>这里是 passthem 和他朋友们的文章</h2>
|
||||
</div>
|
||||
</section>
|
||||
<main>
|
||||
<ul>
|
||||
{
|
||||
blogs.map((blog) => (
|
||||
<BlogCard
|
||||
title={blog.title}
|
||||
link={`/blogs/${blog.id}`}
|
||||
featureImage={blog.featured_image?.image_url}
|
||||
author={{
|
||||
name: blog.author.nickname,
|
||||
avatar: blog.author.avatar.image_url,
|
||||
}}
|
||||
createdAt={blog.created_at}
|
||||
updatedAt={blog.updated_at}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</main>
|
||||
</div>
|
||||
<section>
|
||||
<ul>
|
||||
{
|
||||
blogs.map((blog) => (
|
||||
<li>
|
||||
<a href={`/blogs/${blog.id}`}>{blog.title}</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
</FullLayoutV1>
|
||||
|
||||
<style>
|
||||
.__dev__caution {
|
||||
width: 100dvw;
|
||||
height: 100dvh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -40,4 +73,72 @@ const blogs = await listBlogs({ page })
|
||||
font-weight: 800;
|
||||
}
|
||||
}
|
||||
|
||||
.container {
|
||||
max-inline-size: 960px;
|
||||
margin-inline: auto;
|
||||
}
|
||||
|
||||
.blogs-header {
|
||||
margin-block-end: 3rem;
|
||||
position: relative;
|
||||
aspect-ratio: 16 / 9;
|
||||
|
||||
@media (width < 768px) and (width >= 540px) {
|
||||
aspect-ratio: 2.5 / 1;
|
||||
}
|
||||
|
||||
@media (width >= 768px) {
|
||||
aspect-ratio: 4 / 1;
|
||||
}
|
||||
|
||||
& > .image {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
filter: saturate(0.6);
|
||||
object-fit: cover;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
& > .description {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
gap: 0.5rem;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #00000099;
|
||||
color: white;
|
||||
|
||||
& > h1 {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
& > h2 {
|
||||
font-size: 1rem;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
& > h1,
|
||||
& > h2 {
|
||||
text-shadow: 0 0 10px black;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (width >= 768px) {
|
||||
main {
|
||||
margin-inline: auto;
|
||||
max-width: 840px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
---
|
||||
import { getBlog } from '../../lib/apis/legacy/blog'
|
||||
import BaseLayout from '../../layout/BaseLayout.astro'
|
||||
import FullLayoutV1 from '../../layout/FullLayoutV1.astro'
|
||||
import { MarkdocTreeRender } from '../../components/MarkdocRenderer.tsx'
|
||||
import { toMarkdocTree } from '../../lib/markdoc'
|
||||
import { getCachedMarkdocTree } from '../../lib/markdoc.server.ts'
|
||||
import { Image } from 'astro:assets'
|
||||
import { Icon } from 'astro-icon/components'
|
||||
|
||||
import Artalk from '../../components/Artalk.svelte'
|
||||
|
||||
export const prerender = false
|
||||
|
||||
@ -13,15 +17,165 @@ if (isNaN(blog_id_num) || blog_id_num < 0) {
|
||||
return Astro.redirect('/404')
|
||||
}
|
||||
|
||||
const blogData = await getBlog(blog_id_num)
|
||||
let blogData = null
|
||||
|
||||
try {
|
||||
blogData = await getBlog(blog_id_num)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return Astro.redirect('/500')
|
||||
}
|
||||
|
||||
if (blogData === null) {
|
||||
return Astro.redirect('/404')
|
||||
}
|
||||
|
||||
const tree = await toMarkdocTree(blogData.content)
|
||||
const tree = await getCachedMarkdocTree(blogData.content)
|
||||
const formatDate = (date: Date) =>
|
||||
`${date.getFullYear()} 年 ${date.getMonth() + 1} 月 ${date.getDate()} 日`
|
||||
---
|
||||
|
||||
<!-- <BaseLayout set:html={blogRendered} /> -->
|
||||
<BaseLayout title={blogData.title}>
|
||||
<MarkdocTreeRender tree={tree} client:load />
|
||||
</BaseLayout>
|
||||
<FullLayoutV1 title={blogData.title} withGap>
|
||||
{
|
||||
blogData.featured_image && (
|
||||
<div class="featured-image">
|
||||
<Image
|
||||
class="image"
|
||||
src={blogData.featured_image.image_url}
|
||||
width={960}
|
||||
height={540}
|
||||
alt="博客的头图"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<main>
|
||||
<h1>{blogData.title}</h1>
|
||||
{
|
||||
blogData.author && (
|
||||
<div class="blog-info">
|
||||
<a
|
||||
class="author"
|
||||
href={`https://legacy.passthem.top/user/${blogData.author.username}`}
|
||||
>
|
||||
<div class="avatar">
|
||||
<Image
|
||||
class="image"
|
||||
src={blogData.author.avatar.image_url}
|
||||
width={32}
|
||||
height={32}
|
||||
alt={`用户 ${blogData.author.nickname} 的头像`}
|
||||
/>
|
||||
</div>
|
||||
<div class="username">{blogData.author.nickname}</div>
|
||||
</a>
|
||||
<span class="split">・</span>
|
||||
<span>{formatDate(blogData.updated_at)} 更新</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<article>
|
||||
<MarkdocTreeRender tree={tree} client:load />
|
||||
</article>
|
||||
<h1 class="comment-title">
|
||||
<Icon name="material-symbols:chat-rounded" /> 评论区
|
||||
</h1>
|
||||
<Artalk client:idle />
|
||||
</main>
|
||||
</FullLayoutV1>
|
||||
|
||||
<style>
|
||||
.__dev__caution {
|
||||
height: 100dvh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
& > h1 {
|
||||
font-size: 72px;
|
||||
font-weight: 800;
|
||||
}
|
||||
}
|
||||
|
||||
.featured-image {
|
||||
margin-inline: auto;
|
||||
width: 100%;
|
||||
max-width: 960px;
|
||||
aspect-ratio: 16 / 9;
|
||||
margin-block-end: 2rem;
|
||||
position: relative;
|
||||
|
||||
& > .image {
|
||||
object-fit: cover;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
height: 50px;
|
||||
width: 100%;
|
||||
background: linear-gradient(to bottom, transparent, #00000044);
|
||||
}
|
||||
|
||||
@media (width < 768px) and (width >= 540px) {
|
||||
aspect-ratio: 2.5 / 1;
|
||||
}
|
||||
|
||||
@media (width >= 768px) {
|
||||
aspect-ratio: 4 / 1;
|
||||
margin-block-end: 3rem;
|
||||
}
|
||||
}
|
||||
|
||||
.blog-info {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 1rem;
|
||||
color: var(--color-fg-1);
|
||||
|
||||
& > .author {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
|
||||
& > .avatar {
|
||||
& > .image {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
object-fit: cover;
|
||||
border-radius: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
max-inline-size: 840px;
|
||||
margin-inline: auto;
|
||||
padding-block-end: 4rem;
|
||||
padding-inline: 20px;
|
||||
|
||||
& > h1 {
|
||||
font-size: 2rem;
|
||||
font-weight: 900;
|
||||
margin-block-end: 1.2rem;
|
||||
margin-block-start: 2rem;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
|
||||
&.comment-title {
|
||||
margin-block-start: 3rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
---
|
||||
import BoringLayout from '../layout/BoringLayout.astro'
|
||||
---
|
||||
|
||||
<BoringLayout title="联络我">
|
||||
<h1>联络我</h1>
|
||||
<p>邮箱:<a href="mailto:passthem183@gmail.com">passthem183@gmail.com</a></p>
|
||||
<p>点击 <a href="/">这里</a> 返回主页</p>
|
||||
</BoringLayout>
|
||||
@ -6,15 +6,13 @@ import FullLayoutV1 from '../layout/FullLayoutV1.astro'
|
||||
import MainpageButton from '../components/MainpageButton.svelte'
|
||||
import MainpageComments from '../components/MainpageComments.astro'
|
||||
import MainpageTypewriter from '../components/MainpageTypewriter.svelte'
|
||||
import MainpageContactMe from '../components/MainpageContactMe.svelte'
|
||||
import { Image } from 'astro:assets'
|
||||
import { Icon } from 'astro-icon/components'
|
||||
import PassthemAvatar from '../assets/mainpage_avatars/passthem.png'
|
||||
|
||||
import { mainpageGetClick } from '../lib/apis/legacy/mainpage'
|
||||
|
||||
// 常量定义
|
||||
const AVATAR_URL =
|
||||
'https://cdn.passthem.top/sharex/2026/03/%E6%93%A6%E6%B1%97%E5%90%8E_%E6%96%B9%E5%BD%A2.png.upscale.png'
|
||||
|
||||
// 无用按钮的数字预注入
|
||||
let initialClicks = 0
|
||||
|
||||
@ -33,11 +31,12 @@ try {
|
||||
<div class="self-introduction">
|
||||
<figure class="avatar">
|
||||
<Image
|
||||
src={AVATAR_URL}
|
||||
src={PassthemAvatar}
|
||||
alt="passthem 的头像,一个戴眼镜的男孩"
|
||||
loading="eager"
|
||||
loading="lazy"
|
||||
width={240}
|
||||
height={240}
|
||||
densities={[1.5, 2]}
|
||||
/>
|
||||
</figure>
|
||||
<div class="descriptions">
|
||||
@ -69,7 +68,7 @@ try {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="slide" style="background-color: var(--color-bg-1);">
|
||||
<section class="slide">
|
||||
<div class="slide-title-design1" aria-hidden="true">
|
||||
<svg width="800" height="240" viewBox="0 0 800 240">
|
||||
<text x="10" y="220" class="stroke-layer">留言</text>
|
||||
@ -87,6 +86,27 @@ try {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="slide">
|
||||
<div class="slide-title-design1" aria-hidden="true">
|
||||
<svg width="800" height="240" viewBox="0 0 800 240">
|
||||
<text x="10" y="220" class="stroke-layer">联络</text>
|
||||
<text x="0" y="210" class="main-layer">联络</text>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="slide-title-design2" aria-hidden="true">
|
||||
<Icon name="mdi:email" />
|
||||
</div>
|
||||
<div class="contact-container">
|
||||
<h1>
|
||||
<div class="text">联系我<div class="animation-before"></div></div><div
|
||||
class="animation"
|
||||
>
|
||||
</div>
|
||||
</h1>
|
||||
<MainpageContactMe client:idle />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="slide">
|
||||
<div class="slide-title-design1" aria-hidden="true">
|
||||
<svg width="800" height="240" viewBox="0 0 800 240">
|
||||
@ -97,7 +117,71 @@ try {
|
||||
<div class="slide-title-design2" aria-hidden="true">
|
||||
<Icon name="mdi:link-variant" />
|
||||
</div>
|
||||
<h1>当前页面还在开发中......</h1>
|
||||
<h1>友情链接</h1>
|
||||
<div class="friends">
|
||||
{
|
||||
[
|
||||
[
|
||||
'https://omega98.top/images/blog_avatar.jpg',
|
||||
'https://omega98.top',
|
||||
'核子的博客',
|
||||
],
|
||||
['https://www.tnot.top/logo.png', 'https://tnot.top', 'TNOT 的博客'],
|
||||
[
|
||||
'https://ruusuge.top/img/logo_hu_cc283ac364b1bc0b.png',
|
||||
'https://ruusuge.top',
|
||||
'ルース毛的博客',
|
||||
],
|
||||
[
|
||||
'https://cdn.jsdelivr.net/gh/TransparentLC/transparentlc.github.io/img/avatar.jpg',
|
||||
'https://akarin.dev',
|
||||
'存在感消失的地方',
|
||||
],
|
||||
[
|
||||
'https://wzq02.top/assets/icons/favicon-96x96.png',
|
||||
'https://wzq02.top',
|
||||
'wzq02 的博客',
|
||||
],
|
||||
[
|
||||
'https://pics.r1kka.one/file/1738764637932_-305500c1acccdf39.jpg',
|
||||
'https://r1kka.one/',
|
||||
"Rikka's Blog",
|
||||
],
|
||||
[
|
||||
'https://shimizukaede.top/vite.svg',
|
||||
'https://shimizukaede.top',
|
||||
'Kaede 的博客',
|
||||
],
|
||||
[
|
||||
'https://nonerd.tech/assets/apple-touch-icon.png',
|
||||
'https://nonerd.tech/',
|
||||
'废柴铁克诺',
|
||||
],
|
||||
[
|
||||
'https://legacy.passthem.top/assets/ydt-DIeb2Djx.png',
|
||||
'https://qm.qq.com/q/nDnHUy9KQo',
|
||||
'有顶天变电站 (QQ)',
|
||||
],
|
||||
[
|
||||
'https://legacy.passthem.top/assets/lfxdxy-BogfTZvz.png',
|
||||
'https://qm.qq.com/q/QOpCVZcvyS',
|
||||
'六方相的新月 (QQ)',
|
||||
],
|
||||
].map((b) => (
|
||||
<a href={b[1]} class="friend">
|
||||
<div class="avatar">
|
||||
<Image
|
||||
src={b[0]}
|
||||
width={60}
|
||||
height={60}
|
||||
alt={`网站「${b[2]}」的图标`}
|
||||
/>
|
||||
</div>
|
||||
<div class="description">{b[2]}</div>
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
</FullLayoutV1>
|
||||
|
||||
@ -118,6 +202,11 @@ try {
|
||||
|
||||
document.querySelectorAll('section.slide').forEach((ele) => {
|
||||
observer.observe(ele)
|
||||
;(ele as HTMLElement).addEventListener('focusin', () => {
|
||||
ele.scrollIntoView({
|
||||
block: 'start',
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -132,7 +221,8 @@ try {
|
||||
|
||||
.slide {
|
||||
scroll-snap-align: start;
|
||||
height: 100dvh;
|
||||
scroll-snap-stop: always;
|
||||
height: 100lvh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@ -140,13 +230,17 @@ try {
|
||||
overflow: hidden;
|
||||
isolation: isolate;
|
||||
|
||||
&:nth-child(2n) {
|
||||
background-color: var(--color-bg-1);
|
||||
}
|
||||
|
||||
& > .notation {
|
||||
position: absolute;
|
||||
width: 100dvw;
|
||||
padding-inline-start: 2rem;
|
||||
padding-block-end: 2rem;
|
||||
inset-inline-start: 0;
|
||||
inset-block-end: 0;
|
||||
inset-block-end: calc(100lvh - 100dvh);
|
||||
font-size: smaller;
|
||||
color: var(--color-fg-0);
|
||||
opacity: 0.3;
|
||||
@ -184,6 +278,24 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
@property --avatar-scalar {
|
||||
syntax: '<number>';
|
||||
inherits: true;
|
||||
initial-value: 0;
|
||||
}
|
||||
|
||||
@property --avatar-hover-scalar {
|
||||
syntax: '<number>';
|
||||
inherits: true;
|
||||
initial-value: 0;
|
||||
}
|
||||
|
||||
@property --avatar-rotation {
|
||||
syntax: '<angle>';
|
||||
inherits: true;
|
||||
initial-value: 0deg;
|
||||
}
|
||||
|
||||
/* 自我介绍部分 */
|
||||
.self-introduction {
|
||||
display: flex;
|
||||
@ -200,16 +312,32 @@ try {
|
||||
& > .avatar {
|
||||
margin: 0;
|
||||
border-radius: 50%;
|
||||
|
||||
--final-width: clamp(160px, 30vw, 240px);
|
||||
transition: all cubic-bezier(0.4, 1, 0.4, 1) 1.2s;
|
||||
transform: rotate(10deg);
|
||||
--avatar-scalar: 0;
|
||||
--avatar-hover-scalar: 1;
|
||||
--avatar-rotation: 20deg;
|
||||
transition:
|
||||
--avatar-rotation cubic-bezier(0.2, 1, 0.4, 1) 1.8s,
|
||||
--avatar-scalar cubic-bezier(0.2, 2, 0.3, 0.8) 1.2s,
|
||||
--avatar-hover-scalar cubic-bezier(0.2, 3, 0.4, 0.6) 0.6s,
|
||||
width cubic-bezier(0.4, 1, 0.4, 1) 0.9s;
|
||||
|
||||
transform: rotate(var(--avatar-rotation)) scale(var(--avatar-scalar))
|
||||
scale(var(--avatar-hover-scalar));
|
||||
aspect-ratio: 1 / 1;
|
||||
overflow: hidden;
|
||||
width: 0;
|
||||
|
||||
section.slide.slide-visible & {
|
||||
--avatar-scalar: 1;
|
||||
--avatar-rotation: 0deg;
|
||||
width: var(--final-width);
|
||||
transform: rotate(0);
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
--avatar-hover-scalar: 1.05;
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,7 +399,8 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
section:has(.thsx:hover) .motto > p {
|
||||
section:has(.thsx:hover) .motto > p,
|
||||
section:has(.thsx:focus) .motto > p {
|
||||
&:nth-child(1)::before {
|
||||
transition-delay: 0;
|
||||
}
|
||||
@ -384,4 +513,164 @@ try {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 联络页 */
|
||||
@keyframes bg-contact-roll {
|
||||
0% {
|
||||
background-position: 0 0;
|
||||
}
|
||||
100% {
|
||||
background-position: var(--bg-width) 0;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-container {
|
||||
& > h1 {
|
||||
--height: 1.5em;
|
||||
--skew-angle: 15deg;
|
||||
--col1: var(--color-fg-0);
|
||||
--bg-width: 2rem;
|
||||
--unit: calc(tan(var(--skew-angle)) * var(--height) * 0.5);
|
||||
|
||||
height: var(--height);
|
||||
line-height: var(--height);
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
color: var(--color-bg-0);
|
||||
margin-block-end: 0.5em;
|
||||
position: relative;
|
||||
|
||||
& > .text {
|
||||
background-color: var(--color-fg-0);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
& .animation-before {
|
||||
width: calc(var(--unit) * 2);
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
inset-inline-end: calc(var(--unit) * -2);
|
||||
inset-block-start: 0;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
display: block;
|
||||
background-color: var(--col1);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform: skewX(var(--skew-angle)) translateX(calc(-1 * var(--unit)));
|
||||
}
|
||||
}
|
||||
|
||||
& > .animation {
|
||||
content: '';
|
||||
display: block;
|
||||
background-image: linear-gradient(
|
||||
90deg,
|
||||
transparent 0,
|
||||
transparent 25%,
|
||||
var(--col1) 25%,
|
||||
var(--col1) 75%,
|
||||
transparent 75%,
|
||||
transparent 100%
|
||||
);
|
||||
background-repeat: repeat;
|
||||
background-size: var(--bg-width) 100%;
|
||||
animation: bg-contact-roll infinite linear 2s;
|
||||
transform: skewX(var(--skew-angle)) translateX(calc(var(--unit) - 1px));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 友链页 */
|
||||
.slide:has(> .friends) {
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.friends {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
max-width: 50rem;
|
||||
max-height: 30rem;
|
||||
padding-block: 3rem;
|
||||
overflow-y: auto;
|
||||
margin-inline: 1rem;
|
||||
/* background-color: rgb(from var(--color-bg-0) r g b / .3); */
|
||||
background-color: rgb(from var(--color-bg-2) r g b / 0.5);
|
||||
border-radius: 2rem;
|
||||
backdrop-filter: blur(5px);
|
||||
|
||||
& > .friend {
|
||||
background-color: var(--color-bg-0);
|
||||
display: grid;
|
||||
align-items: center;
|
||||
border-radius: 30px;
|
||||
overflow: hidden;
|
||||
width: 14rem;
|
||||
height: 60px;
|
||||
grid-template-columns: 60px 1fr;
|
||||
position: relative;
|
||||
isolation: isolate;
|
||||
|
||||
& > .avatar {
|
||||
border-radius: 30px;
|
||||
height: 60px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
background-color: var(--color-bg-n);
|
||||
/* box-shadow: 0 0 0 10px var(--color-bg-2); */
|
||||
transition: all cubic-bezier(0.2, 1, 0.4, 1) 0.5s;
|
||||
}
|
||||
|
||||
& > .description {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
display: block;
|
||||
border-radius: 30px;
|
||||
background-color: var(--color-bg-n);
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
inset-inline-start: calc(-100% + 30px);
|
||||
box-shadow: 0 0 0 10px var(--color-blue);
|
||||
transition: inset-inline-start cubic-bezier(0.2, 1, 0.4, 1) 0.5s;
|
||||
}
|
||||
|
||||
outline: solid 0px transparent;
|
||||
outline-offset: 0px;
|
||||
transition: all cubic-bezier(0.2, 1, 0.4, 1) 0.5s;
|
||||
|
||||
&:focus {
|
||||
outline: solid 3px var(--color-blue);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
&:hover::before,
|
||||
&:focus::before {
|
||||
inset-inline-start: 0;
|
||||
}
|
||||
|
||||
&:hover .avatar,
|
||||
&:focus .avatar {
|
||||
/* transform: rotate(360deg); */
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,6 +1,53 @@
|
||||
import rss from '@astrojs/rss'
|
||||
import rss, { type RSSFeedItem } from '@astrojs/rss'
|
||||
import type { APIRoute } from 'astro'
|
||||
import { listBlogs, type ListBlogItemType } from '../lib/apis/legacy/blog'
|
||||
import {
|
||||
getBlog,
|
||||
listBlogs,
|
||||
type ListBlogItemType,
|
||||
} from '../lib/apis/legacy/blog'
|
||||
import { ensureShikiEngine } from '../lib/markdown'
|
||||
// import { toMarkdocTree } from '../lib/markdoc'
|
||||
import Markdoc from '@markdoc/markdoc'
|
||||
import KeyV from 'keyv'
|
||||
import { createHash } from 'node:crypto'
|
||||
import { storage } from '../lib/keyv-cache.server'
|
||||
|
||||
export const prerender = false
|
||||
|
||||
const renderCache = new KeyV<string>({
|
||||
store: storage,
|
||||
namespace: 'markdoc-rss',
|
||||
})
|
||||
|
||||
const _render = async (content: string) => {
|
||||
const key = 'html:' + createHash('sha256').update(content).digest('hex')
|
||||
const cached = await renderCache.get(key)
|
||||
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
|
||||
const blogTree = Markdoc.transform(Markdoc.parse(content))
|
||||
const html = Markdoc.renderers.html(blogTree)
|
||||
|
||||
await renderCache.set(key, html, 1000 * 60 * 60 * 24)
|
||||
return html
|
||||
}
|
||||
|
||||
const _getBlog = async (blogId: number) => {
|
||||
const key = `raw:blog-${blogId}`
|
||||
const cached = await renderCache.get(key)
|
||||
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
|
||||
const content = (await getBlog(blogId))?.content
|
||||
if (content) {
|
||||
await renderCache.set(key, content, 1000 * 60 * 60 * 12)
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
export const GET = (async (context) => {
|
||||
let blogs: ListBlogItemType[] = []
|
||||
@ -17,16 +64,34 @@ export const GET = (async (context) => {
|
||||
}
|
||||
|
||||
const site = context.site || 'https://passthem.top'
|
||||
await ensureShikiEngine()
|
||||
|
||||
return rss({
|
||||
title: '小帕的小窝',
|
||||
description: '小帕和他朋友们的博客',
|
||||
site,
|
||||
items: blogs.map((blog) => ({
|
||||
title: blog.title,
|
||||
link: `${site}/blogs/${blog.id}`,
|
||||
pubDate: new Date(blog.created_at),
|
||||
})),
|
||||
items: await Promise.all(
|
||||
blogs.map(async (blog) => {
|
||||
const blogContent = (await _getBlog(blog.id)) || '博客内容暂不可用'
|
||||
const rssItem: RSSFeedItem = {
|
||||
title: blog.title,
|
||||
description: `一篇由 ${blog.author.nickname} 写的博客`,
|
||||
link: `${site}/blogs/${blog.id}`,
|
||||
pubDate: new Date(blog.created_at),
|
||||
content: await _render(blogContent),
|
||||
author: blog.author.nickname,
|
||||
enclosure: blog.featured_image
|
||||
? {
|
||||
url: blog.featured_image.image_url,
|
||||
length: 0,
|
||||
type: 'image/jpeg',
|
||||
}
|
||||
: undefined,
|
||||
}
|
||||
|
||||
return rssItem
|
||||
}),
|
||||
),
|
||||
customData: `<language>zh-hans</language>`,
|
||||
})
|
||||
}) satisfies APIRoute
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
{
|
||||
"extends": "astro/tsconfigs/strict",
|
||||
"include": [
|
||||
".astro/types.d.ts",
|
||||
"**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"dist"
|
||||
],
|
||||
"include": [".astro/types.d.ts", "**/*"],
|
||||
"exclude": ["dist"],
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "react"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user