-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add remix post + disable writing status
- Loading branch information
Showing
2 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
title: Remix v2 Snippets | ||
description: Code snippets for Remix. | ||
date: '2024-4-28' | ||
category: 'Snippets' | ||
writing: false | ||
published: true | ||
--- | ||
|
||
## Import styles | ||
|
||
If you're using Remix with **Vite**, you can import styles like this: | ||
|
||
```jsx | ||
import type { LinksFunction } from "@remix-run/node"; | ||
|
||
import stylesheet from "@/styles/globals.css?url"; // π | ||
|
||
export const links: LinksFunction = () => [ | ||
{ rel: "stylesheet", href: stylesheet }, | ||
]; | ||
``` | ||
|
||
and that the Vite compiler does not interpret `.css` files as paths: | ||
|
||
```jsx | ||
export default defineConfig({ | ||
plugins: [ | ||
remix({ | ||
ignoredRouteFiles: ["**/*.css"], // π | ||
}), | ||
], | ||
}); | ||
``` | ||
|
||
## Routes | ||
|
||
A guide for managing routes in Remix v2: | ||
|
||
```bash | ||
π app | ||
π routes | ||
| - βοΈ app.tsx -> layout that wraps all the paths of /app. You have to add <Outlet /> from @remix-run/react. | ||
| - π¦ action.set-theme.ts -> /action/set-theme. Exports a server-side ``action``. Ideal for use with <Form /> from @remix-run/react. | ||
| - βοΈ app._index.tsx -> /app (main page) | ||
| - βοΈ app.settings.tsx -> /app/settings | ||
| - βοΈ app.$username.tsx -> /app/pheralb o /app/midudev. π‘ | ||
| - βοΈ root.tsx -> layout that wraps the entire application. | ||
``` | ||
|
||
- π‘ To obtain the *$username*: [remix.run/docs/en/main/route/loader#params](https://remix.run/docs/en/main/route/loader#params) | ||
|
||
## Install & configure Tailwind CSS with Prettier | ||
|
||
1. Install Tailwind CSS, Prettier & Autoprefixer: | ||
|
||
```bash | ||
pnpm i tailwindcss prettier prettier-plugin-tailwindcss autoprefixer -E -D | ||
``` | ||
|
||
2. Create a `global.css` or `styles.css` in the `app/` folder: | ||
|
||
```css | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
``` | ||
|
||
3. Import the styles in the `app/routes/root.tsx`: | ||
|
||
```jsx | ||
import type { LinksFunction } from "@remix-run/node"; | ||
|
||
import stylesheet from "@/styles/globals.css?url"; // or styles.css π | ||
|
||
export const links: LinksFunction = () => [ | ||
{ rel: "stylesheet", href: stylesheet }, | ||
]; | ||
``` | ||
|
||
4. Create a `tailwind.config.ts` file: | ||
|
||
```bash | ||
npx tailwindcss init --ts | ||
``` | ||
|
||
5. In the `tailwind.config.ts` file, add the following: | ||
|
||
```ts | ||
export default { | ||
content: ['./app/**/*.{js,jsx,ts,tsx}'], // π | ||
... | ||
} satisfies Config | ||
``` | ||
|
||
6. Create a `postcss.config.js` file: | ||
|
||
```js | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
}; | ||
``` | ||
|
||
7. Create a `prettier.config.js` file: | ||
|
||
```js | ||
module.exports = { | ||
plugins: ['prettier-plugin-tailwindcss'], | ||
... | ||
}; | ||
``` | ||
|
||
Ready πβ¨ |