Skip to content

Commit

Permalink
bug/issue 164 properly indent code blocks in ordered lists to fix bro…
Browse files Browse the repository at this point in the history
…ken markdown rendering (#166)
  • Loading branch information
thescientist13 authored Jan 28, 2025
1 parent e446934 commit 2aa03c4
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 368 deletions.
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

0 comments on commit 2aa03c4

Please sign in to comment.