Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add bundled configuration for Vercel #483

Merged
merged 3 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bridgetown-core/lib/bridgetown-core/configurations/vercel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

copy_file in_templates_dir("vercel.json"), "vercel.json"
copy_file in_templates_dir("vercel_url.rb"), "plugins/builders/vercel_url.rb"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"cleanUrls": true,
"trailingSlash": false,
"redirects": [],
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "Permissions-Policy",
"value": "geolocation=(self), microphone=()"
}
]
},
{
"source": "/feed.xml",
"headers": [
{
"key": "Content-Type",
"value": "application/rss+xml"
},
{
"key": "Cache-Control",
"value": "public, max-age=3600"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class Builders::VercelUrl < SiteBuilder
def build
hook :site, :pre_render do |site|
next unless ENV["VERCEL_URL"] && ENV["VERCEL_ENV"] != "production"

Bridgetown.logger.info("Subbing Vercel URL")
site.config.update(url: "https://#{ENV["VERCEL_URL"]}")
end
end
end
11 changes: 11 additions & 0 deletions bridgetown-website/src/_docs/bundled-configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The configurations we include are:
- [Bridgetown recommended PostCSS plugins](#bridgetown-recommended-postcss-plugins) (`bt-postcss`)
- [Render YAML Configuration](#render-yaml-configuration) (`render`)
- [Netlify TOML Configuration](#netlify-toml-configuration) (`netlify`)
- [Vercel JSON Configuration](#vercel-json-configuration) (`vercel`)
- [Automated Test Suite using Minitest](#automated-test-suite-using-minitest) (`minitesting`)
- [Cypress](#cypress) (`cypress`)

Expand Down Expand Up @@ -120,6 +121,16 @@ bin/bridgetown configure render
bin/bridgetown configure netlify
```

### Vercel JSON Configuration

⚙️ Adds a basic configuration to your site for use in [Vercel](https://vercel.com) deployments along with a builder to ensure Bridgetown uses the correct `absolute_url` on preview deployments.

🛠 **Configure using:**

```sh
bin/bridgetown configure vercel
```

### Automated Test Suite using Minitest

⚙️ Adds a basic test suite using [Minitest](https://rubygems.org/gems/minitest) and Rails DOM assertions for extremely fast verification of your output HTML. Check out [our automated testing guide](/docs/testing#use-ruby-and-minitest-to-test-html-directly) for more info!
Expand Down