Skip to content

Commit 2efaec8

Browse files
authored
📖 Update README.md and add DEVELOPING.md (#31)
1 parent c7e3646 commit 2efaec8

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

‎DEVELOPING.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Developing
2+
3+
## Command line
4+
5+
### Installing dependencies
6+
7+
```console
8+
npm install
9+
```
10+
11+
### Building
12+
13+
```console
14+
npm run build
15+
```
16+
17+
### Development
18+
19+
You can watch to rebuild on every change using:
20+
21+
```console
22+
npm run dev
23+
```
24+
25+
To test, you may run the example Storybook:
26+
27+
```console
28+
npm run storybook
29+
```
30+
31+
For a manual testing workflow, you should run `dev` and `storybook` at the same time.
32+
33+
## Testing local version elsewhere
34+
35+
You may configure a user package (like `amphtml`) to use your locally built version by using a [package path.](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#local-paths)
36+
37+
### In [`ampproject/amphtml`](https://github.com/ampproject/amphtml/)
38+
39+
Point to a local copy on `build-system/tasks/storybook/package.json`. The following relative path has `amphtml/` and `storybook-addon-amp/` on the same level directory:
40+
41+
```diff
42+
"devDependencies" {
43+
- "@ampproject/storybook-addon-amp": "1.1.1",
44+
+ "@ampproject/storybook-addon-amp": "file:../../../../storybook-addon-amp",
45+
}
46+
```
47+
48+
This way, you may use the local addon package's `npm run dev` in conjunction with `amp storybook` under `amphtml/`. Changes are picked up automatically.

‎README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
An AMP story uses `withAmp` decorator:
3131

3232
```js
33-
import { h } from 'preact';
33+
import {h} from 'preact';
3434
import {storiesOf} from '@storybook/preact';
3535
import {withAmp} from '@ampproject/storybook-addon';
3636

@@ -57,3 +57,20 @@ The following parameters can be specified:
5757

5858
1. `extensions: [{name, version}]` - a list of extensions to be installed.
5959
2. `experiments: [string]` - a list of experiments to enabled.
60+
61+
### `amp-script` hashes
62+
63+
Inline scripts used by `amp-script` require a `<meta name="amp-script-src">` tag that includes [their content hash](https://amp.dev/documentation/components/amp-script/#calculating-the-script-hash).
64+
65+
This addon generates the script hash for stories that need it. The following works without writing the respective `<meta>` tag:
66+
67+
```js
68+
export const UsingInlineScript = () => (
69+
<>
70+
<amp-script script="hello" nodom></amp-script>
71+
<script id="hello" type="text/plain" target="amp-script">
72+
{`console.log('Hello');`}
73+
</script>
74+
</>
75+
);
76+
```

0 commit comments

Comments
 (0)