Skip to content

Commit fac28d7

Browse files
small improvements
1 parent 5948a5f commit fac28d7

19 files changed

+198
-154
lines changed

website/docs/building/debugging.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ In this tutorial, we'll see how.
137137
### Chrome DevTools (Client-side)
138138

139139
1. **Component Inspection**:
140-
```javascript
140+
```js
141141
// In browser console, inspect loaded components
142142
console.log(window.oc.components);
143143

@@ -213,7 +213,7 @@ curl -H "Accept: application/vnd.oc.unrendered+json" https://your-registry.com/y
213213
- Incorrect helper usage
214214

215215
**Debugging**:
216-
```javascript
216+
```js
217217
// In server.js, log the data being passed to template
218218
export const data = (context, callback) => {
219219
const result = {
@@ -232,7 +232,7 @@ export const data = (context, callback) => {
232232
- Incorrect prop types
233233

234234
**Debugging**:
235-
```javascript
235+
```js
236236
// Add console logs in your React component
237237
const MyComponent = (props) => {
238238
console.log('Component props:', props);
@@ -260,7 +260,7 @@ tar -tzf _package/package.tar.gz
260260

261261
### Memory Debugging
262262

263-
```javascript
263+
```js
264264
// Monitor memory usage in browser
265265
console.log('Memory usage:', performance.memory);
266266

@@ -284,7 +284,7 @@ time curl -s http://localhost:3030/your-component > /dev/null
284284

285285
### Client-side Error Handling
286286

287-
```javascript
287+
```js
288288
// Global error handler for components
289289
window.addEventListener('error', (event) => {
290290
if (event.target.tagName === 'OC-COMPONENT') {
@@ -301,7 +301,7 @@ document.addEventListener('oc:error', (event) => {
301301

302302
### Server-side Error Handling
303303

304-
```javascript
304+
```js
305305
// In server.js, always handle errors gracefully
306306
export const data = (context, callback) => {
307307
try {

website/docs/building/template-system.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sidebar_position: 2
33
---
44

5-
# Template system
5+
# Template System
66

77
## Introduction
88

@@ -82,7 +82,7 @@ via configuration API:
8282
via `registerTemplates()` API:
8383

8484
```js
85-
cons templates = oc.registerTemplates([{
85+
const templates = oc.registerTemplates([{
8686
"type": "custom-react-template",
8787
"externals": [{
8888
"global": "React",
@@ -121,7 +121,7 @@ At the moment OC comes with `oc-template-es6` as the default modern template, wi
121121

122122
### ES6 Template Example
123123

124-
```javascript
124+
```js
125125
// template.js - Modern ES6 template
126126
export default function (model) {
127127
return `
@@ -244,7 +244,7 @@ const configuration = {
244244

245245
**Issue**: "Component renders but shows blank"
246246

247-
```javascript
247+
```js
248248
// ❌ Problem - undefined variables
249249
export default function(model) {
250250
return `<div>${model.user.name}</div>`; // Error if user is undefined
@@ -259,7 +259,7 @@ export default function(model) {
259259

260260
**Issue**: "Template externals not loading"
261261

262-
```javascript
262+
```js
263263
// Check external dependencies are accessible
264264
const templates = [
265265
{
@@ -278,7 +278,7 @@ const templates = [
278278

279279
**Issue**: "Slow template rendering"
280280

281-
```javascript
281+
```js
282282
// ❌ Avoid complex logic in templates
283283
export default function(model) {
284284
// Don't do heavy processing here
@@ -299,7 +299,7 @@ export default function(model) {
299299

300300
**Issue**: "Migrating from Handlebars to ES6"
301301

302-
```javascript
302+
```js
303303
// Before (Handlebars)
304304
// {{#if user.isActive}}
305305
// <span class="active">{{user.name}}</span>
@@ -338,7 +338,7 @@ my-custom-template/
338338

339339
### Template API Requirements
340340

341-
```javascript
341+
```js
342342
// compiler.js - Required methods
343343
module.exports = {
344344
compile: (options, callback) => {
@@ -360,7 +360,7 @@ module.exports = {
360360

361361
### Template Registration
362362

363-
```javascript
363+
```js
364364
// Registry configuration
365365
const configuration = {
366366
templates: [

website/docs/components/cli.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If these are satisfied you can install the CLI as shown below.
1616

1717
To install cli, you should type:
1818

19-
```sh
19+
```bash
2020
$ npm install oc -g
2121
```
2222

@@ -26,19 +26,19 @@ Autocomplete is supported for Mac and Linux.
2626

2727
To enable it in **zsh**, you should type:
2828

29-
```sh
29+
```bash
3030
echo '. <(oc completion)' >> .zshrc
3131
```
3232

3333
To enable it in **bash**, you should type:
3434

35-
```sh
35+
```bash
3636
oc completion >> ~/.bashrc
3737
```
3838

3939
or
4040

41-
```sh
41+
```bash
4242
oc completion >> ~/.bash_profile
4343
```
4444

@@ -48,15 +48,15 @@ After enabling autocomplete you should reload the shell.
4848

4949
Basic usage:
5050

51-
```sh
51+
```bash
5252
$ oc <command> [options]
5353
```
5454

5555
Hint: Run -h with any command to show the help
5656

5757
For a list of all the available commands, type **oc** in your terminal
5858

59-
```sh
59+
```bash
6060
$ oc
6161
```
6262

@@ -161,7 +161,7 @@ Remove the node_modules directory from each component's subfolder
161161

162162
#### Usage:
163163

164-
```sh
164+
```bash
165165
$ oc clean <dirPath> [options]
166166
```
167167

@@ -179,7 +179,7 @@ $ oc clean <dirPath> [options]
179179

180180
#### Example:
181181

182-
```sh
182+
```bash
183183
$ oc clean ../all-components --yes
184184
```
185185

@@ -191,7 +191,7 @@ Runs a local oc test registry **to develop and test components**
191191

192192
#### Usage:
193193

194-
```sh
194+
```bash
195195
$ oc dev <dirPath> [port] [baseUrl] [options]
196196
```
197197

@@ -215,7 +215,7 @@ $ oc dev <dirPath> [port] [baseUrl] [options]
215215

216216
#### Example:
217217

218-
```sh
218+
```bash
219219
$ oc dev ../all-components 3001 127.0.0.1:3001 --fallbackRegistryUrl=http://anotherhost:anotherport/
220220
```
221221

@@ -227,7 +227,7 @@ Creates a new empty component in the current folder
227227

228228
#### Usage:
229229

230-
```sh
230+
```bash
231231
$ oc init <componentPath> [templateType]
232232
```
233233

@@ -240,13 +240,13 @@ $ oc init <componentPath> [templateType]
240240

241241
#### Example:
242242

243-
```sh
243+
```bash
244244
$ oc init test-component oc-template-es6
245245
```
246246

247247
or with using relative path:
248248

249-
```sh
249+
```bash
250250
$ oc init components/test-component oc-template-es6
251251
```
252252

@@ -260,7 +260,7 @@ Allows **mocking configuration to simplify local development**
260260

261261
#### Usage
262262

263-
```sh
263+
```bash
264264
$ oc mock <targetType> <targetName> <targetValue>
265265
```
266266

@@ -274,15 +274,15 @@ $ oc mock <targetType> <targetName> <targetValue>
274274

275275
#### Example:
276276

277-
```sh
277+
```bash
278278
$ oc mock plugin hash "always-returned-value"
279279
```
280280

281281
Creates static mock for a "hash" plugin which always returns "always-returned-value" value
282282

283283
To run a dynamic plugin, you can run a plugin locally. This could be the same one running in your registry, or a mock js that behaves differently locally.
284284

285-
```sh
285+
```bash
286286
$ oc mock plugin <targetName> <path to mock .js>
287287
```
288288

@@ -294,7 +294,7 @@ Creates the packaged component ready to be published
294294

295295
#### Usage:
296296

297-
```sh
297+
```bash
298298
$ oc package <componentPath> [options]
299299
```
300300

@@ -325,7 +325,7 @@ Runs a test page consuming a component
325325

326326
#### Usage:
327327

328-
```sh
328+
```bash
329329
$ oc preview <componentHref>
330330
```
331331

@@ -337,7 +337,7 @@ $ oc preview <componentHref>
337337

338338
#### Examples:
339339

340-
```sh
340+
```bash
341341
$ oc preview "http://localhost:3000/my-new-component/1.0.0/?param1=hello&name=Arthur"
342342
```
343343

@@ -349,7 +349,7 @@ Validate a component against registry requirements without publishing
349349

350350
#### Usage:
351351

352-
```sh
352+
```bash
353353
$ oc validate <componentPath> [options]
354354
```
355355

@@ -368,7 +368,7 @@ $ oc validate <componentPath> [options]
368368

369369
#### Examples:
370370

371-
```sh
371+
```bash
372372
# Validate component against configured registries
373373
$ oc validate my-component/
374374

@@ -387,7 +387,7 @@ Publish a component
387387

388388
#### Usage:
389389

390-
```sh
390+
```bash
391391
$ oc publish <componentPath> [options]
392392
```
393393

@@ -409,7 +409,7 @@ $ oc publish <componentPath> [options]
409409

410410
#### Examples:
411411

412-
```sh
412+
```bash
413413
$ oc publish my-new-component/
414414
```
415415

@@ -421,7 +421,7 @@ Shows, adds, removes oc registries to the current project
421421

422422
#### Usage:
423423

424-
```sh
424+
```bash
425425
$ oc registry <command>
426426
```
427427

website/docs/components/getting-started.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ sidebar_position: 1
66

77
## Prerequisites
88

9-
Before creating your first component, make sure your workstation meets the [CLI installation requirements](cli.md#installation). If you followed the **Quick-Start Tutorial** you can skip this.
9+
Before creating your first component, make sure your workstation meets the [CLI installation requirements](cli#install-the-cli). If you followed the **Quick-Start Tutorial** you can skip this.
1010

1111
First create the component directory:
1212

1313
```bash
14-
$ oc init hello-world
14+
oc init hello-world
1515
```
1616

1717
The above command will create the `hello-world` [directory](#component-structure).
1818

1919
It is also possible to set [template](#template) type during the initialisation as an additional init parameter:
2020

2121
```bash
22-
$ oc init hello-world oc-template-es6
22+
oc init hello-world oc-template-es6
2323
```
2424

2525
By default this parameter is set to `oc-template-es6` (modern ES6 templates). Legacy templates like `oc-template-handlebars` are still supported for backwards compatibility.
@@ -72,7 +72,7 @@ The basic package file `package.json` looks as follows:
7272
}
7373
},
7474
"devDependencies": {
75-
"oc-template-handlebars-compiler": "6.0.8"
75+
"oc-template-es6-compiler": "6.0.8"
7676
}
7777
}
7878
```
@@ -107,8 +107,8 @@ export const data = (context, callback) => {
107107

108108
You may want to start a local test registry using a components' folder as a library with a watcher. This will allow to consume and debug it:
109109

110-
```sh
111-
$ oc dev . 3030
110+
```bash
111+
oc dev . 3030
112112
```
113113

114114
Then you may want to create a blank html page to start playing with it and see how it looks:
@@ -126,8 +126,8 @@ Then you may want to create a blank html page to start playing with it and see h
126126

127127
Or, just use the preview function:
128128

129-
```sh
130-
$ oc preview http://localhost:3030/hello-world
129+
```bash
130+
oc preview http://localhost:3030/hello-world
131131
```
132132

133133
That's it. As soon as you make changes on the component, you will be able to refresh this page and see how it looks.

0 commit comments

Comments
 (0)