This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assets and media | |
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|heic|webp|svgz?|mp3|m4a|aac|ogg|wav|mp4|mov|webm|mpe?g|avi|ogv|wmv|woff2?)$ { | |
try_files $uri $uri/ /index.php?$query_string; | |
add_header Cache-Control "public, max-age=31536000, immutable"; | |
access_log off; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createRouterScroller } from 'vue-router-better-scroller' | |
interface ScrollPositionCoordinates { | |
behavior?: ScrollOptions['behavior'] | |
left?: number | |
top?: number | |
} | |
export default defineNuxtPlugin((nuxtApp) => { | |
nuxtApp.vueApp.use( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SPECIAL_CHAR_RE = /[^A-Za-z0-9]/g | |
const LOWERCASE_RE = /[a-z]/g | |
const UPPERCASE_RE = /[A-Z]/g | |
const NUMBER_RE = /[0-9]/g | |
const SCORE_MAP = ['risky', 'guessable', 'weak', 'safe', 'secure'] as const | |
export function getPasswordStrength(input: string | number) { | |
const score = typeof input === 'string' ? getPasswordScore(input) : input | |
return SCORE_MAP[score] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* First, create a type helper that represents | |
* the Result that we'll get from our safe function | |
*/ | |
type Result<T> = | |
| { | |
ok: true; | |
value: T; | |
} | |
| { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<span | |
v-if="icon" | |
:class="[ | |
'children-[svg]:h-full children-[svg]:w-full', | |
defaultStyles && 'inline-block h-[1em] w-[1em] align-middle', | |
]" | |
v-html="icon" | |
/> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FormData as _FormData } from 'formdata-polyfill/esm.min.js' | |
export async function formDataToObject(formData: FormData) { | |
const obj: Record<string, any> = {} | |
for (const [key, value] of formData.entries()) { | |
if (value instanceof Blob) { | |
obj[key] = { | |
__type: 'blob', | |
...(await serializeBlob(value)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a schema for a post | |
const Post = z.object({ | |
slug: z.string(), | |
content: z.string(), | |
}); | |
// Create a schema for a post collection | |
const Posts = z.array(Post); | |
// Fetch a post by slug with the correct typed response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useStorageAsync } from "@vueuse/core"; | |
import { get, set, del } from "idb-keyval"; | |
export const STORAGE_KEY_PREFIX = "app.session."; | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
export function useIdbStorage<T = any>(key: string, initialValue: T) { | |
return useStorageAsync(`${STORAGE_KEY_PREFIX}${key}`, initialValue, { | |
async getItem(key: string) { | |
return (await get<string>(key)) ?? null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media (hover: none) and (pointer: coarse) { | |
/* Touchscreens */ | |
} | |
@media (hover: none) and (pointer: fine) { | |
/* Stylus */ | |
} | |
@media (hover: hover) and (pointer: coarse) { | |
/* Controllers */ | |
} | |
@media (hover: hover) and (pointer: fine) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
panel.plugin("distantnative/block-accordion", { | |
blocks: { | |
accordion: { | |
methods: { | |
addRow() { | |
this.content.rows.push({ summary: "", detail: "" }); | |
this.update({ rows: this.content.rows }); | |
}, | |
removeRow(index) { | |
this.content.rows.splice(index, 1); |