Giter Site home page Giter Site logo

eshengsky / iblog Goto Github PK

View Code? Open in Web Editor NEW
1.3K 50.0 390.0 16.8 MB

基于 Node.js 的开源个人博客系统,采用 Nuxt + Vue + TypeScript 技术栈。

Home Page: https://skysun.name

License: MIT License

JavaScript 2.29% CSS 2.45% TypeScript 25.50% Vue 69.73% Dockerfile 0.04%
blog iblog nodejs nuxtjs nuxt vue vuejs mongodb typescript

iblog's Introduction

iBlog

基于 Node.js 的开源个人博客系统,现代化的 UI 和用户体验。支持桌面端和移动端访问,支持深色模式,支持 Docker 部署。
不仅仅是博客,更是 Demo,是适合新人入门学习的完整项目。

目录

界面预览

  • 博客首页 首页
  • 后台管理 后台
  • 移动端 移动端

在线实例

我的博客 https://skysun.name/

分支说明

技术构成

快速开始

准备条件

安装 Node.js (v8 以上版本)、MongoDB
推荐安装 Yarn 而非 npm 以进行包管理。

安装依赖

$ yarn

启动站点

  • 开发模式
$ yarn run dev
  • 生产模式

先编译项目

$ yarn run build

再启动站点

$ yarn start

打开浏览器,访问 http://localhost:9000/

Debug

  • 要启动前端代码调试,请直接在 Chrome Dev Tools - Sources 面板中进行。

  • 要启动服务端代码调试,请以如下命令启动服务,然后点击 Chrome Dev Tools 左上角的 Node.js 按钮,就可以像调试前端代码一样调试服务端了。

$ node --inspect node_modules/.bin/nuxt-ts

Enjoy it! 😄

系统设置

根据实际情况修改 /blog.config.ts 配置文件,修改后需要重启服务器才能生效。
参数说明:

host

String 类型,主机名,配置为 0.0.0.0 表示监听任意主机。

port

Number 类型,端口号。

enableHTTPS

Boolean 类型,是否启用 HTTPS。

mongoUrl

String 类型,MongoDB 链接。

jwtSecret

String 类型,JWT 秘钥。

线上部署

使用PM2

推荐使用 pm2 进行 Node.js 的进程管理和持久运行。

安装

$ yarn global add pm2

启动

$ pm2 start pm2.json

使用noginx

noginx 是基于 Node.js 的 HTTP 及反向代理服务器(类似 nginx),如果你有多台 iBlog 服务器实例,你可以使用 noginx 进行代理转发和负载均衡。

Docker

iBlog 支持使用 Docker 容器快速部署并启动项目。

安装Docker

官方下载页面 选择对应平台的 Docker Desktop 下载并安装。

制作镜像

在项目根目录下执行如下命令创建镜像文件:

$ yarn run dockerImage

如果创建成功,你可以使用如下命令查看到生成的镜像:

$ docker image ls

创建容器

执行如下命令创建容器:

$ yarn run dockerRun

容器管理

通过 Docker Desktop 执行启动、停止、查看日志等操作。 Docker Desktop

更新日志

请直接查看 Commit 记录。

项目的后续更新计划,欢迎提交 PR

许可协议

MIT License

Copyright (c) 2020 Sky.Sun 孙正华

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

iblog's People

Contributors

dependabot[bot] avatar eshengsky avatar jarvin-guan avatar liaozhenting avatar phoenixzqy avatar pplokijuhyg avatar yipf42 avatar yun-percy 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  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

iblog's Issues

新增文章Mongo中_id(主键)重写为空字符串异常

Hi Sky,

    我发现后端在新增文章时,保存的文章表post中_id字段会出现为空字符串的情况,看了下保存的逻辑_id在保存时应该是有另行赋值,但是实际情况保存完毕后_id的值等于空字符串,导致后面几个问题。

   1.保存完毕后更新由于_id等于空字符串,则更新时无法确定具体数据列
   2.新增文章的_id也会是默认空字符导致新增会被识别为在更新_id为空字符串的数据

  Node Mongoose用得比较少,不知道_id是否在mongoose中能够缺省,让mongodb自动生_id:Object("") 

\node_modules\.staging 不存在,安装依赖的时候报错

你们是怎么安装的。为什么我执行npm install的这一步都进行不下去的呢?

