diff --git a/docs/config/theme.md b/docs/config/theme.md index 44ee060f..621fc48c 100644 --- a/docs/config/theme.md +++ b/docs/config/theme.md @@ -392,31 +392,55 @@ export default defineUserConfig({ 将作为 图标链接 展示在 导航栏最右侧。 - 图标可选值: - - `'github'` - - `'gitlab'` - - `'npm'` - - `'docker'` - - `'discord'` - - `'telegram'` - - `'facebook'` - - `'instagram'` - - `'linkedin'` - - `'mastodon'` - - `'slack'` - - `'twitter'` - - `'x'` - - `'youtube'` - - `'juejin'` - - `'stackoverflow'` - - `'qq'` - - `'weibo'` - - `'bilibili'` - - `'zhihu'` - - `'douban'` - - `'steam'` - - `'xbox'` - - `{ svg: string, name?: string }`: 自定义图标,传入 svg 源码字符串,可选 `name` 字段,用于配置 [`navbarSocialInclude`](#navbarsocialinclude) + 支持 [Iconify](https://icon-sets.iconify.design/) 任意图标,直接使用 iconify name 即可自动加载。 + + 对于 `simple-icons` 集合下的图标,可以省略 `simple-icons:` 前缀,如 `simple-icons:github` 可以简写为 `github` + + 常见的社交图标示例: + + ::: flex + +
+ + - discord ::simple-icons:discord:: + - telegram ::simple-icons:telegram:: + - facebook ::simple-icons:facebook:: + - github ::simple-icons:github:: + - instagram ::simple-icons:instagram:: + - linkedin ::simple-icons:linkedin:: + - mastodon ::simple-icons:mastodon:: + - npm ::simple-icons:npm:: + - slack ::simple-icons:slack:: + - twitter ::simple-icons:twitter:: + - x ::simple-icons:x:: + - youtube ::simple-icons:youtube:: + - bluesky ::simple-icons:bluesky:: + - tiktok ::simple-icons:tiktok:: + +
+ + - qq ::simple-icons:qq:: + - weibo ::simple-icons:sinaweibo:: + - bilibili ::simple-icons:bilibili:: + - gitlab ::simple-icons:gitlab:: + - docker ::simple-icons:docker:: + - juejin ::simple-icons:juejin:: + - zhihu ::simple-icons:zhihu:: + - douban ::simple-icons:douban:: + - steam ::simple-icons:steam:: + - stackoverflow ::simple-icons:stackoverflow:: + - xbox ::simple-icons:xbox:: + - kuaishou ::simple-icons:kuaishou:: + - twitch ::simple-icons:twitch:: + - xiaohongshu ::simple-icons:xiaohongshu:: + +
+ + ::: + + [你可以在这里查看 **simple-icons** 所有可用图标](https://icon-sets.iconify.design/simple-icons/){.readmore} + + 如果 **Iconify** 无法满足你的需求,可以传入 `{ svg: string, name?: string }`的格式,使用自定义图标,传入 svg 源码字符串,可选 `name` 字段,用于配置 [`navbarSocialInclude`](#navbarsocialinclude) 示例: @@ -424,8 +448,10 @@ export default defineUserConfig({ export default defineUserConfig({ theme: plumeTheme({ social: [ + // 使用 iconify name { icon: 'github', link: 'https://github.com/zhangsan' }, { + // 使用自定义图标 icon: { svg: 'xxxxx', name: 'xxx' }, link: 'https://xxx.com' }, diff --git a/docs/en/config/theme.md b/docs/en/config/theme.md index d4670552..7f6e9265 100644 --- a/docs/en/config/theme.md +++ b/docs/en/config/theme.md @@ -397,31 +397,57 @@ export default defineUserConfig({ Displayed as icon links on the far right of the navbar. - Available icon options: - - `'github'` - - `'gitlab'` - - `'npm'` - - `'docker'` - - `'discord'` - - `'telegram'` - - `'facebook'` - - `'instagram'` - - `'linkedin'` - - `'mastodon'` - - `'slack'` - - `'twitter'` - - `'x'` - - `'youtube'` - - `'juejin'` - - `'stackoverflow'` - - `'qq'` - - `'weibo'` - - `'bilibili'` - - `'zhihu'` - - `'douban'` - - `'steam'` - - `'xbox'` - - `{ svg: string, name?: string }`: Custom icon, pass the SVG source string. The optional `name` field is used to configure [`navbarSocialInclude`](#navbarsocialinclude). + Supports any icon from [Iconify](https://icon-sets.iconify.design/). Simply use the iconify name to load it automatically. + + For icons in the `simple-icons` collection, you can omit the `simple-icons:` prefix. + For example, `simple-icons:github` can be abbreviated as `github`. + + Examples of common social icons: + + ::: flex + +
+ + - discord ::simple-icons:discord:: + - telegram ::simple-icons:telegram:: + - facebook ::simple-icons:facebook:: + - github ::simple-icons:github:: + - instagram ::simple-icons:instagram:: + - linkedin ::simple-icons:linkedin:: + - mastodon ::simple-icons:mastodon:: + - npm ::simple-icons:npm:: + - slack ::simple-icons:slack:: + - twitter ::simple-icons:twitter:: + - x ::simple-icons:x:: + - youtube ::simple-icons:youtube:: + - bluesky ::simple-icons:bluesky:: + - tiktok ::simple-icons:tiktok:: + +
+ + - qq ::simple-icons:qq:: + - weibo ::simple-icons:sinaweibo:: + - bilibili ::simple-icons:bilibili:: + - gitlab ::simple-icons:gitlab:: + - docker ::simple-icons:docker:: + - juejin ::simple-icons:juejin:: + - zhihu ::simple-icons:zhihu:: + - douban ::simple-icons:douban:: + - steam ::simple-icons:steam:: + - stackoverflow ::simple-icons:stackoverflow:: + - xbox ::simple-icons:xbox:: + - kuaishou ::simple-icons:kuaishou:: + - twitch ::simple-icons:twitch:: + - xiaohongshu ::simple-icons:xiaohongshu:: + +
+ + ::: + + [You can view all available icons for **simple-icons** here](https://icon-sets.iconify.design/simple-icons/){.readmore} + + If **Iconify** does not meet your needs, you can pass in the format `{ svg: string, name?: string }` to use a custom icon. + Pass in the SVG source code string, with the optional `name` field for configuring [`navbarSocialInclude`](#navbarsocialinclude). Example: @@ -429,8 +455,10 @@ Example: export default defineUserConfig({ theme: plumeTheme({ social: [ + // use iconify name { icon: 'github', link: 'https://github.com/zhangsan' }, { + // use custom icon icon: { svg: 'xxxxx', name: 'xxx' }, link: 'https://xxx.com' }, diff --git a/docs/en/guide/quick-start/collection-post.md b/docs/en/guide/quick-start/collection-post.md index 97407678..73e800e1 100644 --- a/docs/en/guide/quick-start/collection-post.md +++ b/docs/en/guide/quick-start/collection-post.md @@ -450,9 +450,15 @@ export default defineUserConfig({ type: 'post', dir: 'blog', title: 'Blog', - // [!code hl:4] + // [!code hl:9] social: [ - { icon: 'github', link: 'https://github.com/pengzhanbo' }, + // use iconify name + { icon: 'github', link: 'https://github.com/zhangsan' }, + { + // use custom icon + icon: { svg: 'xxxxx', name: 'xxx' }, + link: 'https://xxx.com' + }, ], } ] @@ -471,9 +477,15 @@ export default defineThemeConfig({ type: 'post', dir: 'blog', title: 'Blog', - // [!code hl:4] + // [!code hl:9] social: [ - { icon: 'github', link: 'https://github.com/pengzhanbo' }, + // use iconify name + { icon: 'github', link: 'https://github.com/zhangsan' }, + { + // use custom icon + icon: { svg: 'xxxxx', name: 'xxx' }, + link: 'https://xxx.com' + }, ], } ] @@ -482,43 +494,58 @@ export default defineThemeConfig({ ::: -### Built-in Icon Library +Supports any icon from [Iconify](https://icon-sets.iconify.design/). Simply use the iconify name to load it automatically. + +For icons in the `simple-icons` collection, the `simple-icons:` prefix can be omitted. +For example, `simple-icons:github` can be abbreviated as `github`. + +Examples of common social icons: ::: flex
-- discord -- telegram -- facebook -- github -- instagram -- linkedin -- mastodon -- npm -- slack -- twitter -- x -- youtube +- discord ::simple-icons:discord:: +- telegram ::simple-icons:telegram:: +- facebook ::simple-icons:facebook:: +- github ::simple-icons:github:: +- instagram ::simple-icons:instagram:: +- linkedin ::simple-icons:linkedin:: +- mastodon ::simple-icons:mastodon:: +- npm ::simple-icons:npm:: +- slack ::simple-icons:slack:: +- twitter ::simple-icons:twitter:: +- x ::simple-icons:x:: +- youtube ::simple-icons:youtube:: +- bluesky ::simple-icons:bluesky:: +- tiktok ::simple-icons:tiktok::
-- qq -- weibo -- bilibili -- gitlab -- docker -- juejin -- zhihu -- douban -- steam -- stackoverflow -- xbox +- qq ::simple-icons:qq:: +- weibo ::simple-icons:sinaweibo:: +- bilibili ::simple-icons:bilibili:: +- gitlab ::simple-icons:gitlab:: +- docker ::simple-icons:docker:: +- juejin ::simple-icons:juejin:: +- zhihu ::simple-icons:zhihu:: +- douban ::simple-icons:douban:: +- steam ::simple-icons:steam:: +- stackoverflow ::simple-icons:stackoverflow:: +- xbox ::simple-icons:xbox:: +- kuaishou ::simple-icons:kuaishou:: +- twitch ::simple-icons:twitch:: +- xiaohongshu ::simple-icons:xiaohongshu::
::: +[You can view all available icons of **simple-icons** here](https://icon-sets.iconify.design/simple-icons/){.readmore} + +If **Iconify** cannot meet your needs, you can pass in the format `{ svg: string, name?: string }` +to use custom icons by providing the SVG source code string. + ## Article Cover Configuration The article list page supports cover image display with various layout and size options. diff --git a/docs/guide/quick-start/collection-post.md b/docs/guide/quick-start/collection-post.md index 110e5aae..232b77a2 100644 --- a/docs/guide/quick-start/collection-post.md +++ b/docs/guide/quick-start/collection-post.md @@ -429,7 +429,7 @@ export default defineThemeConfig({ ## 社交链接 -个人信息区域支持社交链接配置,未配置时继承[主题默认 social 设置](../../config/theme.md#social)。 +个人信息区域支持社交链接配置,未配置时继承 [主题默认 social 设置](../../config/theme.md#social)。 ::: code-tabs#config @@ -446,9 +446,15 @@ export default defineUserConfig({ type: 'post', dir: 'blog', title: '博客', - // [!code hl:4] + // [!code hl:9] social: [ - { icon: 'github', link: 'https://github.com/pengzhanbo' }, + // 使用 iconify name + { icon: 'github', link: 'https://github.com/zhangsan' }, + { + // 使用自定义图标 + icon: { svg: 'xxxxx', name: 'xxx' }, + link: 'https://xxx.com' + }, ], } ] @@ -467,9 +473,15 @@ export default defineThemeConfig({ type: 'post', dir: 'blog', title: '博客', - // [!code hl:4] + // [!code hl:9] social: [ - { icon: 'github', link: 'https://github.com/pengzhanbo' }, + // 使用 iconify name + { icon: 'github', link: 'https://github.com/zhangsan' }, + { + // 使用自定义图标 + icon: { svg: 'xxxxx', name: 'xxx' }, + link: 'https://xxx.com' + }, ], } ] @@ -478,43 +490,56 @@ export default defineThemeConfig({ ::: -### 内置图标库 +支持 [Iconify](https://icon-sets.iconify.design/) 任意图标,直接使用 iconify name 即可自动加载。 + +对于 `simple-icons` 集合下的图标,可以省略 `simple-icons:` 前缀,如 `simple-icons:github` 可以简写为 `github` + +常见的社交图标示例: ::: flex
-- discord -- telegram -- facebook -- github -- instagram -- linkedin -- mastodon -- npm -- slack -- twitter -- x -- youtube +- discord ::simple-icons:discord:: +- telegram ::simple-icons:telegram:: +- facebook ::simple-icons:facebook:: +- github ::simple-icons:github:: +- instagram ::simple-icons:instagram:: +- linkedin ::simple-icons:linkedin:: +- mastodon ::simple-icons:mastodon:: +- npm ::simple-icons:npm:: +- slack ::simple-icons:slack:: +- twitter ::simple-icons:twitter:: +- x ::simple-icons:x:: +- youtube ::simple-icons:youtube:: +- bluesky ::simple-icons:bluesky:: +- tiktok ::simple-icons:tiktok::
-- qq -- weibo -- bilibili -- gitlab -- docker -- juejin -- zhihu -- douban -- steam -- stackoverflow -- xbox +- qq ::simple-icons:qq:: +- weibo ::simple-icons:sinaweibo:: +- bilibili ::simple-icons:bilibili:: +- gitlab ::simple-icons:gitlab:: +- docker ::simple-icons:docker:: +- juejin ::simple-icons:juejin:: +- zhihu ::simple-icons:zhihu:: +- douban ::simple-icons:douban:: +- steam ::simple-icons:steam:: +- stackoverflow ::simple-icons:stackoverflow:: +- xbox ::simple-icons:xbox:: +- kuaishou ::simple-icons:kuaishou:: +- twitch ::simple-icons:twitch:: +- xiaohongshu ::simple-icons:xiaohongshu::
::: +[你可以在这里查看 **simple-icons** 所有可用图标](https://icon-sets.iconify.design/simple-icons/){.readmore} + +如果 **Iconify** 无法满足你的需求,可以传入 `{ svg: string, name?: string }`的格式,使用自定义图标,传入 svg 源码字符串。 + ## 文章封面配置 文章列表页支持封面图展示,提供多种布局和尺寸选项。 diff --git a/theme/src/client/components/VPIconify.vue b/theme/src/client/components/VPIconify.vue index 0a427437..dbbc95d8 100644 --- a/theme/src/client/components/VPIconify.vue +++ b/theme/src/client/components/VPIconify.vue @@ -3,7 +3,7 @@ import type { IconifyIcon } from '@iconify/vue/offline' import { loadIcon } from '@iconify/vue' import { Icon as OfflineIcon } from '@iconify/vue/offline' import { computed, ref, watch } from 'vue' -import { useIconsData } from '../composables/index.js' +import { normalizeIconClassname } from '../composables/index.js' defineOptions({ inheritAttrs: false, @@ -20,15 +20,13 @@ const { name, size, color, prefix, extra } = defineProps<{ const icon = ref(null) const loaded = ref(false) -const iconsData = useIconsData() - const iconName = computed(() => { if (name.includes(':')) return name return prefix ? `${prefix}:${name}` : name }) -const localIconName = computed(() => iconsData.value[iconName.value]) +const localIconName = computed(() => normalizeIconClassname(iconName.value)) async function loadRemoteIcon() { if (icon.value) diff --git a/theme/src/client/components/VPSocialLink.vue b/theme/src/client/components/VPSocialLink.vue index 26dbf3bc..bc5422e3 100644 --- a/theme/src/client/components/VPSocialLink.vue +++ b/theme/src/client/components/VPSocialLink.vue @@ -1,6 +1,8 @@ @@ -19,9 +33,12 @@ const svg = computed(() => { + :aria-label="label" + :title="label" + target="_blank" rel="noopener" + > + +