Skip to content

Commit 34c9dba

Browse files
committed
Save netlify branch to site.branch, and use that in editor config, defaulting to site.github branch
This is necessary because `site.github.source.branch` refers to the upstream repo's branch, not the fork. See #227.
1 parent b8462a2 commit 34c9dba

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

editor/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
config: {
2222
backend: {
2323
repo: {{ site.github.repository_nwo | jsonify }},
24-
branch: {{ site.github.source.branch | jsonify }}
24+
branch: {{ site.branch | default: site.github.source.branch | jsonify }}
2525
},
2626
local_backend: {% if jekyll.environment == "production" %}false{% else %}true{% endif %},
2727
site_url: {{ "" | absolute_url | jsonify }}

netlify/plugins/netlify-jekyll-metadata/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ export const onPreBuild = async function () {
55
const siteUrl = process.env.URL
66
const repoUrl = new URL(process.env.REPOSITORY_URL || '')
77
const repoNameWithOwner = repoUrl.pathname.replace(/^\/+/, '')
8+
const branch = process.env.BRANCH
89

910
const fileName = '_config_override.yml'
10-
const fileContents = `repository: ${repoNameWithOwner}\nurl: ${siteUrl}\nbaseurl: ""`
11+
const fileContents = `repository: ${repoNameWithOwner}\nurl: ${siteUrl}\nbranch: ${branch}\nbaseurl: ""`
1112
return fs.promises.writeFile(fileName, fileContents)
1213
}

0 commit comments

Comments
 (0)