dbelyaeff / cogear.js Goto Github PK
View Code? Open in Web Editor NEWModern static websites generator (Node.JS/Webpack)
Home Page: https://cogearjs.org
License: Other
Modern static websites generator (Node.JS/Webpack)
Home Page: https://cogearjs.org
License: Other
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
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
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.
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.
npm install cogear -g
cogear new mysite
cd mysite
cogear -w
@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?
Доброго времени суток! Заинтересовало создание сайта и блога. Но не понятно что как работает! Есть ли документация на русском? И будет ли вообще?
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.
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? 🤔
Can we have pages data stored in JSON file format to be used for templates in the themes section?
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
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:
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
parse.after
also feels wrong for the same reason mentioned above.
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.
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:
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!
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?
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.
👋
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)
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.
Извини напишу по русски :)
Просто ради теста пробую задеплоить внутри локалки на сервер 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)
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
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!
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.
Encourage Hacktoberfest participants to create a new theme for Cogear.JS
https://cogearjs.org/docs/themes
https://www.youtube.com/watch?v=WO1MMMrFlsc
npm i -g cogear
# or
yarn global add cogear
$ cogear plugin cogear-bootstrap
$ cogear theme bootstrap
** Craft a plugin! **
npm publish
Look at cogear-theme-blog to understand its structure.
To create a plugin for Cogear.JS to add a proper loader to Webpack config for React.
https://cogearjs.org/docs/plugins
npm i -g cogear
# or
yarn global add cogear
$ cogear new cogear-react
$ cogear plugin react
** Craft a plugin! **
Look at cogear-plugin-vue to understand its structure.
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
When i run cogear build in docker container / gitlab CI, have error:
env: can't execute 'node --no-deprecation': No such file or directory
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
In NodeJS 12 resolving was changed.
https://github.com/codemotion/cogear.js/blob/2f7954392dacda4ffdce0f720282e9c66851b7a8/lib/plugins/build.js#L91
page.layout
value needs to be a local path: layout = require.resolve('./' + page.layout, {
I don't know if this is the only line that has to be changed, at least the default page builds with that change.
Hello,
Is there a reason to keep .vscode as a part of the repository?
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 %}
.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.