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

Tailwindcss runs over MDsveX classes? #595

Open
gneyal opened this issue Mar 15, 2024 · 2 comments
Open

Tailwindcss runs over MDsveX classes? #595

gneyal opened this issue Mar 15, 2024 · 2 comments

Comments

@gneyal
Copy link

gneyal commented Mar 15, 2024

Screenshot 2024-03-15 at 15 11 16

In my +layout.svelte file if I comment the import app.css file - MDsveX works fine, but if I keep uncommented MDsveX's is not working properly. That is, a line like
# hello

will just come out as an <h1> element but will look the same as a <p>.

What am I missing?

@github-project-automation github-project-automation bot moved this to Triage + Refine in mdsvex Mar 15, 2024
@Pelps12
Copy link

Pelps12 commented Apr 6, 2024

Use the @apply directives Tailwind offers to generate a class you wrap the mdsvex output in

@TheOtherBrian1
Copy link

Leaving this here in case someone comes across this issue.

STEPS TO SOLVE:

  1. install tailwind typography:

It's a plugin for adding styles to blank HTML, such as what's generated by MDsvex

npm install -D @tailwindcss/typography
  1. Add the tailwind plugin to your tailwind.config.js file
import type { Config } from "tailwindcss";

export default {
  content: ["./src/**/*.{html,js,svelte,ts}"],

  theme: {
    extend: {},
  },
  plugins: [
    require('@tailwindcss/typography'), //<------------- add plugin
  ],
} satisfies Config;
  1. Create a layout file:

This will use the prose class from Tailwind Typography to style your markdown

MarkdownLayout.svelte

<div class=" prose">
	<slot />
</div>
  1. Add your layout file's path to mdsvex in svelte.config.js
//...
mdsvex({
      layout: {
        _: 'src/lib/MarkdownLayout.svelte'
      },
//...
  1. customize your prose class

Tailwind Typography provides many resources to customize it for your app:

It would be great if someone could get this into the main site or a readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage + Refine
Development

No branches or pull requests

3 participants