Skip to content

Commit

Permalink
Added dynamic favicon configuration. (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Apr 4, 2021
1 parent d575691 commit d986989
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ socials:
#! ---------------------------------------------------------------
site_meta:
cdn: cn
favicon:

#! ---------------------------------------------------------------
#! Plugins
Expand Down
18 changes: 15 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,26 @@ export default defineComponent({
initResizeEvent()
await appStore.fetchConfig().then(() => {
metaStore.addScripts(appStore.themeConfig.site_meta.cdn.prismjs)
// Change the favicon dynamically.
if (appStore.themeConfig.site_meta.favicon !== '') {
const link = document.querySelector("link[rel~='icon']")
if (link)
link.setAttribute('href', appStore.themeConfig.site_meta.favicon)
}
})
}
const copyEventHandler = (event: any) => {
const pagelink = `\n\nRead more at: ${document.location.href}`
if (event.clipboardData) {
event.clipboardData.setData('text', document.getSelection() + pagelink)
event.preventDefault()
if (document.getSelection() instanceof Selection) {
if (document.getSelection()?.toString() !== '' && event.clipboardData) {
event.clipboardData.setData(
'text',
document.getSelection() + pagelink
)
event.preventDefault()
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/models/ThemeConfig.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ export class SiteMeta {
locale: 'en',
prismjs: []
}
favicon: string = ''

/**
* Model class for Site meta settings
Expand Down

0 comments on commit d986989

Please sign in to comment.