Skip to content

Commit

Permalink
feat: add remix post + disable writing status
Browse files Browse the repository at this point in the history
  • Loading branch information
pheralb committed May 28, 2024
1 parent 8597917 commit 8571efd
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/posts/clack-prompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: How to create a cli with clack
description: Learn how to create a beautiful CLI to generate projects with custom templates using clack/prompts & Typescript.
date: '2024-4-21'
category: 'Tutorial'
writing: true
writing: false
published: true
---

Expand Down
116 changes: 116 additions & 0 deletions src/posts/remix.md
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 πŸš€βœ¨

0 comments on commit 8571efd

Please sign in to comment.