Skip to content

Commit

Permalink
Merge pull request #936 from onflow/nialexsan/coderef-plugin
Browse files Browse the repository at this point in the history
code ref plugin
  • Loading branch information
nialexsan authored Oct 16, 2024
2 parents a20c3da + 1c5dca8 commit bf75c20
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 667 deletions.
48 changes: 38 additions & 10 deletions CONTRIBUTING.md → CONTRIBUTING
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,23 @@ import { useLocation } from '@docusaurus/router';

```

<Callout type="warning">
:::warning

The `index` page should only include information that is available elsewhere within the category's other pages.
</Callout>

:::

### Using DocCardList

Using `DocCardList` improves the layout of the index page:

<Callout type="note" title="Example">
:::note Example

![edit page](./static/images/contributing/doc-card-list-light.png#gh-light-mode-only)

![edit page](./static/images/contributing/doc-card-list-dark.png#gh-dark-mode-only)
</Callout>

:::

On the most pages you can use just `<DocCardList />` component imported from `'@theme/DocCardList'`

Expand All @@ -173,12 +178,13 @@ import { useLocation } from '@docusaurus/router';
<DocCardList items={useDocsSidebar().items.filter(item => !isSamePath(item.href, useLocation().pathname))}/>
```

<Callout type="warning">
:::warning

If you use `<DocCardList/>` on the top level category index page (e.g. `./docs/tools/index.mdx`), Docusaurus will throw an error:

> useCurrentSidebarCategory() should only be used on category index pages.

</Callout>
:::

## SEO

Expand Down Expand Up @@ -225,9 +231,11 @@ Writing links in your documents is easy if you follow this rule-of-thumb: If it
[link](https://www.google.com)
```

<Callout type="tip">
:::tip

Use relative links directly to .md/.mdx files
</Callout>

:::

### Callouts

Expand All @@ -243,12 +251,32 @@ Available types:

Example:
```markdown
<Callout type="tip">
:::tip

Use relative links directly to .md/.mdx files
</Callout>

:::
```

### Code references

To include code from a file using a direct URL use `!from` operand inside a code block.

Example:

````markdown
```
!from https://raw.githubusercontent.com/onflow/docs/refs/heads/main/docs/evm/about.md
```
````

mdx
Copy code
```javascript
{code}
This method keeps your documentation synchronized with your codebase by pulling the latest code directly into your docs.


## Content Validation

Content is validated each time a PR is submitted to the `docs` repository.
Expand Down
Loading

0 comments on commit bf75c20

Please sign in to comment.