Skip to content

Commit

Permalink
add 404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed May 10, 2021
1 parent 05c193f commit dabb92f
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 277 deletions.
213 changes: 0 additions & 213 deletions ace-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,219 +60,6 @@
"args": [],
"aliases": [],
"flags": []
},
"db:seed": {
"settings": {
"loadApp": true
},
"commandPath": "@adonisjs/lucid/build/commands/DbSeed",
"commandName": "db:seed",
"description": "Execute database seeder files",
"args": [],
"aliases": [],
"flags": [
{
"name": "connection",
"propertyName": "connection",
"type": "string",
"description": "Define a custom database connection for the seeders",
"alias": "c"
},
{
"name": "interactive",
"propertyName": "interactive",
"type": "boolean",
"description": "Run seeders in interactive mode",
"alias": "i"
},
{
"name": "files",
"propertyName": "files",
"type": "array",
"description": "Define a custom set of seeders files names to run",
"alias": "f"
}
]
},
"make:model": {
"settings": {},
"commandPath": "@adonisjs/lucid/build/commands/MakeModel",
"commandName": "make:model",
"description": "Make a new Lucid model",
"args": [
{
"type": "string",
"propertyName": "name",
"name": "name",
"required": true,
"description": "Name of the model class"
}
],
"aliases": [],
"flags": [
{
"name": "migration",
"propertyName": "migration",
"type": "boolean",
"alias": "m",
"description": "Generate the migration for the model"
},
{
"name": "controller",
"propertyName": "controller",
"type": "boolean",
"alias": "c",
"description": "Generate the controller for the model"
}
]
},
"make:migration": {
"settings": {
"loadApp": true
},
"commandPath": "@adonisjs/lucid/build/commands/MakeMigration",
"commandName": "make:migration",
"description": "Make a new migration file",
"args": [
{
"type": "string",
"propertyName": "name",
"name": "name",
"required": true,
"description": "Name of the migration file"
}
],
"aliases": [],
"flags": [
{
"name": "connection",
"propertyName": "connection",
"type": "string",
"description": "Define a custom database connection for the migration"
},
{
"name": "folder",
"propertyName": "folder",
"type": "string",
"description": "Pre-select a migration directory"
},
{
"name": "create",
"propertyName": "create",
"type": "string",
"description": "Define the table name for creating a new table"
},
{
"name": "table",
"propertyName": "table",
"type": "string",
"description": "Define the table name for altering an existing table"
}
]
},
"make:seeder": {
"settings": {},
"commandPath": "@adonisjs/lucid/build/commands/MakeSeeder",
"commandName": "make:seeder",
"description": "Make a new Seeder file",
"args": [
{
"type": "string",
"propertyName": "name",
"name": "name",
"required": true,
"description": "Name of the seeder class"
}
],
"aliases": [],
"flags": []
},
"migration:run": {
"settings": {
"loadApp": true
},
"commandPath": "@adonisjs/lucid/build/commands/Migration/Run",
"commandName": "migration:run",
"description": "Run pending migrations",
"args": [],
"aliases": [],
"flags": [
{
"name": "connection",
"propertyName": "connection",
"type": "string",
"description": "Define a custom database connection",
"alias": "c"
},
{
"name": "force",
"propertyName": "force",
"type": "boolean",
"description": "Explicitly force to run migrations in production"
},
{
"name": "dry-run",
"propertyName": "dryRun",
"type": "boolean",
"description": "Print SQL queries, instead of running the migrations"
}
]
},
"migration:rollback": {
"settings": {
"loadApp": true
},
"commandPath": "@adonisjs/lucid/build/commands/Migration/Rollback",
"commandName": "migration:rollback",
"description": "Rollback migrations to a given batch number",
"args": [],
"aliases": [],
"flags": [
{
"name": "connection",
"propertyName": "connection",
"type": "string",
"description": "Define a custom database connection",
"alias": "c"
},
{
"name": "force",
"propertyName": "force",
"type": "boolean",
"description": "Explictly force to run migrations in production"
},
{
"name": "dry-run",
"propertyName": "dryRun",
"type": "boolean",
"description": "Print SQL queries, instead of running the migrations"
},
{
"name": "batch",
"propertyName": "batch",
"type": "number",
"description": "Define custom batch number for rollback. Use 0 to rollback to initial state"
}
]
},
"migration:status": {
"settings": {
"loadApp": true
},
"commandPath": "@adonisjs/lucid/build/commands/Migration/Status",
"commandName": "migration:status",
"description": "Check migrations current status.",
"args": [],
"aliases": [],
"flags": [
{
"name": "connection",
"propertyName": "connection",
"type": "string",
"description": "Define a custom database connection",
"alias": "c"
}
]
}
},
"aliases": {}
Expand Down
42 changes: 37 additions & 5 deletions commands/BuildStatic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { outputFile, copy } from 'fs-extra'
import { ProcessedDoc } from '@dimerapp/content'
import { BaseCommand } from '@adonisjs/core/build/standalone'

