Skip to content

Commit

Permalink
Disable index by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Bios-Marcel committed Dec 27, 2024
1 parent 1281df7 commit b479122
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ strategy = "immediate"

[env]
ROOT_URL = "https://scribblers.bios-marcel.link"
ALLOW_INDEXING = true
SERVE_DIRECTORIES = ":/public"
LOBBY_SETTING_BOUNDS_MAX_MAX_PLAYERS = 100

Expand Down
3 changes: 3 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ type Config struct {
// CanonicalURL specifies the original domain, in case we are accessing the
// site via some other domain, such as scribblers.fly.dev
CanonicalURL string `env:"CANONICAL_URL"`
// AllowIndexing will control whether the noindex, nofollow meta tag is
// added to the home page.
AllowIndexing bool `env:"ALLOW_INDEXING"`
// ServeDirectories is a map of `path` to `directory`. All directories are
// served under the given path.
ServeDirectories map[string]string `env:"SERVE_DIRECTORIES"`
Expand Down
3 changes: 3 additions & 0 deletions internal/frontend/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ type BasePageConfig struct {
// CanonicalURL specifies the original domain, in case we are accessing the
// site via some other domain, such as scribblers.fly.dev
CanonicalURL string `json:"canonicalUrl"`
// AllowIndexing will control whether the noindex, nofollow meta tag is
// added to the home page.
AllowIndexing bool `env:"ALLOW_INDEXING"`
}

var fallbackChecksum = uuid.Must(uuid.NewV4()).String()
Expand Down
13 changes: 7 additions & 6 deletions internal/frontend/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ type SSRHandler struct {

func NewHandler(cfg *config.Config) (*SSRHandler, error) {
basePageConfig := &BasePageConfig{
checksums: make(map[string]string),
hash: md5.New(),
Version: version.Version,
Commit: version.Commit,
RootURL: cfg.RootURL,
CanonicalURL: cfg.CanonicalURL,
checksums: make(map[string]string),
hash: md5.New(),
Version: version.Version,
Commit: version.Commit,
RootURL: cfg.RootURL,
CanonicalURL: cfg.CanonicalURL,
AllowIndexing: cfg.AllowIndexing,
}
if cfg.RootPath != "" {
basePageConfig.RootPath = "/" + cfg.RootPath
Expand Down
2 changes: 2 additions & 0 deletions internal/frontend/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
skribbl.io, scribble, scribblers, scribble.rs, pictionary,
montagsmaler, sketchful, draw and guess, drawmything, free, oss">
<link rel="canonical" href="{{.CanonicalURL}}" />
{{if not .AllowIndexing}}
<meta name="robots" content="noindex, nofollow">{{end}}
{{if ne "" .RootURL}}
<meta property="og:image" content="{{.RootURL}}{{.RootPath}}/resources/logo.png">
<meta property="og:image:type" content="image/png">
Expand Down

0 comments on commit b479122

Please sign in to comment.