add author url support in layout

This commit is contained in:
m1ngsama 2025-06-10 09:23:30 +08:00
parent f34a83bd52
commit 8fbae689d6
5 changed files with 87 additions and 19 deletions

View file

@ -1,23 +1,26 @@
import { defineConfig } from "astro/config" import { defineConfig } from "astro/config";
import { SITE_URL } from "./src/consts" import { SITE_URL } from "./src/consts";
import vue from "@astrojs/vue" import vue from "@astrojs/vue";
import tailwind from "@astrojs/tailwind" import tailwind from "@astrojs/tailwind";
import react from "@astrojs/react" import react from "@astrojs/react";
import { handleLocalCoverPlugin } from "./src/plugins/cover" import { handleLocalCoverPlugin } from "./src/plugins/cover";
import { themePipeline } from "./src/plugins/theme" import { themePipeline } from "./src/plugins/theme";
import remarkToc from "remark-toc";
import rehypeSlug from "rehype-slug";
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
site: SITE_URL, site: SITE_URL,
markdown: { markdown: {
rehypePlugins: [handleLocalCoverPlugin, ...themePipeline], remarkPlugins: [[remarkToc, { heading: "目录", tight: true }]],
rehypePlugins: [rehypeSlug, handleLocalCoverPlugin, ...themePipeline],
syntaxHighlight: "shiki", syntaxHighlight: "shiki",
shikiConfig: { shikiConfig: {
themes: { themes: {
light: 'github-light', light: "github-light",
dark: 'github-dark', dark: "github-dark",
},
}, },
}
}, },
integrations: [ integrations: [
vue(), vue(),
@ -33,13 +36,13 @@ export default defineConfig({
"/active": { "/active": {
target: "https://active.nbtca.space", target: "https://active.nbtca.space",
changeOrigin: true, changeOrigin: true,
rewrite: path => path.replace(/^\/active/, ""), rewrite: (path) => path.replace(/^\/active/, ""),
}, },
"/saturday": { "/saturday": {
target: "http://localhost:4000", target: "http://localhost:4000",
rewrite: path => path.replace(/^\/saturday/, ""), rewrite: (path) => path.replace(/^\/saturday/, ""),
}, },
} },
} },
} },
}) });

View file

@ -38,6 +38,8 @@
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"rehype": "^13.0.2", "rehype": "^13.0.2",
"rehype-slug": "^6.0.0",
"remark-toc": "^9.0.0",
"sharp": "^0.33.5", "sharp": "^0.33.5",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"unist-util-visit": "^5.0.0", "unist-util-visit": "^5.0.0",

View file

