Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /schemas in YAML, /schemas/list in HTML, and a 404 page for the rest #3537

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .htmltest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ IgnoreAltMissing: true
IgnoreCanonicalBrokenLinks: false
CheckMailto: false
IgnoreInternalURLs: # list of paths
- /schemas/latest
IgnoreURLs: # list of regexs of paths or URLs to be ignored
- ^/docs/instrumentation/\w+/(api|examples)/$
- ^/docs/instrumentation/net/(metrics-api|traces-api)/
Expand Down
22 changes: 22 additions & 0 deletions assets/scss/_schema.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.ot-schema-list,
.ot-schemas-404 {
// Hide the sidebar. Add the sidebar's number of col to `main`
main {
@extend .col-md-10;
}

.td-sidebar {
display: none;
}

main td code {
background-color: inherit;
}

// Fixes https://github.com/open-telemetry/opentelemetry.io/issues/1102
// TODO: upstream
.td-sidebar-toc {
margin-top: 4rem;
top: 0;
}
}
1 change: 1 addition & 0 deletions assets/scss/_styles_project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import 'registry';
@import 'tabs';
@import 'external_link';
@import 'schema';

.td-home {
.otel-logo {
Expand Down
25 changes: 25 additions & 0 deletions content/en/schemas/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: 404 - Schema not found
linkTitle: Schemas
type: docs
no_list: true
body_class: ot-schemas-404
outputs: [HTML, YAML]
#
# Note:
# The paths to the `list` and `latest` are absolute below since we
# don't know from which URL this 404 page will be served.
#
---

The page or schema you requested doesn't exist. Maybe you're looking for one of
these:

- [List of schemas](/schemas/index.yaml) hosted on this site, also available in
a [human-readable format](/schemas/list/)
- [Latest](/schemas/latest) schema
- More information about [Telemetry Schemas] in general, or [OpenTelemetry
Schema] in particular.

[OpenTelemetry Schema]: /docs/specs/otel/schemas/#opentelemetry-schema
[Telemetry Schemas]: /docs/specs/otel/schemas/
14 changes: 14 additions & 0 deletions content/en/schemas/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: OpenTelemetry Schemas
linkTitle: List
type: docs
body_class: ot-schema-list
---

The OpenTelemetry schemas hosted on this site are listed below. To learn more
about schemas, see [Telemetry Schemas][]. The list is also available in
[YAML format](/schemas/index.yaml).

{{% schemas %}}

[Telemetry Schemas]: /docs/specs/otel/schemas/
7 changes: 5 additions & 2 deletions hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ markup:
# noClasses: false
style: tango

# Netlify _redirects file
mediaTypes:
text/netlify: {}
text/netlify: {} # Netlify _redirects file
text/yaml: {}

outputFormats:
REDIRECTS:
mediaType: text/netlify
baseName: _redirects
notAlternative: true
YAML: # Yaml for Schemas index page
mediaType: text/yaml
baseName: index.yaml

outputs:
home: [HTML, REDIRECTS, RSS]
Expand Down
3 changes: 3 additions & 0 deletions layouts/index.redirects
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
{{ $schemaFiles := partial "schema-file-list" . -}}
{{ $latestSchemaFile := index $schemaFiles 0 -}}

/schemas /schemas/index.yaml 301!
/schemas/latest /schemas/{{ $latestSchemaFile.Name }}
/schemas/list /schemas/list/ 200 # Explicit rule to avoid the next catch all
/schemas/* /schemas/index.html 404 # Report 404 for anything else that's missing

{{/*
Social-media image redirects. As mentioned in
Expand Down
10 changes: 10 additions & 0 deletions layouts/schemas/section.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{ $schemaFiles := partial "schema-file-list" . -}}
{{ $latestSchemaFile := index $schemaFiles 0 -}}
# OpenTelemetry Schemas v{{ $latestSchemaFile.Name }}
#
# For details, see https://opentelemetry.io/schemas/list

{{ $schemaFiles := partial "schema-file-list.html" . -}}
{{- range $schemaFiles -}}
- {{ .Name }}
{{ end -}}
10 changes: 10 additions & 0 deletions layouts/shortcodes/schemas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- $schemaFiles := partial "schema-file-list.html" . -}}

| Version |
|---------|
{{ range $i, $schema := $schemaFiles -}}
| [`{{ $schema.Name }}`](/schemas/{{ $schema.Name }})
{{- if eq $i 0 -}}
([latest](/schemas/latest))
{{- end -}} |
{{ end -}}
24 changes: 23 additions & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,29 @@ from = "https://blog.opentelemetry.io/*"
to = "https://opentelemetry.io/blog/:splat"
force = true

# Schemas

[[headers]]
for = "/schemas/index.yaml"
[headers.values]
content-type = "text/yaml"

# Ensure that there is a header entry for each major version of the published
# schemas. (If this becomes too bothersome to update, we can automate the
# creation of these schema header entries in a `_headers` file using Hugo
# templating constructs.)

[[headers]]
for = "/schemas/1.*"
[headers.values]
content-type = "application/yaml"

[[headers]]
for = "/schemas/2.*"
[headers.values]
content-type = "application/yaml"

[[headers]]
for = "/schemas/:version"
for = "/schemas/3.*"
[headers.values]
content-type = "application/yaml"