Skip to content

Commit b479122

Browse files
committed
Disable index by default
1 parent 1281df7 commit b479122

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

fly.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ strategy = "immediate"
1616

1717
[env]
1818
ROOT_URL = "https://scribblers.bios-marcel.link"
19+
ALLOW_INDEXING = true
1920
SERVE_DIRECTORIES = ":/public"
2021
LOBBY_SETTING_BOUNDS_MAX_MAX_PLAYERS = 100
2122

internal/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ type Config struct {
5757
// CanonicalURL specifies the original domain, in case we are accessing the
5858
// site via some other domain, such as scribblers.fly.dev
5959
CanonicalURL string `env:"CANONICAL_URL"`
60+
// AllowIndexing will control whether the noindex, nofollow meta tag is
61+
// added to the home page.
62+
AllowIndexing bool `env:"ALLOW_INDEXING"`
6063
// ServeDirectories is a map of `path` to `directory`. All directories are
6164
// served under the given path.
6265
ServeDirectories map[string]string `env:"SERVE_DIRECTORIES"`

internal/frontend/http.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ type BasePageConfig struct {
5454
// CanonicalURL specifies the original domain, in case we are accessing the
5555
// site via some other domain, such as scribblers.fly.dev
5656
CanonicalURL string `json:"canonicalUrl"`
57+
// AllowIndexing will control whether the noindex, nofollow meta tag is
58+
// added to the home page.
59+
AllowIndexing bool `env:"ALLOW_INDEXING"`
5760
}
5861

5962
var fallbackChecksum = uuid.Must(uuid.NewV4()).String()

internal/frontend/index.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ type SSRHandler struct {
4545

4646
func NewHandler(cfg *config.Config) (*SSRHandler, error) {
4747
basePageConfig := &BasePageConfig{
48-
checksums: make(map[string]string),
49-
hash: md5.New(),
50-
Version: version.Version,
51-
Commit: version.Commit,
52-
RootURL: cfg.RootURL,
53-
CanonicalURL: cfg.CanonicalURL,
48+
checksums: make(map[string]string),
49+
hash: md5.New(),
50+
Version: version.Version,
51+
Commit: version.Commit,
52+
RootURL: cfg.RootURL,
53+
CanonicalURL: cfg.CanonicalURL,
54+
AllowIndexing: cfg.AllowIndexing,
5455
}
5556
if cfg.RootPath != "" {
5657
basePageConfig.RootPath = "/" + cfg.RootPath

internal/frontend/templates/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
skribbl.io, scribble, scribblers, scribble.rs, pictionary,
1313
montagsmaler, sketchful, draw and guess, drawmything, free, oss">
1414
<link rel="canonical" href="{{.CanonicalURL}}" />
15+
{{if not .AllowIndexing}}
16+
<meta name="robots" content="noindex, nofollow">{{end}}
1517
{{if ne "" .RootURL}}
1618
<meta property="og:image" content="{{.RootURL}}{{.RootPath}}/resources/logo.png">
1719
<meta property="og:image:type" content="image/png">

0 commit comments

Comments
 (0)