`
npm WARN tar ENOENT: no such file or directory, open 'G:\HOUXIN\node_web\node_modules.staging\rxjs-b2b51ac7\src\internal\scheduler\VirtualTimeScheduler.ts'
npm WARN tar ENOENT: no such file or directory, lstat 'G:\HOUXIN\node_web\node_modules.staging\winston-e47eaf85\scratch\1280\node_modules\core-js\library\fn\math'
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected]
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'iblog2'
npm ERR! notarget

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\houxin\AppData\Roaming\npm-cache_logs\2019-01-05T07_18_36_041Z-debug.log
`
怎么就我遇到这种问题的,网上查了查都不能解决的额

进入后台报错

"stack": [
"Error: ENOENT: no such file or directory, open '/Users/xxx/Documents/Project/Node.js/iBlog2/views/shared/layoutAdmin'"
],

redis是否可以不依赖?

你好,redis是否可以调整为optional的?这样如果服务器资源不是那么多的话,比较节省资源

有个报错,请问怎么解决呢

TypeError: Cannot read property '_id' of null
at category.getByAlias.then.cate (/home/liuyue/Blog/iBlog2/routes/blog.js:42:25)
点击标题报错

文章分类

默认的全部分类和未命名分类不知道从哪里渲染出来的,数据库中只有自己加的分类,请问要修改去哪修改

全部分类等的显示bug

主页分类界面的“全部分类”“未分类”都调用的是en-us.json里面的字符,这个应该在哪里更改?我先用笨办法把那个json文件里面的对应改成中文了

nodejs应用线上部署问题

你好,你的开源博客很好,让我这个nodejs新手收益良多。但是我现在碰到一个问题,nodejs应用环境,你是在哪个云服务器上做的呀?我现在的阿里云虚拟机,好像部署不了nodejs的应用,很郁闷呀!

文章Alias唯一?

hi / 你好,
你能讲一下为什么文章的Alias也是唯一的? 不是已经有_id作为唯一键了吗?

请教个问题

出现下面的错误是为什么?

/node_modules/mongoose-schema-extend/index.js:28
        return () => target.concat(that.callQueue);
                ^

SyntaxError: Unexpected token )
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:413:25)
    at Object.Module._extensions..js (module.js:448:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/ec2-user/iBlog2/models/db.js:3:14)
    at Module._compile (module.js:430:26)
    at Object.Module._extensions..js (module.js:448:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/ec2-user/iBlog2/models/category.js:1:72)
    at Module._compile (module.js:430:26)

db配置

请问mongoDB方面需要哪些配置?
是否需要手动创建表等结构?
谢谢。

请问下二级目录要怎么生成?

你好,很感谢您的共享和帮助,博客我已经搭建起来了。目前遇到了一个问题,就是不知道用编辑器怎么直接生成每篇博客的一级、二级目录,每次要做只能是切换到code模式,然后copy html代码过去修改。但是这样很麻烦,而且我二级目录还出现不了。问下有什么其他简单的方式吗?谢谢

建议使用editor.md替代现有编辑器

你好,非常喜欢你的这个博客系统,但是编辑器不是很喜欢,所见即所得编辑过程效率太低,图片处理不完善,在手机上看文章,经常出现文章内的图片不能自动适应的情况。这在使用微信传播,体验很不好。
如果可以改成下面这个编辑器,那就更加完美了。。。。
http://pandao.github.io/editor.md/

有几个小bug

谢谢博主提供的源码,我花了半天时间也搭建了一个.^_^
搭建的过程中,发现有几个小问题,还望你有时间更新下代码.
一.我将代码下载下来,即使我选择的是中文界面,但是文章分类那里,全部分类和未分类,显示的也是英文字体.
二,发布文章后,后台管理界面,发布时间是24小时制的,查看文章详情时,发布时间是12小时制的.(不知道这12小时是不是故意设置的).
三.关于管理界面,上传头像时,返回的图片路径有问题,我服务器用了nginx转发到3000端口,返回的路径是http://localhost:3000/images/QQ%E6%88%AA%E5%9B%BE20170709172910.png.导致图片找不到.
不过,保存后显示的图片是正常的啦.
上面几个问题其实都无关大雅啦,不影响功能使用,并且用起来确实感觉蛮不错的,谢谢博主开源的代码

关于屏幕有缩小到355px下code超宽导致页面显示问题

image
缩小到355以下时页面显示出现问题,会左右隐藏一部分,检查是pre标签超宽,然后带动替他元素,超出部分会被隐藏。
暂时解决办法,在文章页添加样式
.article-main >>> .hljs {
max-width: 90vw;
}
这种拙劣的方法就不提交push request了,作者大大可能有更好的方式解决

所有环境搭建好后启动项目报错,错误如下,望指导,看着应该是mongodb的问题

@eshengsky

