javascript - External CSS in Node JS -
i trying bind style external css have in project directory.
my app structre looks this:
webdtu app.js public/ stylesheets/ style.css avgrund.css animate.css views/ index.jade userhome.jade .... ....
my userhome.jade
:
doctype html html head title mqtt chat application script(type='text/javascript', src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js') link(rel='stylesheet', href='http://fonts.googleapis.com/css?family=lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic', type='text/css') link(rel='stylesheet', href='../public/stylesheets/animate.css', type='text/css') link(rel='stylesheet', href='../public/stylesheets/style.css', type='text/css') link(rel='stylesheet', href='../public/stylesheets/avgrund.css', type='text/css') body .avgrund-contents header h1 hi #{title} .pr.center.wrapper .cf.pr.chat.animate .pa.chat-shadow .....
my app.js
:
var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieparser = require('cookie-parser'); var bodyparser = require('body-parser'); var mongoose = require('mongoose'); var mongo = require('mongodb'); var monk = require('monk'); var db = monk('localhost:27017/webdtu'); var routes = require('./routes/index'); var users = require('./routes/users'); var app = express(); // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); // uncomment after placing favicon in /public //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); app.use(logger('dev')); app.use(bodyparser.json()); app.use(bodyparser.urlencoded({ extended: false })); app.use(cookieparser()); app.use(express.static(path.join(__dirname, 'public'))); app.use(function(req,res,next){ req.db = db; next(); }); app.use('/', routes); // catch 404 , forward error handler app.use(function(req, res, next) { var err = new error('not found'); err.status = 404; next(err); }); // error handlers // development error handler // print stacktrace if (app.get('env') === 'development') { app.use(function(err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: err }); }); } // production error handler // no stacktraces leaked user app.use(function(err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: {} }); }); module.exports = app;
my problem somehow href='../public/stylesheets/animate.css'
not load correct file project directory , not understand why not work.
then in html use
href='/public/stylesheets/animate.css'
Comments
Post a Comment