Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: uwu mode for Hono website #321

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.