Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/issue 164 properly indent code blocks in ordered lists to fix broken markdown rendering #166

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/pages/docs/pages/layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,26 @@ Below is an example of a _page.html_ layout:

You can create more layouts and use them for pages with the following steps:

<!-- prettier-ignore-start -->

1. Create a new layout, e.g. _layouts/blog.html_
1. In your frontmatter, specify that layout's filename

<!-- prettier-ignore-start -->

<app-ctc-block variant="snippet">

```md
---
layout: blog
---
```md
---
layout: blog
---

## My First Post
## My First Post

Lorum Ipsum
```
Lorum Ipsum
```

</app-ctc-block>

<!-- prettier-ignore-end -->
<!-- prettier-ignore-end -->

## App

Expand Down
84 changes: 43 additions & 41 deletions src/pages/docs/reference/rendering-strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,65 +41,67 @@ For example, creating a list of blog posts for a blog landing page, based on all
<!-- prettier-ignore-start -->
1. Add the `prerender` config to _greenwood.config.js_

<app-ctc-block variant="snippet" heading="greenwood.config.js">
<app-ctc-block variant="snippet" heading="greenwood.config.js">

```js
export default {
prerender: true,
};
```
```js
export default {
prerender: true,
};
```

</app-ctc-block>
</app-ctc-block>

1. Create a content fetching component

<app-ctc-block variant="snippet">
<app-ctc-block variant="snippet">

```js
import { getContentByRoute } from "@greenwood/cli/src/data/queries.js";
```js
import { getContentByRoute } from "@greenwood/cli/src/data/queries.js";

export default class BlogPostsList extends HTMLElement {
async connectedCallback() {
const posts = await getContentByRoute("/blog/");
export default class BlogPostsList extends HTMLElement {
async connectedCallback() {
const posts = await getContentByRoute("/blog/");

this.innerHTML = `
${posts
.map((post) => {
this.innerHTML = `
${posts
.map((post) => {
return `
<a href="${post.route}">
${post.title}
</a>
`;
})
.join("")}
`;
}
}
})
.join("")}
`;
}
}

customElements.define("blog-posts-list", BlogPostsList);
```
customElements.define("blog-posts-list", BlogPostsList);
```

</app-ctc-block>
</app-ctc-block>

1. Add it to your HTML page with the [**static** optimization attribute](/docs/reference/configuration/#optimization), as well as the custom element definition

<app-ctc-block variant="snippet">

```html
<!doctype html>
<html>
<head>
<title>Blog</title>
<script type="module" src="./components/blog-posts-list.js" data-gwd-opt="static"></script>
</head>
<body>
<h1>All Blog Posts</h1>
<blog-posts-list></blog-posts-list>
</body>
</html>
```

</app-ctc-block>
<app-ctc-block variant="snippet">

```html
<!doctype html>
<html>
<head>
<title>Blog</title>
<script type="module" src="./components/blog-posts-list.js" data-gwd-opt="static"></script>
</head>
<body>
<h1>All Blog Posts</h1>
<blog-posts-list></blog-posts-list>
</body>
</html>
```

</app-ctc-block>

<!-- prettier-ignore-end -->

Now you will have list of all your blog posts, automatically generated and formatted from your own content, kept up to date with every change. All with no runtime JavaScript!

Expand Down
108 changes: 53 additions & 55 deletions src/pages/guides/ecosystem/storybook.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,81 +282,79 @@ This can be accomplished with the [**storybook-addon-fetch-mock**](https://story

1. First, install the **storybook-addon-fetch-mock** addon

<!-- prettier-ignore-start -->
<!-- prettier-ignore-start -->

<app-ctc-block variant="runners">
<app-ctc-block variant="runners">

```shell
npm i -D storybook-addon-fetch-mock
```
```shell
npm i -D storybook-addon-fetch-mock
```

```shell
yarn add storybook-addon-fetch-mock --save-dev
```
```shell
yarn add storybook-addon-fetch-mock --save-dev
```

```shell
pnpm add -D storybook-addon-fetch-mock
```
```shell
pnpm add -D storybook-addon-fetch-mock
```

</app-ctc-block>
</app-ctc-block>

<!-- prettier-ignore-end -->
<!-- prettier-ignore-end -->

1. Then add it to your _.storybook/main.js_ configuration file as an **addon**

<!-- prettier-ignore-start -->
<!-- prettier-ignore-start -->

<app-ctc-block variant="snippet" heading=".storybook/main.js">
<app-ctc-block variant="snippet" heading=".storybook/main.js">

```js
const config = {
addons: [
"storybook-addon-fetch-mock",
],
};
```js
const config = {
addons: ["storybook-addon-fetch-mock"],
};

export default config;
```
export default config;
```

</app-ctc-block>
</app-ctc-block>

<!-- prettier-ignore-end -->
<!-- prettier-ignore-end -->

1. Then in your story files, configure your Story to return mock data

<!-- prettier-ignore-start -->

<app-ctc-block variant="snippet" heading="blog-posts-list.stories.js">

```js
import "./blog-posts-list.js";
import pages from "../../stories/mocks/graph.json";

export default {
parameters: {
fetchMock: {
mocks: [
{
matcher: {
url: "http://localhost:1984/___graph.json",
response: {
// this is an example of mocking out getContentByRoute
body: pages.filter((page) => page.route.startsWith("/blog/")),
},
},
},
],
},
},
};
<!-- prettier-ignore-start -->

<app-ctc-block variant="snippet" heading="blog-posts-list.stories.js">

```js
import "./blog-posts-list.js";
import pages from "../../stories/mocks/graph.json";

export default {
parameters: {
fetchMock: {
mocks: [
{
matcher: {
url: "http://localhost:1984/___graph.json",
response: {
// this is an example of mocking out getContentByRoute
body: pages.filter((page) => page.route.startsWith("/blog/")),
},
},
},
],
},
},
};

const Template = () => "<app-blog-posts-list></app-blog-posts-list>";
const Template = () => "<app-blog-posts-list></app-blog-posts-list>";

export const Primary = Template.bind({});
```
export const Primary = Template.bind({});
```

</app-ctc-block>
</app-ctc-block>

<!-- prettier-ignore-end -->
<!-- prettier-ignore-end -->

> To quickly get a "mock" graph to use in your stories, you can run `greenwood build` and copy the _graph.json_ file from the build output directory.
Loading
Loading