Debugger listening on [::]:56682
‌‌base
D:\code workspace\nodejs_workspace\iBlog2\node_modules\_mongoose@4.9.8@mongoose\lib\services\model\applyHooks.js:34
    if (pair[0] !== 'pre' && pair[0] !== 'post' && pair[0] !== 'on') {
            ^

TypeError: Cannot read property '0' of undefined
    at applyHooks (D:\code workspace\nodejs_workspace\iBlog2\node_modules\_mongoose@4.9.8@mongoose\lib\services\model\applyHooks.js:34:13)
    at Function.compile (D:\code workspace\nodejs_workspace\iBlog2\node_modules\_mongoose@4.9.8@mongoose\lib\model.js:3636:3)
    at Mongoose.model (D:\code workspace\nodejs_workspace\iBlog2\node_modules\_mongoose@4.9.8@mongoose\lib\index.js:417:22)
    at Object.<anonymous> (D:\code workspace\nodejs_workspace\iBlog2\models\category.js:16:34)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\code workspace\nodejs_workspace\iBlog2\proxy\category.js:1:83)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)

Process finished with exit code 1

从错误信息看应该是mongoose问题,我换成了[email protected](最新版)还是这个错,mongodb是能连接上的,希望帮忙看下谢谢。

几点问题

1、本地 yarn run dev 访问页面一直加载到无响应错误 node记录 发起请求 /api/settings

确认数据库连接正确,yarn build 之后 start 是可以跑起来

2、(node:24989) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead

每次打包的错误信息,这是哪个依赖的警告信息没找到

运行失败

the server/replset/mongos options are deprecated, all their options are supported at the top level of the options object [poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,sslCRL,autoReconnect,noDelay,keepAlive,connectTimeoutMS,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencyMS,connectWithNoPrimary,authSource,w,wtimeout,j,forceServerObjectId,serializeFunctions,ignoreUndefined,raw,promoteLongs,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,keepAliveInitialDelay,checkServerIdentity,validateOptions]
the server/replset/mongos options are deprecated, all their options are supported at the top level of the options object [poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,sslCRL,autoReconnect,noDelay,keepAlive,connectTimeoutMS,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencyMS,connectWithNoPrimary,authSource,w,wtimeout,j,forceServerObjectId,serializeFunctions,ignoreUndefined,raw,promoteLongs,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,keepAliveInitialDelay,checkServerIdentity,validateOptions]
C:\U:node_modules\mongodb\lib\url_parser.js:126
throw new Error('More than 1 database name in URL');
^

Error: More than 1 database name in URL
请问一下这是什么原因呢?

进入后台报错

进入后台总是报metisMenu.min.js找不到的错

error: Not Found! pid=2216, uid=0, hostname=Passerby, stack=[Error: Not Found!,     at app.use 
(/home/iBlog2/app.js:90:17),     at Layer.handle [as handle_request] 
(/home/iBlog2/node_modules/express/lib/router/layer.js:95:5),     at trim_prefix 
(/home/iBlog2/node_modules/express/lib/router/index.js:312:13),     at 
/home/iBlog2/node_modules/express/lib/router/index.js:280:7,     at Function.process_params 
(/home/iBlog2/node_modules/express/lib/router/index.js:330:12),     at next 
(/home/iBlog2/node_modules/express/lib/router/index.js:271:10),     at 
/home/iBlog2/node_modules/express/lib/router/index.js:618:15,     at next 
(/home/iBlog2/node_modules/express/lib/router/index.js:256:14),     at Function.handle 
(/home/iBlog2/node_modules/express/lib/router/index.js:176:3),     at router 
(/home/iBlog2/node_modules/express/lib/router/index.js:46:12),     at Layer.handle [as handle_request] 
(/home/iBlog2/node_modules/express/lib/router/layer.js:95:5),     at trim_prefix 
(/home/iBlog2/node_modules/express/lib/router/index.js:312:13),     at 
/home/iBlog2/node_modules/express/lib/router/index.js:280:7,     at Function.process_params 
(/home/iBlog2/node_modules/express/lib/router/index.js:330:12),     at next 
(/home/iBlog2/node_modules/express/lib/router/index.js:271:10),     at 
/home/iBlog2/node_modules/express/lib/router/index.js:618:15], code=404, baseUrl=, 
originalUrl=/static/metisMenu/dist/metisMenu.min.js, , , ip=127.0.0.1, route=undefined

/static/metisMenu/dist/metisMenu.min.js 访问不到

在CentOS6.8x64下运行的会这样,到windows下面运行是正常的

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.