-
-
Notifications
You must be signed in to change notification settings - Fork 857
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- improve documentation, - remove extra empty line in the rendered file, - don't generate API redirects for non-product pages.
- Loading branch information
1 parent
e0cb381
commit 28f5adb
Showing
1 changed file
with
21 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,29 @@ | ||
--- | ||
# Netlify _redirects template. Documentation can be found on https://docs.netlify.com/routing/redirects/. | ||
# | ||
# The _redirects file is included in _config.yml/include key otherwise Jekyll doesn't copy it to | ||
# _site directory, where Netlify expects it. | ||
# | ||
# To create a new redirect, add an alternate_urls array in the page front-matter. | ||
|
||
# Setting a layout forces Jekyll to render this file | ||
layout: null | ||
--- | ||
{% comment %} | ||
|
||
The following loop creates a _redirects file as per | ||
Netlify's syntax: https://docs.netlify.com/routing/redirects/ | ||
|
||
This also creates a lot of whitespace in the resulting file. | ||
|
||
To create a new redirect, add a alternate_urls array in the page front-matter. | ||
|
||
The _redirects file is included in _config.yml/include key otherwise | ||
Jekyll doesn't copy it to _site directory, where Netlify expects it. | ||
|
||
The Redirect syntax is | ||
/redirect-this /to-that | ||
|
||
{% endcomment %} | ||
{% for page in site.pages %} | ||
|
||
{% if page.alternate_urls %} | ||
|
||
{%- for page in site.pages -%} | ||
# Redirects for {{page.path}} | ||
{% for url in page.alternate_urls %} | ||
{%- if page.alternate_urls %} | ||
{%- for url in page.alternate_urls %} | ||
{{url}} {{page.permalink}} | ||
/api{{url}}.json /api{{page.permalink}}.json | ||
/api{{url}}/* /api{{page.permalink}}/:splat | ||
{% endfor %} | ||
{% endif %} | ||
/api{{page.permalink}} /api{{page.permalink}}.json | ||
{%- endfor %} | ||
{%- endif %} | ||
{%- if page.layout == 'product' %} | ||
/api{{page.permalink}} /api{{page.permalink}}.json | ||
{%- if page.alternate_urls %} | ||
{%- for url in page.alternate_urls %} | ||
/api{{url}}.json /api{{page.permalink}}.json | ||
/api{{url}}/* /api{{page.permalink}}/:splat | ||
{%- endfor %} | ||
{%- endif %} | ||
{%- endif %} | ||
|
||
{% endfor %} |