GithubHelp home page GithubHelp logo

dbelyaeff / cogear.js Goto Github PK

View Code? Open in Web Editor NEW
309.0 309.0 26.0 352 KB

Modern static websites generator (Node.JS/Webpack)

Home Page: https://cogearjs.org

License: Other

JavaScript 90.33% Smarty 0.59% HTML 0.03% Shell 0.75% Handlebars 0.03% Pug 0.91% Stylus 7.37%
cogear nodejs static-site-generator webpack

cogear.js's People

Contributors

bidhan-a avatar dbelyaeff avatar gormartsen avatar stowball avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cogear.js's Issues

Doesn't cogear.js offer partials?

In order to keep the APP for changes we need a way to reuse content. Partial provides a simple interface for great flexibility and power around reusing pieces of the project

In EJS:

<h1>Hello</h1>
<%- partial("_menu") %>
<body>...</body>

Partial directory:

/project/partials/_menu.ejs

Typescript support

Hi,

first of all many thanks for your great work. Cogear is in my opinion a very good static site generator which I'm currently testing. However is it possible to use Typescript for the JS files? When I change the theme.js file to theme.ts I get a build error.

Many thanks for your feedback,
Matthias

Cannot install Cogear CLI

Hi.
I'm having trouble installing cogear CLI. Apparently, even if I did sudo npm install cogear -g, the install.js script is getting EACCES: permission denied error.

OS: Linux, Elementary 5.0 (Ubuntu 18.04 LTS based)
NodeJS version: v10.16.0
NPM version 6.9.0

Here is the the screen output (debug log is too long to paste here but I can provide it):

npm WARN deprecated [email protected]: 'postcss-cssnext' has been deprecated in favor of 'postcss-preset-env'. Read more at https://moox.io/blog/deprecating-cssnext/
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated [email protected]: Package no longer supported. Contact [email protected] for more info.
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: I wrote this module a very long time ago; you should use something else.
/usr/bin/cogear -> /usr/lib/node_modules/cogear/bin/cogear.js

> [email protected] install /usr/lib/node_modules/cogear/node_modules/node-sass
> node scripts/install.js

Unable to save binary /usr/lib/node_modules/cogear/node_modules/node-sass/vendor/linux-x64-64 : { Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/cogear/node_modules/node-sass/vendor'
    at Object.mkdirSync (fs.js:757:3)
    at sync (/usr/lib/node_modules/cogear/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/usr/lib/node_modules/cogear/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/usr/lib/node_modules/cogear/node_modules/node-sass/scripts/install.js:114:11)
    at Object.<anonymous> (/usr/lib/node_modules/cogear/node_modules/node-sass/scripts/install.js:157:1)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
  errno: -13,
  syscall: 'mkdir',
  code: 'EACCES',
  path: '/usr/lib/node_modules/cogear/node_modules/node-sass/vendor' }

> [email protected] postinstall /usr/lib/node_modules/cogear/node_modules/core-js
> node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> [email protected] postinstall /usr/lib/node_modules/cogear/node_modules/node-sass
> node scripts/build.js

Building: /usr/bin/node /usr/lib/node_modules/cogear/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/bin/node',
gyp verb cli   '/usr/lib/node_modules/cogear/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import sys; print "2.7.15
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 10.16.0
gyp verb command install [ '10.16.0' ]
gyp verb install input version string "10.16.0"
gyp verb install installing version: 10.16.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 10.16.0
gyp verb build dir attempting to create "build" dir: /usr/lib/node_modules/cogear/node_modules/node-sass/build
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/cogear/node_modules/node-sass/build'
gyp ERR! System Linux 4.18.0-20-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/cogear/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /usr/lib/node_modules/cogear/node_modules/node-sass
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN [email protected] requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/cogear/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/sinisap/.npm/_logs/2019-06-01T06_29_24_676Z-debug.log

Any help would be greatly appreciated.

Cheers.

hot reloading not working

Issue

I have installed CogearJS according to documentation and created a new site. The site is running on http://localhost:9000. Changing and saving content, like e.g. within ./public/pages/index.md, and saving has no effect, the running site always shows the old content. The console where cogear is running displays no information about an error or so.

