Skip to content

Instantly share code, notes, and snippets.

@DavidWells
Last active February 8, 2025 01:55
Show Gist options
  • Save DavidWells/4182dff83d9eedcca8f93c72a94f3ea5 to your computer and use it in GitHub Desktop.
Save DavidWells/4182dff83d9eedcca8f93c72a94f3ea5 to your computer and use it in GitHub Desktop.
Yaml and Toml

Which is better? YOU DECIDE

# toml
[build]
  command = "npm run build"
  publish = "build"
  functions = "functions-build"

[[headers]]
  for = "/baz"
  [headers.values]
    X-Frame-Options = "DENY"
[[headers]]
  for = "/*"
  [headers.values]
    Cache-Control= "no-cache, no-store, must-revalidate"
    X-Frame-Options = "DENY"
    X-XSS-Protection = "1; mode=block"
    Link = '''
    </style1.css>; rel=preload; as=stylesheet, \
    </style2.css>; rel=preload; as=stylesheet, \
    </style3.css>; rel=preload; as=stylesheet'''

[[redirects]]
  from = "/*"
  to = "/.netlify/functions/do-login"
  status = 302
  force = true
  query = {site = ":site"}
  conditions = {Role = ["admin"]}
[[redirects]]
  from = "/foo"
  to = "/bar"
  status = 200
# yml
build:
  command: npm run build
  publish: build
  functions: functions-build

headers:
  - for: /baz
    values:
      X-Frame-Options: DENY
  - for: /*
    values:
      Cache-Control: no-cache, no-store, must-revalidate
      X-Frame-Options: DENY
      X-XSS-Protection: 1; mode=block
      Link: |
        </style1.css>; rel=preload; as=stylesheet,
        </style2.css>; rel=preload; as=stylesheet,
        </style3.css>; rel=preload; as=stylesheet

redirects:
  - from: /*
    to: /.netlify/functions/do-login
    status: 302
    force: true
    query: {site = ":site"}
    conditions: { Role: [admin] }
  - from: /foo
    to: /bar
    status: 200
    force: true

P.s. TOML can't handle brackets in double quotes...

@DavidWells
Copy link
Author

@DrSensor
Copy link

@DavidWells
Copy link
Author

@DavidWells
Copy link
Author

@CanRau
Copy link

CanRau commented Jul 21, 2023

@DavidWells
Copy link
Author

@CanRau
Copy link

CanRau commented Feb 8, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment