|
1 | 1 | # Scully - Getting Started
|
2 | 2 |
|
3 |
| -After created your Angular application go to your command line using Angular-CLI, you need to add Scully to your project: |
| 3 | +The first thing you need to get started with Scully is a working Angular app using Angular 8.* or 9.*. |
4 | 4 |
|
5 |
| -```bash |
6 |
| -ng add @scullyio/init |
7 |
| -``` |
| 5 | +This getting started doc covers the three steps to adding Scully into your project. |
8 | 6 |
|
9 |
| -The command above set up the necessary to start to work with Scully (_we go to get more deep about this in next releases._). |
| 7 | +1. [Installation](#installation) |
| 8 | +2. [Build](#build) |
| 9 | +3. [Test](#test) |
10 | 10 |
|
11 |
| -If the installation was success you can read a message similar to this one. |
12 | 11 |
|
| 12 | +## Installation |
| 13 | +To install Scully, do the following: From the root directory of your Angular project (in a terminal window), run the following command: |
13 | 14 | ```bash
|
14 |
| -Installed packages for tooling via yarn. |
15 |
| -✔ Added dependency |
16 |
| -✔ Import HttpClientModule into root module |
17 |
| -UPDATE package.json (1447 bytes) |
18 |
| -UPDATE src/app/app.module.ts (472 bytes) |
19 |
| -UPDATE src/polyfills.ts (3035 bytes) |
20 |
| -UPDATE src/app/app.component.ts (325 bytes) |
21 |
| - ✔ Packages installed successfully. |
22 |
| - ✔ Update package.json |
23 |
| -CREATE scully.config.js (65 bytes) |
24 |
| -UPDATE package.json (1507 bytes) |
25 |
| -``` |
26 |
| - |
27 |
| -## @scullyio/init:blog |
28 |
| - |
29 |
| -Scully have built-in schematics to use, `@scullyio/init:blog` allows you to create a full Lazy Loaded feature module to start your basic |
30 |
| -static site. |
31 |
| - |
32 |
| -You just need write in your command line: |
33 |
| - |
34 |
| -```bash |
35 |
| -ng g @scullyio/init:blog |
36 |
| -``` |
37 |
| - |
38 |
| -After the execution, you should read: |
39 |
| -``` |
40 |
| -CREATE src/app/blog/blog-routing.module.ts (336 bytes) |
41 |
| -CREATE src/app/blog/blog.module.ts (335 bytes) |
42 |
| -CREATE src/app/blog/blog.component.css (0 bytes) |
43 |
| -CREATE src/app/blog/blog.component.html (19 bytes) |
44 |
| -CREATE src/app/blog/blog.component.spec.ts (614 bytes) |
45 |
| -CREATE src/app/blog/blog.component.ts (261 bytes) |
46 |
| -UPDATE src/app/app-routing.module.ts (336 bytes) |
47 |
| - ✔ Blog 12-13-2019-blog-X file created |
48 |
| - ✔ Update scully.config.js |
49 |
| -CREATE blog/12-13-2019-blog-X.md (101 bytes) |
50 |
| -UPDATE scully.config.js (121 bytes) |
51 |
| -``` |
52 |
| - |
53 |
| -As you can see above `ng g @scullyio/init:blog` creates the following files for you: |
54 |
| - |
55 |
| -- blog-routing.module.ts |
56 |
| -- blog.module.ts |
57 |
| -- blog.component.css |
58 |
| -- blog.component.html |
59 |
| -- blog.component.spec.ts |
60 |
| -- blog.component.ts |
61 |
| - |
62 |
| -Also, it updated the `app-routing.module.ts` with the new module added. Last but not least we added `scully.config.js` and create a |
63 |
| -folder named `/blog` wich inside have a markdown file. |
64 |
| - |
65 |
| -###### `scully.config.js` |
66 |
| - |
67 |
| -Inside this file, we can find all the routes of your app generated automatically from Scully. |
68 |
| - |
69 |
| -```js |
70 |
| -exports.config = { |
71 |
| - projectRoot: "./src/app", |
72 |
| - routes: { |
73 |
| - '/blog/:slug': { |
74 |
| - type: 'contentFolder' |
75 |
| - }, |
76 |
| - } |
77 |
| -}; |
| 15 | +ng add @scullyio/init |
78 | 16 | ```
|
79 | 17 |
|
80 |
| -##### What if I don't want a module called "blog"? |
| 18 | +At this point, Scully has been added to your project. The most important part of the installation is the addition of the |
| 19 | +Scully configuration file: `scully.config.js` (_soon this will be `scully.config.ts`_). To learn more about this file, |
| 20 | +read [Scully Configuration](scully-configuration.md) docs. |
81 | 21 |
|
82 |
| -If for any reason you want to customize the name of your module we have a specific command for that. |
| 22 | +## Build |
83 | 23 |
|
84 |
| -## @scullyio/init:markdown --name |
85 |
| - |
86 |
| -With `@scullyio/init:markdown` you can customize the name of your modules easy, just adding the flag `--name` |
| 24 | +So you have your Angular app AND you have installed Scully. So let's run a scully build to turn your site into a |
| 25 | +pre-rendered Angular app. Because scully runs based on a build of your app, the first step is to build your Angular |
| 26 | +project. Then you can run the scully build. |
87 | 27 |
|
88 | 28 | ```bash
|
89 |
| -ng g @scullyio/init:markdown --name=categories |
| 29 | +ng build |
| 30 | +npm run scully |
90 | 31 | ```
|
91 | 32 |
|
92 |
| -The example above allows you to create a new Lazy Loaded Module named "categories". |
93 |
| - |
| 33 | +That's it. You're done! In your project directory, you now have a `/dist/static` folder that contains the built version |
| 34 | +of your app. |
94 | 35 |
|
95 |
| -## ng g @scullyio/init:post --title |
| 36 | +__NOTE:__ If you had any errors or warning during the build phase, please follow the instructions in the errors/warnings |
| 37 | +(if applicable) or [submit an issue](issues). |
96 | 38 |
|
97 |
| -PENDING |
| 39 | +## Test |
98 | 40 |
|
99 |
| -``` |
100 |
| -ng g @scullyio/init:post --title |
101 |
| -``` |
| 41 | +Now that you're project has been pre-rendered, you can validate the build in one of a few ways. |
102 | 42 |
|
103 |
| -### Time to build! |
| 43 | +1. Serve the contents of your `dist/static` directory |
| 44 | +2. Browse the contents of `dist/static` directory and read the HTML |
104 | 45 |
|
105 |
| -At this moment we know how to create our static site using Scully, but now it's time to build and see the magic. |
| 46 | +#### Serve the contents |
106 | 47 |
|
107 |
| -#### Step one, build our angular app |
| 48 | +Using something like [http-server](https://www.npmjs.com/package/http-server) you can serve the contents of your |
| 49 | +`dist/static` folder. All routes that work in your non-pre-rendered Angular app should still work. Not all apps are |
| 50 | +capable of running without |
108 | 51 |
|
109 |
| -We need to build our Angular app using the command: |
| 52 | +__Extra Credit__: While serving your app, [disable javasript](https://developers.google.com/web/tools/chrome-devtools/javascript/disable) |
| 53 | +and make sure that you app still works. This is the goal for your app, to run with JavaScript disabled. Most of the |
| 54 | +parts of your app should work without JS enabled. |
110 | 55 |
|
111 |
| - ```bash |
112 |
| - ng build |
113 |
| - ``` |
114 |
| - |
115 |
| - After finished this process the Angular-CLI should create the dist folder with all our fully compiled app. |
116 |
| - |
117 |
| - #### Step two, build using Scully |
118 |
| - |
119 |
| - ```bash |
120 |
| - npm run scully |
121 |
| - ``` |
122 |
| - |
123 |
| - As a result of command line above inside the `dist` folder we should found another 2 folder: |
124 |
| - |
125 |
| -``` |
126 |
| -|-- dist/ |
127 |
| -| |-- my-project-name/ |
128 |
| -| |-- static/ |
| 56 | +#### Browse the contents |
129 | 57 |
|
130 |
| -``` |
| 58 | +Browse the contents of your `dist/static` directory and make sure that all of your pages were pre-rendered and saved to |
| 59 | +HTML correctly. |
131 | 60 |
|
132 |
| -`static` folder contains all our static site ready for deploy to your favorite server. |
133 |
| - |
134 | 61 |
|
135 | 62 | ---
|
136 |
| -Prev: [Pre-requisites ⬅️️](pre-requisites.md) | Next: [Working with Plugins ➡️](working-with-plugins.md) |
| 63 | +Next: [Full Documentation ➡️](scully.md) |
0 commit comments