The hot reloading feature seams not to work.

Setup

npm install cogear -g
cogear new mysite
cd mysite
cogear -w

Environment

  • Windows 10 Pro.
  • NodeJS v10.11.0.
  • NPM 6.4.1.
  • Cogear 1.2.17.

Data files and collections

@codEmotion great initiative you started here, thank you!

What are your thoughts on jekyll's data files and collections that provide users with re-usable data stores which then can be used to autogenerate content across pages. Do you plan for something similar in cogear.js?

Документация на русском

Доброго времени суток! Заинтересовало создание сайта и блога. Но не понятно что как работает! Есть ли документация на русском? И будет ли вообще?

Move changelogs from readme

I suggest to move changelog entries from Readme to separate Changelog file for simplicity and code style for project. Changelog after that can be auto-generated by CI, hooks and etc.

Cannot include ejs file in layout

I have the following structure:

.
├── README.md
├── layouts
│   ├── content.ejs
│   ├── hello-world.ejs
│   └── index.pug
├── package.json
├── resources
│   └── favicon.png
├── screenshot.jpg
├── style.styl
└── theme.js

index.pug

extends ../_bootstrap

block body
  include content.ejs

content.ejs

<%- include hello-world.ejs %>

<p>
  Some text...
</p>

hello-world.ejs

<h1>Hello world!</h1>

The result is

<%- include hello-world.ejs %>
Some text...

instead of

Hello world!
Some text...

What's wrong with my setup? 🤔

Pages in JSON format

Can we have pages data stored in JSON file format to be used for templates in the themes section?

By default, CSS should be injected in `<head>` and JS in `<body>`

As best practice, to support server-side rendered pages that don't rely on JavaScript, all <script>s should be inserted before the closing </body>.

Currently, there is only one inject front-matter variable, which doesn't support this. I suggest changing https://github.com/codemotion/cogear.js/blob/master/lib/plugins/build.js#L119 to have a different injectElement for .css and .js files respectively, and perhaps to also support injectCSS and injectJS variables

Adding support to additional template engines

Hi,

I'd like to use the Twig.js engine to render templates in a cogear project. Even though Cogear's plugin support is pretty powerful, I feel it's lacking support for rendering pages with a different template engine.

I did manage to get it working though, this is my plugin:

const Twig = require("twig");

module.exports = {
	apply() {
		cogear.on("webpack.config", () => {
			cogear.pageFormats.push("twig");
		});
		cogear.on("parse.after", data => {
			if (data.vars.format !== ".twig") {
				return data;
			}
			return new Promise((resolve, reject) => {
				data.vars.path = data.vars.path.replace(".twig/index", "");
				data.vars.uri = data.vars.uri.replace(".twig/", ".html");
				Twig.renderFile(data.vars.filePath, data.vars, (err, html) => {
					if (err) {
						console.error(err);
						return reject(err);
					}
					data.parsedContent = html;
					resolve()
				});
			})
		});
	}
};

Some parts feel a bit "hacky", specifically:

  1. cogear.pageFormats.push only worked in the webpack.config event, which feels like I'm using the event for the wrong reason. preload didn't cut it because my plugin's handler is fired after the internal preload plugin creates the files array here

  2. parse.after also feels wrong for the same reason mentioned above.

  3. Having the template go through the "default" engine here seems to be unavoidable. I fear this may cause exceptions in some scenarios if the twig syntax collides with EJS.

  4. I had to transform data.vars.path and data.vars.uri to have the page rendered on a proper location instead of page.twig/index.html. I didn't figure out how this works internally, so I don't know this can be done better.

Some possible solutions I had in mind:

  • put cogear.formatOptions in configuration
  • Find a way to let the parser bypass the default template engines so a plugin can handle the rendering. Maybe introduce a render event and check if data.parsedContent has been set ?

I'd like to contribute code to Cogear itself to improve support for what I'm trying to do, but I could use some feedback before making changes that might get rejected.

Hope to hear from you!

resources?

This documentation is not very clear

https://cogearjs.org/docs/resources

how is supposed to link an image?

