diff --git a/astro.config.ts b/astro.config.ts index 7a6a5ae..b8dc28a 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -15,6 +15,7 @@ import { visit } from 'unist-util-visit' import UnoCSS from 'unocss/astro' import { themeConfig } from './src/config' import { langMap } from './src/i18n/config' +import { rehypeCodeCopyButton } from './src/plugins/rehype-code-copy-button.mjs' import { rehypeImgToFigure } from './src/plugins/rehype-img-to-figure.mjs' import { rehypeUnwrapImg } from './src/plugins/rehype-unwrap-img.mjs' import { remarkAdmonitions } from './src/plugins/remark-admonitions.mjs' @@ -78,6 +79,7 @@ export default defineConfig({ rehypePlugins: [ rehypeKatex, rehypeSlug, + rehypeCodeCopyButton, rehypeImgToFigure, rehypeUnwrapImg, // Must be after rehypeImgToFigure [ diff --git a/src/components/Widgets/CodeCopyButton.astro b/src/components/Widgets/CodeCopyButton.astro new file mode 100644 index 0000000..cca8fd3 --- /dev/null +++ b/src/components/Widgets/CodeCopyButton.astro @@ -0,0 +1,63 @@ + diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 9674b29..6c43f11 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -3,6 +3,7 @@ import Button from '@/components/Button.astro' import Footer from '@/components/Footer.astro' import Header from '@/components/Header.astro' import Navbar from '@/components/Navbar.astro' +import CodeCopyButton from '@/components/Widgets/CodeCopyButton.astro' import GithubCard from '@/components/Widgets/GithubCard.astro' import GsapAnimation from '@/components/Widgets/GsapAnimation.astro' import PhotoSwipe from '@/components/Widgets/PhotoSwipe.astro' @@ -44,7 +45,7 @@ const MarginBottom = isPost && themeConfig.comment?.enabled
@@ -55,7 +56,8 @@ const MarginBottom = isPost && themeConfig.comment?.enabled
{showAnimation && }