-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'i7-robots-txt' into 'main'
Add an extensible template for robots.txt Closes #7 See merge request tpo/web/lego!65
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
_template: robots.txt | ||
--- | ||
_discoverable: no | ||
--- | ||
_model: none |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{%- macro capitalize_first(text) -%} | ||
{{- text[0].upper() -}}{{- text[1:] -}} | ||
{%- endmacro -%} | ||
User-agent: * | ||
Disallow: /javascript/* | ||
Disallow: /scss/* | ||
Disallow: /static/* | ||
|
||
{#- the '\n' is because we need a newline, | ||
but we need to strip trailing and leading whitespace as well. | ||
fragile, be careful #} | ||
{% for user_agent, directives in bag('robots_txt').items() -%} | ||
{{ '\n' }}User-agent: {{ user_agent }} | ||
{%- for directive, values in directives.items() -%} | ||
{%- for value in values -%} | ||
{{ '\n' }}{{ capitalize_first(directive) }}: {{ value -}} | ||
{% endfor -%} | ||
{% endfor %} | ||
{% endfor %} |