Skip to content

Commit

Permalink
Add redirect to naked URL across our docs (#17464)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickvigilante authored Jul 19, 2023
1 parent b8cbc88 commit 2fefee9
Show file tree
Hide file tree
Showing 52 changed files with 96 additions and 66 deletions.
16 changes: 1 addition & 15 deletions src/current/_data/redirects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,8 @@
# https://docs.netlify.com/routing/redirects/redirect-options/#splats
############################################################

- destination: v19.1/:splat
sources: ['v2.2/*']
force: true

- destination: cockroachcloud/:splat
sources: ['managed/*']
force: true

- destination: releases/index.md
sources: ['releases/']
force: true

- destination: advisories/index.md
sources:
- advisories/
- advisories/advisories.md
sources: ['advisories/advisories.md']

# Pages undergoing maintenance

Expand Down
7 changes: 5 additions & 2 deletions src/current/_includes/sidebar.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
// This condition makes it possible to use external
// urls in the sidebar.
if (!/^https?:/.test(url)) {
url = sidebar.baseUrl + url.replace(".html", "");
url = sidebar.baseUrl + url.replace("/index.html", "").replace(".html", "");
}
return url;
});
Expand All @@ -110,7 +110,10 @@
else {
activePathname = location.pathname
}
if (location.pathname.slice(-5) === '.html') {
if (location.pathname.includes("/index.html")) {
activePathname = activePathname.replace("/index.html", "/")
}
if (location.pathname.includes(".html")) {
activePathname = activePathname.replace(".html", "")
}
// console.log(urls);
Expand Down
8 changes: 4 additions & 4 deletions src/current/_includes/version-switcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<ul class="list-unstyled" style="display: none">
{% for v in page.versions %}
<li class="tier-2 {% if v.version == page.version %}active{% endif %}">
<a
<a data-proofer-ignore
{% if v.url %}
href="{{ v.url | relative_url }}"
href="{{ v.url | relative_url | replace: "/index.html", "" | replace: ".html", "" | downcase }}"
class="version--mobile"
{% else %}
class="version--mobile version--page-dne"
Expand All @@ -24,9 +24,9 @@
</span>
{% endunless %}
</a>
<a
<a data-proofer-ignore
{% if v.url %}
href="{{ v.url | relative_url }}"
href="{{ v.url | relative_url | replace: "/index.html", "" | replace: ".html", "" | downcase }}"
class="version--desktop"
{% else %}
class="version--desktop version--page-dne"
Expand Down
2 changes: 1 addition & 1 deletion src/current/_plugins/versions/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def generate
page.data['release_info'] = vp.release_info
page.data['sidebar_data'] ||= vp.sidebar_data
canonical = stable_vp(vp.key)&.url || page.url
page.data['canonical'] ||= canonical.sub('.html', '')
page.data['canonical'] ||= canonical.sub('/index.html', '').sub('.html', '').downcase

page.data['versions'] = versions.map do |v|
{ 'version' => v, 'url' => vps_with_key(vp.key)[v]&.url }
Expand Down
5 changes: 5 additions & 0 deletions src/current/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ layout: null
# Release notes generated from _data/redirects.yml
{% if site.baseurl == "/docs" %}
/ /docs/ 301!
/docs/managed/* /docs/cockroachcloud/:splat 301!
/docs/api/cloud /docs/api/cloud/v1 301!
/docs/api/cloud/ /docs/api/cloud/v1 301!
/docs/api/cluster /docs/api/cluster/v2 301!
/docs/api/cluster/ /docs/api/cluster/v2 301!
{% assign major_versions = site.data.versions | map: "major_version" -%}

{%- for r in site.data.redirects -%}
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion src/current/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build]
base = "src/current/"
publish = "_site/"
command = "./build-netlify.sh"
command = "netlify/build.sh"
[build.environment]
NODE_VERSION = "18.14.0"
RUBY_VERSION = "3.2.1"
Expand All @@ -18,6 +18,10 @@
[build.processing.images]
compress = false

[[edge_functions]]
function = "pretty-urls"
path = "/*"

#[[plugins]]
# package = "@netlify/plugin-lighthouse"
# [plugins.inputs]
Expand Down
File renamed without changes.
33 changes: 33 additions & 0 deletions src/current/netlify/edge-functions/pretty-urls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// adapted from https://github.com/ascorbic/slash-edge/blob/main/lib/strip-slash.ts

import { Context } from 'https://edge.netlify.com'

export default async function handler(request: Request, context: Context) {
const { pathname } = new URL(request.url)
// Skip for root, or if we're already proxying the request
const pathsToSkip = [
/\/docs\/.*?\/contribute-to-cockroachdb(\.html)?/,
/\/docs\/.*?\/build-a-python-app-with-cockroachdb-peewee(\.html)?/,
/\/docs\/css\/.*?/,
/\/docs\/js\/.*?/,
/\/docs\/_redirects/,
/\/docs(\/(advisories|api|cockroachcloud|releases|tutorials|v\d{1,2}\.\d(\/(architecture|security-reference))?))?\/?$/
];

function canonicalize(pathname: string) {
let result = pathname.replace("/index.html", "").replace(".html", "").toLowerCase();
if (result.endsWith("/")) {
result = result.slice(0, -1);
}
return result;
}

let canonical = canonicalize(pathname);

if (pathname === '/' || request.headers.get('x-nf-subrequest') || pathsToSkip.some(x => x.test(pathname) || pathname === canonical)) {
return
}

return Response.redirect(`${canonicalize(request.url)}`, 301)

}
1 change: 0 additions & 1 deletion src/current/releases/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ summary: Release notes for older versions of CockroachDB.
toc: true
docs_area: releases
toc_not_nested: true
canonical: /releases/index.html
---

{% comment %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestrate CockroachDB with Kubernetes
summary: How to orchestrate the deployment and management of an insecure 3-node CockroachDB cluster with Kubernetes.
toc: true
canonical: /stable/deploy-cockroachdb-with-kubernetes.html
canonical: /stable/deploy-cockroachdb-with-kubernetes
---

This page shows you how to orchestrate the deployment and management of an insecure 3-node CockroachDB cluster with [Kubernetes](http://kubernetes.io/), using the [StatefulSet](http://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/) feature.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v1.0/orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestration
summary:
toc: false
canonical: /stable/kubernetes-overview.html
canonical: /stable/kubernetes-overview
---

Orchestration systems automate the deployment, scaling, and management of containerized applications. Combined with CockroachDB's [automated sharding](frequently-asked-questions.html#how-does-cockroachdb-scale) and [fault tolerance](frequently-asked-questions.html#how-does-cockroachdb-survive-failures), they have the potential to lower operator overhead to almost nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestrate CockroachDB with Kubernetes (Insecure)
summary: How to orchestrate the deployment and management of an insecure 3-node CockroachDB cluster with Kubernetes.
toc: true
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure.html
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure
---

<div class="filters filters-big clearfix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Orchestrate CockroachDB with Kubernetes
summary: How to orchestrate the deployment and management of a secure 3-node CockroachDB cluster with Kubernetes.
toc: true
secure: true
canonical: /stable/deploy-cockroachdb-with-kubernetes.html
canonical: /stable/deploy-cockroachdb-with-kubernetes
---

<div class="filters filters-big clearfix">
Expand Down
2 changes: 1 addition & 1 deletion src/current/v1.1/orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestration
summary: Learn how to run CockroachDB with popular open-source orchestration systems.
toc: false
canonical: /stable/kubernetes-overview.html
canonical: /stable/kubernetes-overview
---

Orchestration systems automate the deployment, scaling, and management of containerized applications. Combined with CockroachDB's [automated sharding](frequently-asked-questions.html#how-does-cockroachdb-scale) and [fault tolerance](frequently-asked-questions.html#how-does-cockroachdb-survive-failures), they have the potential to lower operator overhead to almost nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Orchestrate CockroachDB in a Single Kubernetes Cluster (Insecure)
summary: How to orchestrate the deployment, management, and monitoring of an insecure 3-node CockroachDB cluster with Kubernetes.
toc: true
toc_not_nested: true
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure.html
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure
---

<div class="filters filters-big clearfix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ summary: How to orchestrate the deployment, management, and monitoring of a secu
toc: true
toc_not_nested: true
secure: true
canonical: /stable/deploy-cockroachdb-with-kubernetes.html
canonical: /stable/deploy-cockroachdb-with-kubernetes
---

<div class="filters filters-big clearfix">
Expand Down
2 changes: 1 addition & 1 deletion src/current/v19.1/orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestration
summary: Learn how to run CockroachDB with popular open-source orchestration systems.
toc: false
canonical: /stable/kubernetes-overview.html
canonical: /stable/kubernetes-overview
---

Orchestration systems automate the deployment, scaling, and management of containerized applications. Combined with CockroachDB's [automated sharding](frequently-asked-questions.html#how-does-cockroachdb-scale) and [fault tolerance](frequently-asked-questions.html#how-does-cockroachdb-survive-failures), they have the potential to lower operator overhead to almost nothing.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v19.2/multi-region-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Develop a Multi-Region Web Application
summary: This page includes instructions for building a multi-region web application on CockroachDB, using Flask and SQLAlchemy.
toc: true
canonical: /stable/movr-flask-application.html
canonical: /stable/movr-flask-application
---

This page walks you through developing a multi-region application. It is the fourth section of the [Develop and Deploy a Multi-Region Web Application](multi-region-overview.html) tutorial.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v19.2/multi-region-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Create a Multi-Region Database Schema
summary: This page documents the database schema for the multi-region Flask application built on CockroachDB.
toc: true
canonical: /stable/movr-flask-database.html
canonical: /stable/movr-flask-database
---

This page walks you through creating a database schema for an example multi-region application. It is the second section of the [Develop and Deploy a Multi-Region Web Application](multi-region-overview.html) tutorial.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v19.2/multi-region-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Deploy a Multi-Region Web Application
summary: This page includes instructions for deploying a multi-region web application using CockroachCloud and Google Cloud services.
toc: true
canonical: /stable/movr-flask-deployment.html
canonical: /stable/movr-flask-deployment
---

This page walks you through deploying an application and database in multiple regions. It is the fifth and final section of the [Develop and Deploy a Multi-Region Web Application](multi-region-overview.html) tutorial.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v19.2/multi-region-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Develop and Deploy a Multi-Region Web Application
summary: Learn how to build and deploy a multi-region web application on CockroachDB, using Flask, SQLAlchemy, CockroachCloud, and Google Cloud services.
toc: true
canonical: /stable/movr-flask-overview.html
canonical: /stable/movr-flask-overview
---

This tutorial walks you through developing and deploying a multi-region web application built on CockroachDB, using Flask, SQLAlchemy, CockroachCloud, and Google Cloud Platform services.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v19.2/multi-region-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Set Up a Virtual Environment for Developing Multi-Region Applications
summary: This page walks you through setting up a demo multi-region CockroachDB cluster, and a virtual development environment.
toc: true
canonical: /stable/movr-flask-setup.html
canonical: /stable/movr-flask-setup
---

This page walks you through setting up a virtual environment for developing and debugging an example multi-region application. It is the third section of the [Develop and Deploy a Multi-Region Web Application](multi-region-overview.html) tutorial. In this section, you will set up a demo CockroachDB cluster, initialize the database, and set up a virtual development environment.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v19.2/multi-region-use-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: MovR&#58; An Example Multi-Region Use-Case
summary: This page covers an example use-case for multi-region applications.
toc: true
canonical: /stable/movr-flask-use-case.html
canonical: /stable/movr-flask-use-case
---

This page walks you through an example use case for multi-region application development and deployment. It is the first section of the [Develop and Deploy a Multi-Region Web Application](multi-region-overview.html) tutorial.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Orchestrate CockroachDB in a Single Kubernetes Cluster (Insecure)
summary: How to orchestrate the deployment, management, and monitoring of an insecure 3-node CockroachDB cluster with Kubernetes.
toc: true
toc_not_nested: true
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure.html
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure
---

<div class="filters filters-big clearfix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ summary: How to orchestrate the deployment, management, and monitoring of a secu
toc: true
toc_not_nested: true
secure: true
canonical: /stable/deploy-cockroachdb-with-kubernetes.html
canonical: /stable/deploy-cockroachdb-with-kubernetes
---

<div class="filters filters-big clearfix">
Expand Down
2 changes: 1 addition & 1 deletion src/current/v19.2/orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestration
summary: Learn how to run CockroachDB with popular open-source orchestration systems.
toc: false
canonical: /stable/kubernetes-overview.html
canonical: /stable/kubernetes-overview
---

Orchestration systems automate the deployment, scaling, and management of containerized applications. Combined with CockroachDB's [automated sharding](frequently-asked-questions.html#how-does-cockroachdb-scale) and [fault tolerance](frequently-asked-questions.html#how-does-cockroachdb-survive-failures), they have the potential to lower operator overhead to almost nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestrate CockroachDB with Kubernetes (Insecure)
summary: How to orchestrate the deployment, management, and monitoring of an insecure 3-node CockroachDB cluster with Kubernetes.
toc: true
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure.html
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure
---

<div class="filters filters-big clearfix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Orchestrate CockroachDB with Kubernetes
summary: How to orchestrate the deployment, management, and monitoring of a secure 3-node CockroachDB cluster with Kubernetes.
toc: true
secure: true
canonical: /stable/deploy-cockroachdb-with-kubernetes.html
canonical: /stable/deploy-cockroachdb-with-kubernetes
---

<div class="filters filters-big clearfix">
Expand Down
2 changes: 1 addition & 1 deletion src/current/v2.0/orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestration
summary: Learn how to run CockroachDB with popular open-source orchestration systems.
toc: false
canonical: /stable/kubernetes-overview.html
canonical: /stable/kubernetes-overview
---

Orchestration systems automate the deployment, scaling, and management of containerized applications. Combined with CockroachDB's [automated sharding](frequently-asked-questions.html#how-does-cockroachdb-scale) and [fault tolerance](frequently-asked-questions.html#how-does-cockroachdb-survive-failures), they have the potential to lower operator overhead to almost nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestrate CockroachDB in a Single Kubernetes Cluster (Insecure)
summary: How to orchestrate the deployment, management, and monitoring of an insecure 3-node CockroachDB cluster with Kubernetes.
toc: true
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure.html
canonical: /stable/deploy-cockroachdb-with-kubernetes-insecure
---

<div class="filters filters-big clearfix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Orchestrate CockroachDB in a Single Kubernetes Cluster
summary: How to orchestrate the deployment, management, and monitoring of a secure 3-node CockroachDB cluster with Kubernetes.
toc: true
secure: true
canonical: /stable/deploy-cockroachdb-with-kubernetes.html
canonical: /stable/deploy-cockroachdb-with-kubernetes
---

<div class="filters filters-big clearfix">
Expand Down
2 changes: 1 addition & 1 deletion src/current/v2.1/orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Orchestration
summary: Learn how to run CockroachDB with popular open-source orchestration systems.
toc: false
canonical: /stable/kubernetes-overview.html
canonical: /stable/kubernetes-overview
---

Orchestration systems automate the deployment, scaling, and management of containerized applications. Combined with CockroachDB's [automated sharding](frequently-asked-questions.html#how-does-cockroachdb-scale) and [fault tolerance](frequently-asked-questions.html#how-does-cockroachdb-survive-failures), they have the potential to lower operator overhead to almost nothing.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v20.1/multi-region-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Develop a Multi-Region Web Application
summary: This page includes instructions for building a multi-region web application on CockroachDB, using Flask and SQLAlchemy.
toc: true
canonical: /stable/movr-flask-application.html
canonical: /stable/movr-flask-application
---

This page walks you through developing a multi-region application. It is the fourth section of the [Develop and Deploy a Multi-Region Web Application](multi-region-overview.html) tutorial.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v20.1/multi-region-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Create a Multi-Region Database Schema
summary: This page documents the database schema for the multi-region Flask application built on CockroachDB.
toc: true
canonical: /stable/movr-flask-database.html
canonical: /stable/movr-flask-database
---

This page walks you through creating a database schema for an example multi-region application. It is the second section of the [Develop and Deploy a Multi-Region Web Application](multi-region-overview.html) tutorial.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v20.1/multi-region-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Deploy a Multi-Region Web Application
summary: This page includes instructions for deploying a multi-region web application using CockroachCloud and Google Cloud services.
toc: true
canonical: /stable/movr-flask-deployment.html
canonical: /stable/movr-flask-deployment
---

This page walks you through deploying an application and database in multiple regions. It is the fifth and final section of the [Develop and Deploy a Multi-Region Web Application](multi-region-overview.html) tutorial.
Expand Down
2 changes: 1 addition & 1 deletion src/current/v20.1/multi-region-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Develop and Deploy a Multi-Region Web Application
summary: Learn how to build and deploy a multi-region web application on CockroachDB, using Flask, SQLAlchemy, CockroachCloud, and Google Cloud services.
toc: true
canonical: /stable/movr-flask-overview.html
canonical: /stable/movr-flask-overview
---

This tutorial walks you through developing and deploying a multi-region web application built on CockroachDB, using Flask, SQLAlchemy, CockroachCloud, and Google Cloud Platform services.
Expand Down
Loading

0 comments on commit 2fefee9

Please sign in to comment.