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

Invalid top-level expression #29

Open
FilmKnurd opened this issue Sep 20, 2015 · 10 comments
Open

Invalid top-level expression #29

FilmKnurd opened this issue Sep 20, 2015 · 10 comments

Comments

@FilmKnurd
Copy link

This is not a problem with this plugin, but I'm posting this in case someone else runs into this issue.

Compilation failed for me with

Metalsmith · [metalsmith-sass] Error: invalid top-level expression -> /Users/veritas/www/hannahsstudio.com/src/styles/style.scss:1:1

I thought the issue was with the SASS file or with this plugin. I finally looked at the plugin source code and saw that the data option was set to the file contents. It turns out all my files were being processed by the layouts plugin, so the data option had a bunch of HTML templating inside it. I just had to set the patterns option in the layouts plugin to only process markdown files.

This might be a good note to put in the documentation.

@karneaud
Copy link

thanks for this as I was going nuts trying to figure out what was wrong

@ismay
Copy link

ismay commented Sep 21, 2015

@karneaud , @FilmKnurd Were you using the default option? Because if you're not using that, metalsmith-layouts won't process anything unless it has the layout key in the file's frontmatter.

@karneaud
Copy link

Ohhh...ok

@ismay
Copy link

ismay commented Sep 21, 2015

@karneaud So what was it, were you using the default option? (just so I, and others encountering this issue know)

@karneaud
Copy link

Sorry, There was a lot of issues I was dealing with at the time and admit I cannot remember how i solved it. I think it had to do with my files reference and the metalsmith-ignore. I do not believe however that it was because of the default option

@ismay
Copy link

ismay commented Sep 21, 2015

Then it shouldn't be a metalsmith-layouts related issue. It'll only process everything if the default option has been set. Otherwise only a layouts key will trigger it. If it's behaving otherwise let me know, but so far I don't have any evidence that this is a bug.

@marr
Copy link

marr commented Nov 19, 2015

I am hitting this issue as well. Can't seem to figure out how to avoid setting layout in the front-matter by utilizing metalsmith-layouts default property.
This setup works but it requires the layout property in my article: https://github.com/marr/metalsmith-project/blob/master/build.js

I would like to avoid that and rely on the default with a build file like this:https://gist.github.com/anonymous/379d3baaee3503050fdc however it errors out with:

/Users/dmarr/src/dmarr.io/build.js:19
      throw err;
      ^

Error: [metalsmith-sass] Error: Invalid CSS after "": expected 1 selector or at-rule, was "<!DOCTYPE html>" -> /Users/dmarr/src/dmarr.io/src/scss/styles.scss:1:1
    at Object.callback (/Users/dmarr/src/dmarr.io/node_modules/metalsmith-sass/lib/index.js:69:23)
    at options.error (/Users/dmarr/src/dmarr.io/node_modules/node-sass/lib/index.js:280:32)

@ismay
Copy link

ismay commented Nov 21, 2015

Please move any discussion related to metalsmith-layouts to the metalsmith-layouts repo. Feel free to open an issue there.

To answer your question @marr :

This setup works but it requires the layout property in my article: https://github.com/marr/metalsmith-project/blob/master/build.js

With your setup metalsmith-layouts will indeed only process files that have a layout set in the frontmatter. If you're going to use the default option it will apply a layout to everything. If you don't want that you can filter with the pattern option.

I'll add a note in the readme for the use of the default key and hope that this solves it. If not feel free to open an issue: https://github.com/superwolff/metalsmith-layouts

@marr
Copy link

marr commented Nov 23, 2015

Thanks ismay, I will try the pattern prop, although it does seem a little counterintuitive. I guess since my layout is .html, I would set the pattern to just '.html'. From the error and your explanation above, I'd think it was still a -sass issue, since the error is coming from metalsmith-sass and prints "Invalid CSS".

@ismay
Copy link

ismay commented Nov 23, 2015

I'd use '*/.html', otherwise it won't match anything.

On 23 Nov 2015, at 19:16, David Marr [email protected] wrote:

Thanks ismay, I will try the pattern prop, although it does seem a little counterintuitive. I guess since my layout is .html, I would set the pattern to just '.html'. From the error and your explanation above, I'd think it was still a -sass issue, since the error is coming from metalsmith-sass and prints "Invalid CSS".


Reply to this email directly or view it on GitHub.

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