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

Using static CSS in Fresh #492

Closed
tsklxiv opened this issue Jul 10, 2022 · 4 comments
Closed

Using static CSS in Fresh #492

tsklxiv opened this issue Jul 10, 2022 · 4 comments

Comments

@tsklxiv
Copy link

tsklxiv commented Jul 10, 2022

Hi there!

I am building a website for my classless CSS style, Subreply CSS.

As such, I wanted to use the CSS to style the website, but I can't find any way to use them in Fresh. Is there any way to import a static CSS file into Fresh?

@harrel56
Copy link
Contributor

Hope it helps: #476 (comment)

@EdAyers
Copy link

EdAyers commented Jul 10, 2022

Working example to save some comment trawling:

Put your stylesheet (eg mystyles.css) in static/, and put this in routes/_app.tsx.

// routes/_app.tsx
/** @jsx h */
/** @jsxFrag Fragment */
import { Fragment, h } from "preact";
import { Head, asset } from "$fresh/runtime.ts";
import { AppProps } from "$fresh/server.ts";

export default function App(props: AppProps) {
  return (
    <>
      <Head>
        <link href={asset('/mystyles.css')} rel="stylesheet"/>
      </Head>
      <props.Component />
    </>
  );
}

I couldn't find any docs for _app.tsx, I guess it is where you put the top level wrapper for your pages?

@harrel56
Copy link
Contributor

I couldn't find any docs for _app.tsx, I guess it is where you put the top level wrapper for your pages?

Yes, routes/_app.tsx is correct. As for docs there is issue for that #491

@lucacasonato
Copy link
Member

Closing as this seems resolved.

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

No branches or pull requests

4 participants