export default class BuildStatic extends BaseCommand {
Expand Down Expand Up @@ -27,20 +28,50 @@ export default class BuildStatic extends BaseCommand {
stayAlive: false,
}

private async generateHtmlFile(doc) {
/**
* Write file to the disk
*/
private async writeFile(filePath: string, html: string) {
await outputFile(this.application.publicPath(filePath), html)
this.logger.action('Create').succeeded(filePath)
}

/**
* Generate the html file from the processed doc
*/
private async generateHtmlFile(doc: ProcessedDoc) {
const Content = (await import('App/Services/Content')).default
const filePath = `${doc.url}.html`

const { html, error } = await Content.render(doc.url)

if (error) {
return this.logger.action('Create').failed(filePath, error)
}

await outputFile(this.application.publicPath(filePath), html)
this.logger.action('Create').succeeded(filePath)
await this.writeFile(filePath, html!)
}

/**
* Create the static error pages
*/
private async createErrorPages() {
const View = this.application.container.use('Adonis/Core/View')
const html = await View.render('errors.404')
await this.writeFile('404.html', html!)
}

/**
* Copies the _redirects file from root to the public
* folder
*/
private async createRedirectsFile() {
await copy(this.application.makePath('_redirects'), this.application.publicPath('_redirects'))
this.logger.action('COPY').succeeded('_redirects')
}

/**
* Run command
*/
public async run () {
const Content = (await import('App/Services/Content')).default
const docs: any[] = []
Expand All @@ -58,6 +89,7 @@ export default class BuildStatic extends BaseCommand {
await this.generateHtmlFile(doc)
}

await copy(this.application.makePath('_redirects'), this.application.publicPath('_redirects'))
await this.createRedirectsFile()
await this.createErrorPages()
}
}
37 changes: 37 additions & 0 deletions resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,40 @@ DOC CONTENT STYLES
padding-right: var(--toc-width);
}
}

.banner {
display: flex;
max-width: 700px;
margin: auto;
color: var(--text-color);
align-items: center;
justify-content: center;
height: calc(100vh - var(--header-height));
}

.banner div:first-child {
border-right: 1px solid var(--lighter-gray);
padding-right: 60px;
margin-right: 60px;
}

.banner h1 {
font-size: 6.8rem;
font-weight: 600;
}

.banner h2 {
font-size: 4rem;
font-weight: 600;
margin: 0 0 20px 0;
line-height: 1;
}

.banner p {
font-size: 2.2rem;
margin: 0;
}

.banner a {
color: var(--brand-color);
}
22 changes: 21 additions & 1 deletion resources/css/markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@
padding: 2px 6px;
}

.markdown h1 a, .markdown h2 a, .markdown h3 a, .markdown h4 a {
color: var(--mute-color);
margin-left: -1em;
opacity: 0;
padding-right: 0.2em;
text-decoration: none;
}

.markdown h1 .icon:before, .markdown h2 .icon:before, .markdown h3 .icon:before, .markdown h4 .icon:before {
content: '#';
}
.markdown h1:hover a,
.markdown h2:hover a,
.markdown h3:hover a,
.markdown h4:hover a {
opacity: 1;
}

.markdown h1 {
color: var(--heading-color);
font-size: var(--markdown-h1-size);
Expand All @@ -39,6 +57,7 @@
border-top: 1px solid var(--lighter-gray);
margin: 70px 0 20px 0;
padding-top: 50px;
position: relative;
}
/** Required only when using Calibre */
.markdown h2 code {
Expand All @@ -51,18 +70,19 @@
font-weight: var(--bold-font-weight);
font-size: var(--markdown-h3-size);
margin: 60px 0 10px 0;
position: relative;
}
/** Required only when using Calibre */
.markdown h3 code {
font-size: 2.0rem;
}


.markdown h4 {
color: var(--heading-color);
font-weight: var(--bold-font-weight);
font-size: var(--markdown-h4-size);
margin: 40px 0 5px 0;
position: relative;
}
/** Required only when using Calibre */
.markdown h4 code {
Expand Down
1 change: 1 addition & 0 deletions resources/fonts/Calibre/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The calibre font is licensed to Harminder Virk for https://adonisjs.com only.
1 change: 1 addition & 0 deletions resources/fonts/jetbrains/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The JetBrains Mono font is licensed under [SIL Open Font License](https://github.com/JetBrains/JetBrainsMono/blob/master/OFL.txt)
Loading

0 comments on commit dabb92f

Please sign in to comment.