Skip to content

Commit

Permalink
pre-render dynamic routes
Browse files Browse the repository at this point in the history
  • Loading branch information
d-koppenhagen committed Dec 27, 2019
1 parent 6805f9d commit de5e58f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 4 deletions.
9 changes: 8 additions & 1 deletion scully.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ exports.config = {
folder: "./blog"
}
},
'/books/:isbn': {
'type': 'json',
'isbn': {
'url': 'https://api3.angular-buch.com/books',
'property': 'isbn'
}
}
}
};
};
6 changes: 5 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { BookComponent } from './book/book.component';


const routes: Routes = [{ path: 'blog', loadChildren: () => import('./blog/blog.module').then(m => m.BlogModule) }];
const routes: Routes = [
{ path: 'blog', loadChildren: () => import('./blog/blog.module').then(m => m.BlogModule) },
{ path: 'books/:isbn', component: BookComponent }
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { BookComponent } from './book/book.component';

@NgModule({
declarations: [
AppComponent
AppComponent,
BookComponent
],
imports: [
BrowserModule,
Expand Down
Empty file added src/app/book/book.component.css
Empty file.
1 change: 1 addition & 0 deletions src/app/book/book.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>book works!</p>
25 changes: 25 additions & 0 deletions src/app/book/book.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { BookComponent } from './book.component';

describe('BookComponent', () => {
let component: BookComponent;
let fixture: ComponentFixture<BookComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ BookComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(BookComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/book/book.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-book',
templateUrl: './book.component.html',
styleUrls: ['./book.component.css']
})
export class BookComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
2 changes: 1 addition & 1 deletion src/assets/scully-routes.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"route":"/blog/12-27-2019-blog","title":"This is the blog","description":"blog description","publish":false},{"route":"/blog/first-post","title":"First post","description":"blog description","publish":false}]
[{"route":"/books/9783864906466"},{"route":"/books/9783864902079"},{"route":"/books/9783864904523"},{"route":"/books/9783960090267"},{"route":"/books/9783864903274"},{"route":"/books/9783864903571"},{"route":"/blog/12-27-2019-blog","title":"This is the blog","description":"blog description","publish":false},{"route":"/blog/first-post","title":"First post","description":"blog description","publish":false}]

0 comments on commit de5e58f

Please sign in to comment.