Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Path to public assets not working #4

Closed
adamsilver opened this issue May 7, 2017 · 0 comments
Closed

Path to public assets not working #4

adamsilver opened this issue May 7, 2017 · 0 comments

Comments

@adamsilver
Copy link

adamsilver commented May 7, 2017

I have configured fractal to use Nunjucks and to use static assets:

'use strict';

const fractal = module.exports = require('@frctl/fractal').create();

fractal.web.set('static.path', __dirname+'/public');

fractal.set('project.title', 'FooCorp Component Library');
fractal.docs.set('path', __dirname + '/src/docs');
fractal.docs.engine('@frctl/nunjucks');
fractal.components.set('path', __dirname + '/src/components');
fractal.components.engine('@frctl/nunjucks');
fractal.components.set('ext', '.html');

And I have an alert component inside the following directory structure:

  /src
    /components
      /alert
        _preview.html
        alert.html
        alert.config.json
        alert.css
        alert.js
    /public
      /css
        demo.css

The _preview.html contains this HTML:

<!DOCTYPE html>
<html>
	<head>
	    <meta charset="utf-8">
	    <!-- doesn't work -->
	    <link media="all" rel="stylesheet" href="{{ '/public/css/demos.css' | path }}">
	    <!-- doesn't work -->
	    <link media="all" rel="stylesheet" href="{{ '/css/demos.css' | path }}">

	    <!-- Does work but have to put the word raw in -->
	    <link media="all" rel="stylesheet" href="{{ '/components/raw/alert/alert.css' | path }}">
	    <title>Preview Layout</title>
	</head>
	<body>

		{{ yield }}

		<script src="{{ '/components/raw/alert/alert.js' | path }}">
	</body>
</html>

The problem is both attempts to reference css in the public directory fail.

Also, is it right that I had to specifiy "raw" in the path for the component CSS file?

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

No branches or pull requests

1 participant