Skip to content

Commit

Permalink
feat: uwu mode for Hono website
Browse files Browse the repository at this point in the history
  • Loading branch information
sor4chi committed Apr 30, 2024
1 parent 96dd034 commit 20e4d70
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ export default defineConfig({
},
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2022-present Yusuke Wada & Hono contributors',
copyright:
'Copyright © 2022-present Yusuke Wada & Hono contributors. Logo by @sawaratsuki1004.',
},
nav: [
{ text: 'Docs', link: '/top' },
Expand Down
3 changes: 3 additions & 0 deletions .vitepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { h } from 'vue'
import DefaultTheme from 'vitepress/theme'
import NotFound from './NotFound.vue'
import { enableUwu } from './uwu'
import './custom.css'

enableUwu()

export default {
...DefaultTheme,
Layout() {
Expand Down
46 changes: 46 additions & 0 deletions .vitepress/theme/uwu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Follow: https://github.com/reactjs/react.dev/blob/main/src/pages/_document.tsx
*/

export function enableUwu() {

try {
var preferredUwu
try {
preferredUwu = localStorage.getItem('uwu')
} catch (err) {}

const isUwuValue =
window.location && window.location.search && window.location.search.match(/uwu=(true|false)/)

if (isUwuValue) {
const isUwu = isUwuValue[1] === 'true'
if (isUwu) {
try {
localStorage.setItem('uwu', true)
} catch (err) {}
document.documentElement.classList.add('uwu')
console.log(
'uwu mode enabled. logo credits to @sawaratsuki1004 via https://github.com/SAWARATSUKI/ServiceLogos'
)
} else {
try {
localStorage.removeItem('uwu', false)
} catch (err) {}
}
} else if (preferredUwu) {
document.documentElement.classList.add('uwu')
}
} catch (err) {}

document.addEventListener('DOMContentLoaded', async () => {
var logo
while (!logo) {
await new Promise((resolve) => setTimeout(resolve, 100))
logo = document.querySelector('img.logo')
}
if (document.documentElement.classList.contains('uwu')) {
logo.src = '/images/uwu.png'
}
})
}
Binary file added public/images/uwu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 20e4d70

Please sign in to comment.