@ -80,6 +80,12 @@ importers:
rehype: rehype:
specifier: ^13.0.2 specifier: ^13.0.2
version: 13.0.2 version: 13.0.2
rehype-slug:
specifier: ^6.0.0
version: 6.0.0
remark-toc:
specifier: ^9.0.0
version: 9.0.0
sharp: sharp:
specifier: ^0.33.5 specifier: ^0.33.5
version: 0.33.5 version: 0.33.5
@ -2462,6 +2468,9 @@ packages:
'@types/react@18.3.23': '@types/react@18.3.23':
resolution: {integrity: sha512-/LDXMQh55EzZQ0uVAZmKKhfENivEvWz6E+EYzh+/MCjMhNsotd+ZHhBGIjFDTi6+fz0OhQQQLbTgdQIxxCsC0w==} resolution: {integrity: sha512-/LDXMQh55EzZQ0uVAZmKKhfENivEvWz6E+EYzh+/MCjMhNsotd+ZHhBGIjFDTi6+fz0OhQQQLbTgdQIxxCsC0w==}
'@types/ungap__structured-clone@1.2.0':
resolution: {integrity: sha512-ZoaihZNLeZSxESbk9PUAPZOlSpcKx81I1+4emtULDVmBLkYutTcMlCj2K9VNlf9EWODxdO6gkAqEaLorXwZQVA==}
'@types/unist@3.0.3': '@types/unist@3.0.3':
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
@ -3752,6 +3761,9 @@ packages:
hast-util-from-parse5@8.0.3: hast-util-from-parse5@8.0.3:
resolution: {integrity: sha512-3kxEVkEKt0zvcZ3hCRYI8rqrgwtlIOFMWkbclACvjlDw8Li9S2hk/d51OI0nr/gIpdMHNepwgOKqZ/sy0Clpyg==} resolution: {integrity: sha512-3kxEVkEKt0zvcZ3hCRYI8rqrgwtlIOFMWkbclACvjlDw8Li9S2hk/d51OI0nr/gIpdMHNepwgOKqZ/sy0Clpyg==}
hast-util-heading-rank@3.0.0:
resolution: {integrity: sha512-EJKb8oMUXVHcWZTDepnr+WNbfnXKFNf9duMesmr4S8SXTJBJ9M4Yok08pu9vxdJwdlGRhVumk9mEhkEvKGifwA==}
hast-util-is-element@3.0.0: hast-util-is-element@3.0.0:
resolution: {integrity: sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==} resolution: {integrity: sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==}
@ -3767,6 +3779,9 @@ packages:
hast-util-to-parse5@8.0.0: hast-util-to-parse5@8.0.0:
resolution: {integrity: sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==} resolution: {integrity: sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==}
hast-util-to-string@3.0.1:
resolution: {integrity: sha512-XelQVTDWvqcl3axRfI0xSeoVKzyIFPwsAGSLIsKdJKQMXDYJS4WYrBNF/8J7RdhIcFI2BOHgAifggsvsxp/3+A==}
hast-util-to-text@4.0.2: hast-util-to-text@4.0.2:
resolution: {integrity: sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==} resolution: {integrity: sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==}
@ -4222,6 +4237,9 @@ packages:
mdast-util-to-string@4.0.0: mdast-util-to-string@4.0.0:
resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==} resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==}
mdast-util-toc@7.1.0:
resolution: {integrity: sha512-2TVKotOQzqdY7THOdn2gGzS9d1Sdd66bvxUyw3aNpWfcPXCLYSJCCgfPy30sEtuzkDraJgqF35dzgmz6xlvH/w==}
merge-stream@2.0.0: merge-stream@2.0.0:
resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==}
@ -4799,6 +4817,9 @@ packages:
rehype-raw@7.0.0: rehype-raw@7.0.0:
resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==} resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==}
rehype-slug@6.0.0:
resolution: {integrity: sha512-lWyvf/jwu+oS5+hL5eClVd3hNdmwM1kAC0BUvEGD19pajQMIzcNUd/k9GsfQ+FfECvX+JE+e9/btsKH0EjJT6A==}
rehype-stringify@10.0.1: rehype-stringify@10.0.1:
resolution: {integrity: sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==} resolution: {integrity: sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==}
@ -4821,6 +4842,9 @@ packages:
remark-stringify@11.0.0: remark-stringify@11.0.0:
resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==} resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==}
remark-toc@9.0.0:
resolution: {integrity: sha512-KJ9txbo33GjDAV1baHFze7ij4G8c7SGYoY8Kzsm2gzFpbhL/bSoVpMMzGa3vrNDSWASNd/3ppAqL7cP2zD6JIA==}
repeat-string@1.6.1: repeat-string@1.6.1:
resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==} resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==}
engines: {node: '>=0.10'} engines: {node: '>=0.10'}
@ -8875,6 +8899,8 @@ snapshots:
'@types/prop-types': 15.7.14 '@types/prop-types': 15.7.14
csstype: 3.1.3 csstype: 3.1.3
'@types/ungap__structured-clone@1.2.0': {}
'@types/unist@3.0.3': {} '@types/unist@3.0.3': {}
'@types/uuid@10.0.0': {} '@types/uuid@10.0.0': {}
@ -10475,6 +10501,10 @@ snapshots:
vfile-location: 5.0.3 vfile-location: 5.0.3
web-namespaces: 2.0.1 web-namespaces: 2.0.1
hast-util-heading-rank@3.0.0:
dependencies:
'@types/hast': 3.0.4
hast-util-is-element@3.0.0: hast-util-is-element@3.0.0:
dependencies: dependencies:
'@types/hast': 3.0.4 '@types/hast': 3.0.4
@ -10523,6 +10553,10 @@ snapshots:
web-namespaces: 2.0.1 web-namespaces: 2.0.1
zwitch: 2.0.4 zwitch: 2.0.4
hast-util-to-string@3.0.1:
dependencies:
'@types/hast': 3.0.4
hast-util-to-text@4.0.2: hast-util-to-text@4.0.2:
dependencies: dependencies:
'@types/hast': 3.0.4 '@types/hast': 3.0.4
@ -11040,6 +11074,16 @@ snapshots:
dependencies: dependencies:
'@types/mdast': 4.0.4 '@types/mdast': 4.0.4
mdast-util-toc@7.1.0:
dependencies:
'@types/mdast': 4.0.4
'@types/ungap__structured-clone': 1.2.0
'@ungap/structured-clone': 1.3.0
github-slugger: 2.0.0
mdast-util-to-string: 4.0.0
unist-util-is: 6.0.0
unist-util-visit: 5.0.0
merge-stream@2.0.0: {} merge-stream@2.0.0: {}
merge2@1.4.1: {} merge2@1.4.1: {}
@ -11718,6 +11762,14 @@ snapshots:
hast-util-raw: 9.1.0 hast-util-raw: 9.1.0
vfile: 6.0.3 vfile: 6.0.3
rehype-slug@6.0.0:
dependencies:
'@types/hast': 3.0.4
github-slugger: 2.0.0
hast-util-heading-rank: 3.0.0
hast-util-to-string: 3.0.1
unist-util-visit: 5.0.0
rehype-stringify@10.0.1: rehype-stringify@10.0.1:
dependencies: dependencies:
'@types/hast': 3.0.4 '@types/hast': 3.0.4
@ -11772,6 +11824,11 @@ snapshots:
mdast-util-to-markdown: 2.1.2 mdast-util-to-markdown: 2.1.2
unified: 11.0.5 unified: 11.0.5
remark-toc@9.0.0:
dependencies:
'@types/mdast': 4.0.4
mdast-util-toc: 7.1.0
repeat-string@1.6.1: {} repeat-string@1.6.1: {}
require-directory@2.1.1: {} require-directory@2.1.1: {}

View file

@ -88,7 +88,13 @@ const dateFormatted = formatDate(pubDate)
</a </a
> >
<p class="content"> <p class="content">
作者: {frontmatter.author} 发表日期:{dateFormatted} 作者:
{
typeof frontmatter.author === "object"
? <a href={frontmatter.author.url} target="_blank" rel="noopener">{frontmatter.author.name}</a>
: frontmatter.author
}
,发表日期:{dateFormatted}
</p> </p>
</div> </div>
</div> </div>

View file

@ -5,7 +5,7 @@ pubDate: 2025-06-10
description: "🤪" description: "🤪"
author: author:
name: "小明" name: "小明"
link: "https://m1ng.space/" url: "https://m1ng.space/"
cover: cover:
url: "https://i.pinimg.com/736x/6f/00/d7/6f00d73e426549d0f5b1bb873bf2015f.jpg" url: "https://i.pinimg.com/736x/6f/00/d7/6f00d73e426549d0f5b1bb873bf2015f.jpg"
alt: "cover" alt: "cover"