Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@astro-content/faker

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astro-content/faker

Quickly populate content collections from your schemas.

  • 0.0.0-alpha.16
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Astro Content — Content faker for Markdown + front matter

Quickly populate content collections from your schemas.

Perfect match with remark-lint-frontmatter-schema and @astro-content/validator.

Installation

pnpm i @astro-content/faker

OR

Shallow clone demo project:

pnpx degit JulianCataldo/astro-content/packages/faker/demo ./ac-faker-demo

Usage

CLI

# content-faker $SOURCE_TEMPLATE $DESTINATION_DIR $ENTRIES_COUNT
#                             Default to 1 if unset ———^

# E.g.
content-faker src/mocks/blog-post.template.md content/blog-posts 20
Example template

Gist:

Complete example:

---
'$schema': src/schemas/blog-post.schema.yaml
---

```js:faker
'# ' + faker.lorem.sentence(10)
```

```js:faker
'## ' + faker.lorem.sentence(9)
```

```js:faker
`**${faker.address.city()}**`
```

```js:faker
faker.lorem.sentence(12)
```

```js:faker
'### ' + faker.lorem.sentence(9)
```

```js:faker
`<SomeMap address="${faker.address.city()}" />`
```

---

```js:faker
'> ' + faker.lorem.sentence(10)
```

---

```js:faker
`- ${faker.lorem.sentence(6)}\n- ${faker.lorem.sentence(8)}\n- ${faker.lorem.sentence(10)}`
```

```js:faker
`<SomeTweet id="${faker.helpers.arrayElement(['1590042307163717635','1593680639005315073','1587901468585205760','1578871432700125185'])}" />`
```

```js:faker
'## ' + faker.lorem.sentence(9)
```

```js:faker
faker.lorem.paragraphs(2)
```

```js:faker
'### ' + faker.lorem.sentence(9)
```

```js:faker
`<SomeYoutubeVideo id="${faker.helpers.arrayElement(['xtTy5nKay_Y','BZZ9rGN4GK8','GPelHyt7iJ8','py8nD37SVDU'])}" />`
```

```js:faker
faker.lorem.paragraphs(1)
```

---

```js:faker
faker.date.recent().toLocaleDateString()
```

🎊 Yields:

---
title: dolor
description: deseruntut laboris sit laborumin labore ullamcovoluptate laboris
  occaecat nisi fugiatfugiat labore dolore in
tags:
  - Music
  - Cooking
  - Gardening
  - Video
  - Sport
  - Development
---

<!-- GENERATED CONTENT -->

# Aperiam tempora animi necessitatibus eligendi quas explicabo reprehenderit fugiat nobis.

## Iure delectus sapiente voluptas possimus provident maiores ipsam mollitia.

**Wizaberg**

Ullam voluptatibus perspiciatis placeat in officiis odio laborum cumque excepturi ut eveniet.

### Dolor assumenda similique aspernatur soluta provident exercitationem dolorum reiciendis.

<SomeMap address="Coleborough" />

---

> Vitae quibusdam doloremque consequuntur facilis quisquam corporis saepe aperiam adipisci.

---

- Autem vitae voluptate modi vero pariatur.
- Unde fuga iure eos assumenda iste atque voluptas.
- Aliquid est harum quod explicabo facilis quidem placeat error unde.

<SomeTweet id="1587901468585205760" />

## Quia perspiciatis laborum quasi nostrum dolor molestiae ex consequuntur.

Cupiditate quam labore aliquam at quisquam natus molestiae laboriosam. Ullam harum occaecati quidem dolorem sint libero. Reiciendis incidunt illo repudiandae nostrum quidem. Saepe beatae sequi quasi culpa quas cum quo. Odit perspiciatis reprehenderit quos id quae autem ab beatae. Corrupti nemo perferendis mollitia facilis.
Nostrum ad laboriosam. Rerum libero possimus est expedita possimus placeat veniam necessitatibus voluptas. Exercitationem blanditiis odio illum totam id repudiandae.

### Tenetur similique cupiditate illo doloremque similique commodi reiciendis est.

<SomeYoutubeVideo id="GPelHyt7iJ8" />

Repudiandae distinctio exercitationem. Quo totam esse debitis. Nihil velit a expedita laboriosam. Minus quas itaque iusto quis non quod. Aut sapiente soluta voluptate ipsum ducimus mollitia commodi veniam animi.

---

18/11/2022

API

Alternatively from the CLI, you can use this library programmatically:

import { generateFakeContent } from '@astro-content/faker';

await generateFakeContent(mdTemplatePath, outDir, count).catch((error) => {
  console.log(error);
});

See also the demo project to play with.

Recommendations

For the best experience, use these helpers in combination with remark-lint-frontmatter-schema.


🔗  JulianCataldo.com

Keywords

FAQs

Package last updated on 18 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc