feat(snippets): introduce reusable code chunks section, add cms support, and fix navbar turkish characters
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: "CSS Reset"
|
||||
language: "css"
|
||||
category: "CSS"
|
||||
description: "Minimal ve modern bir CSS reset şablonu."
|
||||
---
|
||||
|
||||
```css
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html {
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-moz-tab-size: 4;
|
||||
tab-size: 4;
|
||||
}
|
||||
|
||||
body {
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
img, picture, video, canvas, svg {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
input, button, textarea, select {
|
||||
font: inherit;
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: "useLocalStorage Hook"
|
||||
language: "typescript"
|
||||
category: "React Hooks"
|
||||
description: "localStorage ile senkronize çalışan bir React hook'u."
|
||||
---
|
||||
|
||||
```typescript
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
export function useLocalStorage<T>(key: string, initialValue: T) {
|
||||
const [value, setValue] = useState<T>(() => {
|
||||
if (typeof window === "undefined") return initialValue;
|
||||
const stored = localStorage.getItem(key);
|
||||
return stored ? JSON.parse(stored) : initialValue;
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
}, [key, value]);
|
||||
|
||||
return [value, setValue] as const;
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user