I tried it with <img src="./src/resources/img/image.png" alt=""> in src folder

It says it cannot resolve it, unlike in css file where I did with for background-image

background-image: url(resources/img/topBg.jpg);

That worked, but not img tag

wtf?

grammar fix :D

Here

In the For any hosting section it says

Doesn't require**s** any database

Should be: Doesn't require

Suggestion: let us issue PRs to the website as well.

👋

JS files wont load

I tried to create a .js file in js folder.

Then my code looks like in a page:

---
js: ["js/test.js"]
---

Then I got an error from console

(node:9728) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'files' of undefined
    at page.chunks.forEach.chunk (C:\Users\joann\AppData\Roaming\npm\node_modules\cogear\lib\plugins\build.js:122:32)
    at Array.forEach (<anonymous>:null:null)
    at Promise (C:\Users\joann\AppData\Roaming\npm\node_modules\cogear\lib\plugins\build.js:119:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)

(node:9728) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 17)

Cogear CLI tool doesn't work

A command cogear new cogear-site doesn't work, it throws following error:

/usr/bin/env: 'node --no-deprecation': No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines

Of course, npm i -g cogear command was done before.

My system characteristics:

node -v

v11.9.0

npm -v

6.7.0

Arch Linux.

Проблема деплоя sftp

Извини напишу по русски :)
Просто ради теста пробую задеплоить внутри локалки на сервер Ubuntu с Windows.
deploy.yaml

sftp:
type: sftp
host: 192.168.1.2
user: user
password: pwd
path: /home/sites/hexo/

выходит ошибка:

√ Current working dir: c:\Temp\cogear
√ Theme default.
√ Presets found: sftp
i No preset is chosen.
i Starting sftp preset by default:

  • Deploying:Authenticating with password.
    / Deploying:/home/sites/hexo/ undefined
    path.js:39
    throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Re
ceived type undefined
at assertPath (path.js:39:11)
at Object.join (path.js:432:7)
at C:\Users\Alex\AppData\Roaming\npm\node_modules\cogear\node_modules\node-sftp-deploy\index.js:79:62
at iterate (C:\Users\Alex\AppData\Roaming\npm\node_modules\cogear\node_modules\node-sftp-deploy\node_modules\async\lib\async.js:146:13)
at Object.async.eachSeries (C:\Users\Alex\AppData\Roaming\npm\node_modules\cogear\node_modules\node-sftp-deploy\node_modules\async\lib\async.js:162:9)
at C:\Users\Alex\AppData\Roaming\npm\node_modules\cogear\node_modules\node-sftp-deploy\index.js:70:23
at C:\Users\Alex\AppData\Roaming\npm\node_modules\cogear\node_modules\node-sftp-deploy\index.js:189:21
at SFTPStream.onReady (C:\Users\Alex\AppData\Roaming\npm\node_modules\cogear\node_modules\ssh2\lib\client.js:756:9)
at Object.onceWrapper (events.js:273:13)

Can't build anymore 😕

Hello,
I've been using cogear for the past few weeks, but as of recently, the build and watch stopped working. Would you be able to provide any help on this?

This is what I get when I run cogear -n and cogear build.

✔ Current working dir: ~/Projects/MY_PROJECT
✔ Theme default.
✔ Preloaded in 311ms.
(node:19638) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at assertPath (path.js:39:11)
    at Object.join (path.js:1157:7)
    at Promise.all.files.map.file (/Users/maikel/.nvm/versions/node/v10.10.0/lib/node_modules/cogear/node_modules/hard-source-webpack-plugin/lib/envHash.js:42:54)
    at Array.map (<anonymous>:null:null)
    at hashFiles (/Users/maikel/.nvm/versions/node/v10.10.0/lib/node_modules/cogear/node_modules/hard-source-webpack-plugin/lib/envHash.js:42:28)
    at module.exports.options (/Users/maikel/.nvm/versions/node/v10.10.0/lib/node_modules/cogear/node_modules/hard-source-webpack-plugin/lib/envHash.js:84:20)
    at runReadOrReset (/Users/maikel/.nvm/versions/node/v10.10.0/lib/node_modules/cogear/node_modules/hard-source-webpack-plugin/index.js:286:9)
    at _next0 (<anonymous>:57:17)
    at _promise0.then._result0 (<anonymous>:75:1)

