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

fix(layouts): index.redirects truncates newline #775

Merged
merged 1 commit into from
Jun 21, 2022

Conversation

james-d-elliott
Copy link
Contributor

@james-d-elliott james-d-elliott commented Jun 5, 2022

Summary

This fixes an issue where the generation of aliases may remove newlines erroneously moving subsequent lines to the same line as the last alias or otherwise mangle the output.

Basic example

Can be tested in a short-code with the following content rendered in a fence (you can also see the output of the original using this method just with the original template; you can also replace .Aliases with dict to see what it does with an empty enumerable I believe):

start
{{- range $p := .Site.Pages }}
{{- range .Aliases }}
{{ . }} {{ $p.RelPermalink }}
{{- end }}
{{- end }}
end

Motivation

This prevents an error in netlify about a redirect which is improperly formatted.

Checks

  • Read Create a Pull Request
  • Supports all screen sizes (if relevant)
  • Supports both light and dark mode (if relevant)
  • Passes npm run test

This fixes an issue where the generation of aliases may remove newlines erroneously moving subsequent lines to the same line as the last alias or otherwise mangle the output.
Copy link
Member

@h-enk h-enk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested/verified. Thanks!

Example, before:

/introduction/ /docs/prologue/introduction/
/quick-start/ /docs/prologue/quick-start/
/commands/ /docs/prologue/commands/# /docs/1.0/prologue/   /docs/1.0/prologue/introduction/
# /docs/1.0/help/       /docs/1.0/help/how-to-update/
# /docs/1.0/            /docs/1.0/prologue/introduction/
# /docs/                /docs/1.0/prologue/introduction/
#
# /docs/0.1/*           https://v0-1-0--doks-versioning-poc.netlify.app/docs/0.1/:splat  200
# /docs/0.2/*           https://v0-2-0--doks-versioning-poc.netlify.app/docs/0.2/:splat  200

Example, after:


/introduction/ /docs/prologue/introduction/
/quick-start/ /docs/prologue/quick-start/
/commands/ /docs/prologue/commands/

# /docs/1.0/prologue/   /docs/1.0/prologue/introduction/
# /docs/1.0/help/       /docs/1.0/help/how-to-update/
# /docs/1.0/            /docs/1.0/prologue/introduction/
# /docs/                /docs/1.0/prologue/introduction/
#
# /docs/0.1/*           https://v0-1-0--doks-versioning-poc.netlify.app/docs/0.1/:splat  200
# /docs/0.2/*           https://v0-2-0--doks-versioning-poc.netlify.app/docs/0.2/:splat  200

@h-enk h-enk added this to the v0.5.0 milestone Jun 21, 2022
@h-enk h-enk merged commit 9845b82 into thuliteio:master Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants