Skip to content

Commit

Permalink
docs: add README
Browse files Browse the repository at this point in the history
  • Loading branch information
monsat committed Nov 12, 2021
1 parent aa54903 commit ee669bb
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# VuePress Plugin usePages

You can use array of all PagesData in your doc.

> This plugin is for VuePress 2
You can create articles list links easily.


## Install

```
$ npm install -D vuepress-plugin-use-pages
# or
$ yarn add -D vuepress-plugin-use-pages
```

## Usage

Add `vuepress-plugin-use-pages` in your config file.

```ts:docs/.vuepress/config.ts
plugins: [
['vuepress-plugin-use-pages'],
],
```

in your doc file or component.

```html:some-component.vue
<script>
import { defineComponent } from 'vue'
import { usePages } from '@temp/pages' // pages.js is default filename
export default defineComponent({
setup() {
const pages = usePages()
console.log(pages)
return { pages }
},
})
</script>
<template>
<ul>
<li
v-for="page in pages"
:key="page.key"
>
<a :href="page.path">{{ page.title }}</a>
<span v-if="page.frontmatter.date">
[ {{ (new Date(page.frontmatter.date)).toLocaleString() }} ]
</span>
</li>
</ul>
</template>
```

## Options

```ts:docs/.vuepress/config.ts
plugins: [
['vuepress-plugin-use-pages', {
startsWith: '/posts/', // fetch only matched paths
filter: (page) => page.lang === 'ja', // fetch only filtered pages
limit: 30, // maximum cached size
file: 'articles.js', // temp file name
}],
],
```

### startsWith

If your docs are in `docs/posts/**/*.md`, set `startsWith: '/posts/'`.

default: `/articles/`

### filter

Additional filter function.

### limit

maximum cached size.

default: `false` (all files)

### file

temp file name

default: `pages.js`

## Reference

- [VuePress](https://v2.vuepress.vuejs.org/)

## License

MIT

0 comments on commit ee669bb

Please sign in to comment.