Skip to content

Commit

Permalink
Only set baseurl for live-reload (#306).
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed Apr 22, 2024
1 parent cc6f767 commit 7bf30c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cmd/build/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ func createHTML(currentContent content, env env) error {
// Inject data-content-filepath attribute
htmlBytes = bytes.Replace(htmlBytes, []byte("<html"), []byte("<html data-content-filepath='"+currentContent.contentFilepath+"' "), 1)
if Doreload {
if env.baseurl == "" {
// Fix live-reload.js path if baseurl isn't set
env.baseurl = "/"
}
// Inject live-reload script (stored in ejected core).
htmlBytes = bytes.Replace(
htmlBytes,
Expand Down
5 changes: 0 additions & 5 deletions readers/site_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ func GetSiteConfig(basePath string) (SiteConfig, string) {
siteConfig.BuildDir = "public"
}

// If baseurl is not set in config, use "/" for resolving URLs like core/live-reload.js
if siteConfig.BaseURL == "" {
siteConfig.BaseURL = "/"
}

// If local server port is not set in config, use default
if siteConfig.Local.Port <= 0 {
siteConfig.Local.Port = 3000
Expand Down

0 comments on commit 7bf30c2

Please sign in to comment.