# vue-static-generator

> A Vue static website generator

Latest version **0.2.1** (published 2018-09-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-static-generator
pnpm add vue-static-generator
yarn add vue-static-generator
bun add vue-static-generator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2018-09-28 |
| First published | 2018-09-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 17.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Laegel |
| Maintainers | laegel |
| Keywords | Vue, SSR, static, generator |

## Links

- npm: https://www.npmjs.com/package/vue-static-generator
- npm.io page: https://npm.io/package/vue-static-generator

## Dependencies (2)

- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [@alexbinary/rimraf](https://npm.io/package/@alexbinary/rimraf.md) ^1.0.2

## Recent versions

- 0.2.1 (latest) — 2018-09-28
- 0.2.0 — 2018-09-28
- 0.1.0 — 2018-09-14

## README

# vue-static-generator
A Vue SSR generator to take advantage of SEO, versatility and Vue awesomeness (oh no, this intro is definitely not objective).

A small package made in order to fill the only thing [Nuxt](https://nuxtjs.org/) doesn't provide: an "on-demand" Vue server side rendering.

Still working on it, if anyone has troubles to set it up, do not hesitate to contact me.

## Use case
As I was building a CMS and wanted to use Vue and SSR (yeah I know, that's quite an edge case) for SEO, I looked for existing libraries that could suit my needs. Unfortunately, I didn't find anything, that's why I decided to create this package.

## Features
With this package, you're able to generate a whole website or do it page by page.

Multilingual is a core feature, as it's directly implied in the generation process.

Although sitemap plays an important role in SEO, I'm still wondering if it should belong to core or if it shall be a kind of module. 

## Installation
`npm i -S vue-static-decorator`

or

`yarn add vue-static-decorator -S`

Please note that you need the modules from your bundle JSON file to be installed and that "vue-server-renderer" package version must match Vue's.

## Configuration

```typescript
interface GenerateConfiguration {
    baseURI: string,
    languages: {
        [languageCode: string]: LanguageConfiguration
    },
    fileIndex?: string, // default "index"
    fileExtension?: string, // default ".html",
    fileWriter?: Function, // default file writer will just write the file at the location, can be customized
    targetDirectory?: string // default "./dist"
}

interface LanguageConfiguration {
    defaultTitle: string,
    routes: RouteConfiguration[]
}

interface RouteConfiguration {
    path: string,
    children?: RouteConfiguration[]
    regenerate?: string[] | () => string[],
    type?: string, // Used when defining a type

    // Those are required when route has a "type" property
    data?: any[] | () => any[], 
    resolver?: string | () => string
}
```

### GenerateConfiguration
The main configuration object.

At least one language must be used in the "languages" property.

### LanguageConfiguration
The language configuration object.

As routes may differ between all languages, route configurations are separated.

### RouteConfiguration
The route configuration object.

"regenerate" is used to tell the generator to refresh specific paths (e.g. a homepage that would display our latest posts).

"data" is the input of data that will mainly* be used when generating the whole project.

"resolver" corresponds to the way the "path" property will be resolved. As sometimes you'll need to use variables in your paths, the only way to resolve it is to provide a callback to process your data and output the expected path.

\* *mainly*, as you could also use it in any callback property, for example.

## API
This package provides two classes:

```typescript
interface GeneratorWrapper {
    static create(config, bundle, options);

    static async initialize(): Promise[];

    static async generateByRoute(route, options): Promise[];

    static async generateByType(type, ids, options): Promise[];
}
```
This is a wrapper for the Generator class, the direct generator feature access.

If the wrapper doesn't fit your need, you can still build your own around the Generator class:

```typescript
interface Generator {
    constructor(config, bundle, options = null);

    generateByArgs(args): Promise[];

    generateAll(): Promise[];
}
```

---
_Source: https://npm.io/package/vue-static-generator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
