修改Copyright.astro时的一些报错,有些疑问🤔 #145
Answered
by
yizhixiaokong
yizhixiaokong
asked this question in
Q&A
|
我想参考 https://astro-pure.js.org/docs/advanced/customize#swizzling 部分修改 Copyright.astro 中的一些样式。 在src/components/pages/Copyright.astro 复制了node_modules/astro-pure/components/pages/Copyright.astro 并且修改了依赖,具体如下: ---
import type { CollectionKey, InferEntrySchema } from 'astro:content'
import config from 'virtual:config'
- import { cn, getFormattedDate } from '../../utils'
- import { QRCode } from '../advanced'
- import { Icon } from '../user'
+ import { QRCode } from 'astro-pure/advanced'
+ import { Icon } from 'astro-pure/user'
+ import { cn, getFormattedDate } from 'astro-pure/utils'
......
<div class='mx-6 rounded-b-xl border border-t-0 px-3 pb-1.5 pt-1 sm:mx-8 sm:px-4'>
<a
href='/projects#sponsorship'
class='flex items-center justify-between text-muted-foreground no-underline'
target='_blank'
>
- <span>Buy me a cup of coffee ☕.</span>
+ <span>Buy me a cup of coffeeeeeeeeeeee ☕.</span>
<Icon class='box-content size-5 p-1' name='receive-money' />
</a>
......
<script>
- import { showToast } from '../../utils'
+ import { showToast } from 'astro-pure/utils'
// Copy link
const copyLink = document.getElementById('copy-link')
......对应src/layouts/BlogPost.astro 引用修改: - import { ArticleBottom, Copyright, Hero } from 'astro-pure/components/pages'
+ import Copyright from '@/components/pages/Copyright.astro'
+ import { ArticleBottom, Hero } from 'astro-pure/components/pages'然后 这个是什么 |
Answered by
yizhixiaokong
Mar 13, 2026
Replies: 2 comments
|
我有试一下把utils整个copy过来,然后好像把 <script>
- import { showToast } from 'astro-pure/utils'
+ import { showToast } from '@/utils'
// Copy link
const copyLink = document.getElementById('copy-link')
copyLink?.addEventListener('click', () => {
navigator.clipboard.writeText(window.location.href)
// Show toast
showToast({ message: 'Link copied!' })
})
......
</script>对这方面确实不太懂😂 |
0 replies
Answer selected by
cworld1
|
virtual:config 是 vite 自定义模块,应该是可以随便用的才对。你那怎么出现问题的没看懂,不过能解决问题就好👍 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我有试一下把utils整个copy过来,然后好像把
<script>中的import改了就没这个报错了。对这方面确实不太懂😂