-
-
Notifications
You must be signed in to change notification settings - Fork 253
Add default error.hbs and error-404.hbs templates #145
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
Open
bst1n
wants to merge
5
commits into
TryGhost:main
Choose a base branch
from
bst1n:add-default-error-pages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b9d85f1
Add default error.hbs and error-404.hbs templates
bst1n 7d8c9c3
Use translatable 'Page not found' string instead of Ghost's raw message
bst1n 968ad85
Fix grid layout of recent posts section on 404 page
bst1n 74e20ad
Address review feedback on error templates
bst1n 5378f9d
Restore {{t}} helpers in error.hbs
bst1n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,44 @@ | ||
| {{!< default}} | ||
|
|
||
| {{!-- | ||
| 404 page. Inherits the default layout so visitors keep the theme's | ||
| navigation, footer, and overall look while they figure out where to go. | ||
| --}} | ||
|
|
||
| <main class="gh-main"> | ||
|
|
||
| <article class="gh-article gh-canvas"> | ||
|
|
||
| <header class="gh-article-header"> | ||
| <h1 class="gh-article-title is-title">{{statusCode}}</h1> | ||
| <p class="gh-article-excerpt is-body">{{t "Page not found"}}</p> | ||
| </header> | ||
|
|
||
| <section class="gh-content is-body"> | ||
| <p> | ||
| <a href="{{@site.url}}" class="gh-button">{{t "Go to the front page →"}}</a> | ||
| </p> | ||
| </section> | ||
|
|
||
| </article> | ||
|
|
||
| </main> | ||
|
|
||
| {{!-- Visitors landing here didn't find what they were looking for. | ||
| Suggest a few recent posts to help them re-engage. --}} | ||
| {{#get "posts" include="authors" limit="3" as |suggested|}} | ||
| {{#if suggested}} | ||
| <section class="gh-container is-grid gh-outer"> | ||
| <div class="gh-container-inner gh-inner"> | ||
| <h2 class="gh-container-title">{{t "Recent posts"}}</h2> | ||
| <div class="gh-main"> | ||
| <div class="gh-feed"> | ||
| {{#foreach suggested}} | ||
| {{> "post-card" lazyLoad=true}} | ||
| {{/foreach}} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| {{/if}} | ||
| {{/get}} |
This file contains hidden or 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,86 @@ | ||
| {{!-- | ||
| Generic error template — handles all non-404 errors (500, etc.). | ||
| Standalone (doesn't extend default.hbs) and kept lightweight on | ||
| purpose: minimal dependencies, no partials, no API calls. | ||
|
|
||
| The reasoning mirrors Casper's: 500 errors usually happen when | ||
| something on the server is struggling, so we don't want the error | ||
| page itself to compound the issue. Keep this template as | ||
| self-contained as possible. | ||
| --}} | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="{{@site.locale}}"> | ||
| <head> | ||
| <title>{{meta_title}}</title> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <link rel="stylesheet" type="text/css" href="{{asset "built/screen.css"}}"> | ||
| <style> | ||
| :root { | ||
| --background-color: {{@custom.site_background_color}} | ||
| } | ||
| </style> | ||
|
|
||
| <script> | ||
| /* The script for calculating the color contrast has been taken from | ||
| https://gomakethings.com/dynamically-changing-the-text-color-based-on-background-color-contrast-with-vanilla-js/ */ | ||
| var accentColor = getComputedStyle(document.documentElement).getPropertyValue('--background-color'); | ||
| accentColor = accentColor.trim().slice(1); | ||
|
|
||
| if (accentColor.length === 3) { | ||
| accentColor = accentColor[0] + accentColor[0] + accentColor[1] + accentColor[1] + accentColor[2] + accentColor[2]; | ||
| } | ||
|
|
||
| var r = parseInt(accentColor.substr(0, 2), 16); | ||
| var g = parseInt(accentColor.substr(2, 2), 16); | ||
| var b = parseInt(accentColor.substr(4, 2), 16); | ||
| var yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000; | ||
| var textColor = (yiq >= 128) ? 'dark' : 'light'; | ||
|
|
||
| document.documentElement.className = `has-${textColor}-text`; | ||
| </script> | ||
|
|
||
| {{ghost_head}} | ||
| </head> | ||
| <body class="{{body_class}}"> | ||
|
|
||
| <main class="gh-main"> | ||
|
|
||
| <article class="gh-article gh-canvas"> | ||
|
|
||
| <header class="gh-article-header"> | ||
| <h1 class="gh-article-title is-title">{{statusCode}}</h1> | ||
| <p class="gh-article-excerpt is-body">{{message}}</p> | ||
| </header> | ||
|
|
||
| <section class="gh-content is-body"> | ||
| <p> | ||
| <a href="{{@site.url}}" class="gh-button">{{t "Go to the front page →"}}</a> | ||
| </p> | ||
| </section> | ||
|
|
||
| {{#if errorDetails}} | ||
| <section class="gh-content is-body"> | ||
| <h3>{{t "Theme errors"}}</h3> | ||
| <ul> | ||
| {{#foreach errorDetails}} | ||
| <li> | ||
| <strong>{{rule}}</strong> | ||
| {{#foreach failures}} | ||
| <p>{{ref}}: {{message}}</p> | ||
| {{/foreach}} | ||
| </li> | ||
| {{/foreach}} | ||
| </ul> | ||
| </section> | ||
| {{/if}} | ||
|
|
||
| </article> | ||
|
|
||
| </main> | ||
|
|
||
| {{ghost_foot}} | ||
|
|
||
| </body> | ||
| </html> | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.