{"id":108738,"date":"2020-05-22T06:26:26","date_gmt":"2020-05-21T22:26:26","guid":{"rendered":"http:\/\/4563.org\/?p=108738"},"modified":"2020-05-22T06:26:26","modified_gmt":"2020-05-21T22:26:26","slug":"hexo-serverless-framework%ef%bc%8c%e7%ae%80%e5%8d%95%e4%b8%89%e6%ad%a5%e6%90%ad%e5%bb%ba%e4%bd%a0%e7%9a%84%e4%b8%aa%e4%ba%ba%e5%8d%9a%e5%ae%a2","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=108738","title":{"rendered":"Hexo + Serverless Framework\uff0c\u7b80\u5355\u4e09\u6b65\u642d\u5efa\u4f60\u7684\u4e2a\u4eba\u535a\u5ba2"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Hexo + Serverless Framework\uff0c\u7b80\u5355\u4e09\u6b65\u642d\u5efa\u4f60\u7684\u4e2a\u4eba\u535a\u5ba2               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : scf10cent <\/span>  <span><i><\/i> 50<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5f88\u591a\u4eba\u90fd\u60f3\u62e5\u6709\u81ea\u5df1\u7684\u4e2a\u4eba\u535a\u5ba2\uff0c\u8fd8\u5f97\u770b\u8d77\u6765\u6f02\u4eae\u3001\u9177\u9177\u7684\u3002\u5c24\u5176\u5bf9\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u4e0d\u4ec5\u53ef\u4ee5\u5206\u4eab\u6280\u672f\uff08\u88c5\uff09\u5fc3\u5f97\uff08\u903c\uff09\uff0c\u9762\u8bd5\u7684\u65f6\u5019\u8fd8\u80fd\u6210\u4e3a\u52a0\u5206\u3002\u8fd9\u91cc\u4ecb\u7ecd\u4e24\u6b3e\u597d\u7528\u7684\u795e\u5668\uff0c\u4e0d\u7528\u5fd9\u524d\uff08\u524d\u7aef\uff09\u5fd9\u540e\uff08\u540e\u7aef\uff09\uff0c\u7b80\u5355 3min \u5373\u53ef\u641e\u5b9a\uff0c\u672c\u6587\u514d\u8d39\u5206\u4eab\u7ed9\u5927\u5bb6\u3002<\/p>\n<blockquote>\n<p>PS\uff1a\u4e0d\u4f1a\u5199\u4ee3\u7801\uff1f\u6ca1\u6709\u5907\u6848\u7684\u57df\u540d\uff1f\u6ca1\u6709\u670d\u52a1\u5668\uff1f\u5728\u8fd9\u91cc\uff0c\u8fd9\u4e9b\u90fd\u4e0d\u662f\u4e8b\u513f\uff01<\/p>\n<\/blockquote>\n<p><strong>\u5de5\u5177\u4ecb\u7ecd<\/strong><\/p>\n<ul>\n<li><strong>Serverless Framework<\/strong>\uff1aServerless Framework \u662f\u4e1a\u754c\u975e\u5e38\u53d7\u6b22\u8fce\u7684\u65e0\u670d\u52a1\u5668\u5e94\u7528\u6846\u67b6\uff0c\u5f00\u53d1\u8005\u65e0\u9700\u5173\u5fc3\u5e95\u5c42\u8d44\u6e90\u5373\u53ef\u90e8\u7f72\u5b8c\u6574\u53ef\u7528\u7684 Serverless \u5e94\u7528\u67b6\u6784\u3002<\/li>\n<li><strong>Hexo<\/strong>\uff1aHexo \u662f\u4e00\u4e2a\u5feb\u901f\u3001\u7b80\u6d01\u4e14\u9ad8\u6548\u7684\u535a\u5ba2\u6846\u67b6\u3002Hexo \u4f7f\u7528 Markdown \uff08\u6216\u5176\u4ed6\u6e32\u67d3\u5f15\u64ce\uff09\u89e3\u6790\u6587\u7ae0\uff0c\u5728\u51e0\u79d2\u5185\uff0c\u5373\u53ef\u5229\u7528\u9753\u4e3d\u7684\u4e3b\u9898\u751f\u6210\u9759\u6001\u7f51\u9875\u3002<\/li>\n<\/ul>\n<p>\u4f7f\u7528 Serverless Framework \u90e8\u7f72\u4e00\u4e2a Hexo \u7f51\u7ad9\u53ea\u9700\u4e09\u6b65\uff1a\uff1a\u5b89\u88c5\u4e0e\u521d\u59cb\u5316 \u2192 \u914d\u7f6e yml \u6587\u4ef6 \u2192 \u90e8\u7f72<\/p>\n<h2>\u5b89\u88c5\u4e0e\u521d\u59cb\u5316<\/h2>\n<p>\u7b80\u5355\u4e09\u6b65\uff0c\u5373\u53ef\u901a\u8fc7 Serverless Website \u7ec4\u4ef6\u5feb\u901f\u6784\u5efa\u4e00\u4e2a Serverless Hexo \u7ad9\u70b9\u3002<\/p>\n<p><strong>\u9996\u5148\u786e\u4fdd\u7cfb\u7edf\u5305\u542b\u4ee5\u4e0b\u73af\u5883\uff1a<\/strong><\/p>\n<ul>\n<li>Node.js (Node.js \u7248\u672c\u9700\u4e0d\u4f4e\u4e8e 8.6\uff0c\u5efa\u8bae\u4f7f\u7528 Node.js 10.0 \u53ca\u4ee5\u4e0a\u7248\u672c)<\/li>\n<li>Git<\/li>\n<\/ul>\n<p>\u5982\u672a\u5b89\u88c5\u4e0a\u8ff0\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u53c2\u8003\u5b89\u88c5\u8bf4\u660e\u3002<\/p>\n<p><strong>1. \u5b89\u88c5 Serverless Framework<\/strong><\/p>\n<pre><code>$ npm install -g serverless <\/code><\/pre>\n<p><strong>2. \u5b89\u88c5 Hexo<\/strong><\/p>\n<pre><code>$ npm install -g hexo-cli <\/code><\/pre>\n<p><strong>3. \u521d\u59cb\u5316\u9879\u76ee<\/strong><\/p>\n<pre><code>$ hexo init hexo   # \u751f\u6210 hexo \u76ee\u5f55 $ cd hexo $ npm install <\/code><\/pre>\n<p>\u521d\u59cb\u5316\u5b8c\u6210\u540e\uff0chexo \u6587\u4ef6\u5939\u7684\u76ee\u5f55\u5982\u4e0b\uff1a<\/p>\n<pre><code>. \u251c\u2500\u2500 _config.yml \u251c\u2500\u2500 package.json \u251c\u2500\u2500 scaffolds \u251c\u2500\u2500 source |   \u251c\u2500\u2500 _drafts |   \u2514\u2500\u2500 _posts \u2514\u2500\u2500 themes <\/code><\/pre>\n<p><strong>4. \u751f\u6210\u672c\u5730\u535a\u5ba2\u9875\u9762<\/strong><\/p>\n<pre><code>hexo g   # generate <\/code><\/pre>\n<p>\u53ef\u4ee5\u901a\u8fc7 <code>hexo g<\/code> \u547d\u4ee4\u751f\u6210\u9759\u6001\u9875\u9762\uff0c\u5982\u679c\u5e0c\u671b\u5728\u672c\u5730\u67e5\u770b\u6548\u679c\uff0c\u4e5f\u53ef\u4ee5\u8fd0\u884c\u4e0b\u5217\u547d\u4ee4\uff0c\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee http:\/\/localhost:4000 \u67e5\u770b\u9875\u9762\u6548\u679c\u3002<\/p>\n<pre><code>hexo s   # server <\/code><\/pre>\n<h2>\u914d\u7f6e yml \u6587\u4ef6<\/h2>\n<p>\u9879\u76ee\u76ee\u5f55\u4e0b\uff0c\u521b\u5efa <code>serverless.yml<\/code> \u6587\u4ef6<\/p>\n<pre><code>cd.&gt; serverless.yml <\/code><\/pre>\n<p>\u5c06\u4ee5\u4e0b\u5185\u5bb9\u5199\u5165\u4e0a\u8ff0\u7684 yml \u6587\u4ef6\u91cc\uff1a<\/p>\n<pre><code># serverless.yml  myWebsite:   component: \"@serverless\/tencent-website\"inputs:     code:       src: .\/public # Upload static files generated by HEXO       index: index.html       error: index.html     region: ap-guangzhou     bucketName: my-bucket-hexo <\/code><\/pre>\n<p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u6587\u4ef6\u76ee\u5f55\u5982\u4e0b\uff1a<\/p>\n<pre><code>. \u251c\u2500\u2500 .serverless \u251c\u2500\u2500 hexo |   \u251c\u2500\u2500 public |   \u251c\u2500\u2500 ... |   \u251c\u2500\u2500 _config.yml |   \u251c\u2500\u2500 ... |   \u2514\u2500\u2500 source \u2514\u2500\u2500 serverless.yml <\/code><\/pre>\n<h2>\u90e8\u7f72<\/h2>\n<p>\u901a\u8fc7 <code>sls<\/code> \u547d\u4ee4\u8fdb\u884c\u90e8\u7f72\uff0c\u5e76\u53ef\u4ee5\u6dfb\u52a0 <code>--debug<\/code> \u53c2\u6570\u67e5\u770b\u90e8\u7f72\u8fc7\u7a0b\u4e2d\u7684\u4fe1\u606f<\/p>\n<p>\u5982\u60a8\u7684\u8d26\u53f7\u672a\u767b\u9646\u6216\u6ce8\u518c\u817e\u8baf\u4e91\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u5fae\u4fe1\u626b\u63cf\u547d\u4ee4\u884c\u4e2d\u7684\u4e8c\u7ef4\u7801\u8fdb\u884c\u6388\u6743\u767b\u9646\u548c\u6ce8\u518c\u3002<\/p>\n<pre><code>PS serverless --debug    DEBUG \u2500 Resolving the template's static variables.   DEBUG \u2500 Collecting components from the template.   DEBUG \u2500 Downloading any NPM components found in the template.   DEBUG \u2500 Analyzing the template's components dependencies.   DEBUG \u2500 Creating the template's components graph.   DEBUG \u2500 Syncing template state.   DEBUG \u2500 Executing the template's components graph.   DEBUG \u2500 Starting Website Component.  Please scan QR code login from wechat Wait login... Login successful for TencentCloud   DEBUG \u2500 Preparing website Tencent COS bucket my-bucket-1250000000.   DEBUG \u2500 Deploying \"my-bucket-1250000000\" bucket in the \"ap-guangzhou\" region.   DEBUG \u2500 \"my-bucket-1250000000\" bucket was successfully deployed to the \"ap-guangzhou\" region.   DEBUG \u2500 Setting ACL for \"my-bucket-1250000000\" bucket in the \"ap-guangzhou\" region.   DEBUG \u2500 Ensuring no CORS are set for \"my-bucket-1250000000\" bucket in the \"ap-guangzhou\" region.   DEBUG \u2500 Ensuring no Tags are set for \"my-bucket-1250000000\" bucket in the \"ap-guangzhou\" region.   DEBUG \u2500 Configuring bucket my-bucket-1250000000 for website hosting.   DEBUG \u2500 Uploading website files from D:hexotinalocalhexopublic to bucket my-bucket-1250000000.   DEBUG \u2500 Starting upload to bucket my-bucket-1250000000 in region ap-guangzhou   DEBUG \u2500 Uploading directory D:hexotinalocalhexopublic to bucket my-bucket-1250000000   DEBUG \u2500 Website deployed successfully to URL: https:\/\/my-bucket-1250000000.cos-website.ap-guangzhou.myqcloud.com.    myWebsite:     url: https:\/\/my-bucket-1250000000.cos-website.ap-guangzhou.myqcloud.com     env:    13s \u00bb myWebsite \u00bb done <\/code><\/pre>\n<p>\u8bbf\u95ee\u547d\u4ee4\u884c\u8f93\u51fa\u7684 website url\uff0c\u5373\u53ef\u67e5\u770b\u5c5e\u4e8e\u81ea\u5df1\u7684 Serverless Hexo \u7ad9\u70b9\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/06\/20200531_5ed41699b80b9.png\" alt=\"Hexo + Serverless Framework\uff0c\u7b80\u5355\u4e09\u6b65\u642d\u5efa\u4f60\u7684\u4e2a\u4eba\u535a\u5ba2\" \/><\/p>\n<p>\u5982\u679c\u9700\u8981\u66f4\u65b0 hexo \u7ad9\u70b9\u4e2d\u7684\u6587\u7ae0\uff0c\u53ea\u9700\u8981\u5728\u672c\u5730\u91cd\u65b0\u8fd0\u884c <code>hexo g<\/code> \u66f4\u65b0\u672c\u5730\u9875\u9762\uff0c\u518d\u8fd0\u884c <code>sls<\/code> \u5c31\u53ef\u4ee5\u76f4\u63a5\u66f4\u65b0\u5230 Hexo \u7f51\u7ad9\u5566~<\/p>\n<ul>\n<li>\u5177\u4f53\u4ee3\u7801\u53ef\u53c2\u8003\u5b8c\u6574\u6a21\u677f\u4ed3\u5e93<\/li>\n<\/ul>\n<h2>\u5c0f\u7ed3<\/h2>\n<p>\u672c\u6587\u7b80\u5355\u5c55\u793a\u4e86\u5982\u4f55\u5229\u7528 Serverless Framework \u521b\u5efa\u4e00\u4e2a\u4e2a\u4eba\u535a\u5ba2\uff0cHexo \u62e5\u6709\u4e30\u5bcc\u7684\u63d2\u4ef6\u7cfb\u7edf\uff0c\u5927\u5bb6\u53ef\u4ee5\u57fa\u4e8e Serverless Framework \u548c hexo \u5f00\u53d1\u66f4\u591a\u4e2a\u6027\u5316\u529f\u80fd\uff0c\u5982\u81ea\u5b9a\u4e49 Themes\u3001\u535a\u6587\u7f6e\u9876\u3001\u6dfb\u52a0\u5c0f\u56fe\u6807\u7b49\u3002\u8fd9\u4e24\u4e2a\u5de5\u5177\u7ed3\u5408\u4f7f\u7528\uff0c\u5f00\u53d1\u65b9\u4fbf\u90e8\u7f72\u5feb\u6377\uff0c\u975e\u5e38\u9002\u5408\u60f3\u8981\u5feb\u901f\u642d\u5efa\u9759\u6001\u7f51\u7ad9\u7684\u5f00\u53d1\u8005\u3002<\/p>\n<blockquote>\n<p>\u53c2\u8003\uff1a<\/p>\n<\/blockquote>\n<ul>\n<li>Serverless Framework &#8211; \u4ea7\u54c1\u5b98\u7f51<\/li>\n<li>Serverless Framework &#8211; GitHub<\/li>\n<\/ul>\n<p>\u5927\u5bb6\u4e5f\u53ef\u4ee5\u8bbf\u95ee\uff1aServerless \u4e2d\u6587\u6280\u672f\u793e\u533a\uff0c\u53ef\u4ee5\u5728 \u6700\u4f73\u5b9e\u8df5 \u91cc\u67e5\u770b\u66f4\u591a\u5173\u4e8e Serverless \u5e94\u7528\u7684\u5f00\u53d1\uff01<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Hexo + Serverless&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/108738"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=108738"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/108738\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=108738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=108738"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=108738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}