立诚勿怠,格物致知
It's all about connecting the dots

OSChina支持Pages功能了

This is not a new function supported by OSChina, but I’m just aware of that yesterday. Long time ago, I had once made a choice whether to use github or OSChina to be the repository storing my public code, and I finally use github later due to the fact that I found OSChina seems to have to function like github Pages. You know, as I front end developer, it’s import to show not both your code but also its visual display to others. Therefore, functions like github pages are very meaningful to me and it’s also very convenient. Without functions like github pages, I will need to build my code and then use FTP/SFTP tools like FileZilla to upload my frontend static files to my server. If you change your code in high frequency, you will find this way quite time-wasting. Whereas if you use github pages, all you need to do after rebuild your code is type one line’s command in your command line tools and press enter button ^_^.

Using Github Pages

Right. There is a npm package called “gh-pages”. If your built files are stored in a folder named “src” in the root directory of your project. You can add one custom script in your package.json file like below:

"scripts": {
  "dev": "node build/dev-server.js",
  "build": "node build/build.js",
  "deployToGit": "gh-pages -d dist",
  "test": "echo \"Error: no test specified\" && exit 1"
},

The scripts “gh-pages -d dist” will deploy all your code under dist folder to a remote branch in github called “gh-pages”, and then you can visit your project online through link like “http://yakima-teng.github.io/demos/” in which “yakima-teng” should be replaced by your github user name and “demos” should be replaced by your project name of your github repository.

Using OSChina Pages

Although there is strings “gh” in the name of the npm package “gh-pages”, this package is also available to use for OSChina Pages. As per the official npm website for this package, you can find many custom options. In short, if:

  • your files need to be visited online are all built to a folder called dist in your project root,
  • you want to use a remote branch called “oschina-pages” to be used for online display purpose,
  • your remote git repository address is “https://git.oschina.net/yakima/demos.git”.

You can add a script alias (short name) “deployToOSChina” in your package.json file like below:

"scripts": {
  "dev": "node build/dev-server.js",
  "build": "node build/build.js",
  "deployToGit": "gh-pages -d dist",
  "deployToOSChina": "gh-pages -d dist -b oschina-pages -o oschina -r https://git.oschina.net/yakima/demos.git",
  "test": "echo \"Error: no test specified\" && exit 1"
},

Yakima Teng,

August 28, 2017,

In Shanghai, China

赞(1) 打赏
文章名称:《OSChina支持Pages功能了》
文章链接:https://www.orzzone.com/oschina-supported-pages.html
商业联系:yakima.public@gmail.com

本站大部分文章为原创或编译而来,对于本站版权文章,未经许可不得用于商业目的,非商业性转载请以链接形式标注原文出处。
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力提供更多优质内容!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册