(node:19638) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
✔ Resources are copied to the output folder.

I tried removing all the JS files, removed a whole bunch of files, reverted my git repo to a time where I had no issues, but I keep getting the same issue.

Any ideas? Suggestions?

Thanks in advance,
Maikel

Allow for site wide config of layout

I would like to have non-theme based layout with .html as extension (using .ejs compiler to allow the use of variables) but I would not like to specify layout in each page.

Currently it seems only .pug would work without specifying layout per page.

Thanks!

How to modify webpack config?

The docs say: "You can edit it in your project to customize Webpack behavior.", but adding webpack.prod.js to the root of my project doesn’t seem to affect effective webpack config.

Config files both for production and development modes are located into the main cogear package root:

./cogear
├── LICENCE.md
├── README.md
├── bin
├── lib
├── node_modules
├── package.json
├── postcss.config.js
├── webpack.common.js  # <= Common config shared between production and development
├── webpack.dev.js     # <= Development config
└── webpack.prod.js    # <= Production config

All in all it's usual Webpack config. You can edit it in your project to customize Webpack behavior.

Create a Bootstrap 4 theme for Cogear.JS

Subject

Encourage Hacktoberfest participants to create a new theme for Cogear.JS

How to

Read the following docs:

https://cogearjs.org/docs/themes

Watch the video:

https://www.youtube.com/watch?v=WO1MMMrFlsc

Install Cogear.JS

npm i -g cogear
# or
yarn global add cogear

Generate a project

$ cogear plugin cogear-bootstrap

Generate a theme

$ cogear theme bootstrap

** Craft a plugin! **

Publish it to Github

Publish it to NPM

npm publish

Hint

Look at cogear-theme-blog to understand its structure.

Output option not being sent to correct directory

I tried to build to a different directory outside of my project folder.

cogear build --output ~/Dropbox/Development/avocadoras.github.io/outputfromcogear/

However it does not send the built files to that directory, but instead creates a directory structure similar to my ouput string inside my project folder. After going into ~/Dropbox/Development/avocadoras.github.io/outputformcogear I see an empty folder. When I cd into my project folder called site and type pwd I get this result : /Users/jr/Desktop/Projects/CoGear/site/Users/jr/Dropbox/Development/avocadoras.github.io/outputfromcogear which means it is creating a folder structure similar to my output string inside my project folder but not actually moving those files to my output target. Is this how the option supposed to work?

OS: High Sierra 10.13.6
Node: 10.9.0

GitlabCI error when run build in docker

When i run cogear build in docker container / gitlab CI, have error:
env: can't execute 'node --no-deprecation': No such file or directory

https://github.com/codemotion/cogear.js/blob/97c2b64aced0b5ce38eb5168b616980808cf0a5f/bin/cogear.js#L1

Dockerfile example:

FROM mhart/alpine-node:10

RUN apk add --no-cache make gcc g++ python git bash

COPY . ./app
WORKDIR /app

RUN npm i && npm run build

ENTRYPOINT ["ls","public"]

package.json

{
  "name": "smartwords",
  "scripts": {
    "start": "cogear",
    "dev": "cogear dev",
    "build": "cogear build && cogear build",
    "prod": "cogear prod",
    "cogear": "cogear"
  },
  
"devDependencies": {
    "cogear": "^1.3.2"
  }
}

This is real big problem, because i cant setup site update in github pages

Loop through some/all the pages

Hi,

I couldn't find this info in the docs. Is it possible to run a loop inside one of the pages (index for example) that reads all the other pages and outputs the content of all/some of them?

To the point, I want to creade a single page site, but have the different sections saved in multiple "pages", something like in Jekyll: {% for post in site.posts %}.

suggestion: release pattern

I noticed that you are releasing to npm registry but there is no tag release on github.

It would be very convenient to have github releases as well.

Thank you.

PS is there any plans to have a chat on gitter or telegram for the project?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.