# This line should *not* be indented media_folder: "source/images/uploads" # Media files will be stored in the repo under images/uploads public_folder: "/images/uploads" # The src attribute for uploaded media will begin with /images/uploads
collections: - name: "blog" # Used in routes, e.g., /admin/collections/blog label: "Post" # Used in the UI folder: "source/_posts" # The path to the folder where the documents are stored create: true # Allow users to create new documents in this collection slug: "{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md fields: # The fields for each document, usually in front matter - {label: "Layout", name: "layout", widget: "hidden", default: "post"} - {label: "Title", name: "title", widget: "string"} - {label: "Publish Date", name: "date", widget: "datetime"} - {label: "Tags", name: "tags", widget: "list", required: false} - {label: "Categories", name: "categories", widget: "list", required: false} - {label: "Photos", name: "photos", widget: "list", required: false} - {label: "Excerpt", name: "excerpt", widget: "string", required: false} - {label: "Body", name: "body", widget: "markdown"} - {label: "Permalink", name: "permalink", widget: "string", required: false} - {label: "Comments", name: "comments", widget: "boolean", default: true, required: false}
index.html
1 2 3 4 5 6 7 8 9 10 11 12 13
<!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Content Manager</title> </head> <body> <!-- Include the script that builds the page and powers Netlify CMS --> <script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script> <script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script> </body> </html>
var path = require("path"); var fs = require('fs'); var mime = require('mime'); var AWS = require('aws-sdk'); AWS.config.loadFromPath('./s3-deploy/config.json'); let s3 = new AWS.S3();
const uploadDir = function (s3Path, bucketName) { function walkSync(currentDirPath, callback) { fs.readdirSync(currentDirPath).forEach(function (name) { var filePath = path.join(currentDirPath, name); var stat = fs.statSync(filePath); if (stat.isFile()) { callback(filePath, stat); } else if (stat.isDirectory()) { walkSync(filePath, callback); } }); }
walkSync(s3Path, function (filePath, stat) { let bucketPath = filePath.substring(s3Path.length + 1); let mimeType = mime.getType(bucketPath); let params = { Bucket: bucketName, Key: bucketPath.replace(/\\/g, '/'), Body: fs.readFileSync(filePath), ContentType: mimeType }; s3.putObject(params, function (err, data) { if (err) { console.log(err) } else { console.log('Successfully uploaded ' + bucketPath + ' to ' + bucketName); } }); }); };
请注意选择Custom SSL Certificate, 然后输入框中,AWS会自动列出可用的证书列表,如果没有,则点击Request or Import a certificate with ACM 选择上面新增的就好了 在浏览器访问这个cloudfront地址,就可以看到https的标志,查看这个https证书就可以得到自定义的这个域名,而不是cloudfront开头的,看起来是不是很高大上。
Webhooks 里提供了几十种状态,所有这些状态都会注册到Stripe里一个叫webhooks事件钩子的地方,我们可以指定不同事件的触发时,转发数据到某个我们自己搭建好的Web Api上。(下图是我们的服务器end point, 因为我们没有用到服务器,使用的是亚马逊lambda做一个Serverless)
举个支付宝的栗子
服务端 (Serverless)
以AWS的Lambda + API gateway为例, 其中,前者是用来定义API, 后者是做路由。