Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"flatfilers/*",
"plugins/*",
"support/*",
"utils/*"
"utils/*",
"validators/*"
],
"scripts": {
"clean": "find ./ '(' -name 'node_modules' -o -name 'dist' -o -name '.turbo' -o -name '.parcel-cache' ')' -type d -exec rm -rf {} +",
Expand Down
75 changes: 75 additions & 0 deletions validators/StaticSiteGenerator/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Flatfile Static Site Generator Plugin

This Flatfile Listener plugin implements a static site generator that processes imported data, generates static pages, and provides options for different static site generators, styling, and interactivity. It seamlessly integrates with Flatfile's data import capabilities to create customizable static websites.

## Features

- Automatic data processing and transformation
- Support for multiple static site generators (e.g., Gatsby)
- Customizable templates and styling options
- Interactive features like search and sorting
- Sitemap generation
- SEO metadata creation
- Data visualization capabilities
- Responsive design
- Export functionality for generated static sites

## Installation

To install the plugin, run the following command:

```bash
npm install @flatfile/plugin-static-site-generator
```

## Example Usage

```javascript
import { FlatfileListener } from '@flatfile/listener';
import staticSiteGenerator from '@flatfile/plugin-static-site-generator';

const listener = FlatfileListener.create((client) => {
client.use(staticSiteGenerator());

// ... other configurations
});

export default listener;
```

## Configuration

The plugin can be configured with the following options:

```javascript
client.use(staticSiteGenerator({
generator: 'gatsby',
template: 'default',
styling: 'minimal',
interactivity: ['search', 'sort'],
exportJobName: 'Export for Static Site Generation',
autoDownload: true
}));
```

- `generator`: The static site generator to use (default: 'gatsby')
- `template`: The template style for the generated site (default: 'default')
- `styling`: The styling option for the site (default: 'minimal')
- `interactivity`: An array of interactive features to include (default: ['search', 'sort'])
- `exportJobName`: The name of the export job (default: 'Export for Static Site Generation')
- `autoDownload`: Whether to automatically download the generated site (default: true)

## Behavior

1. The plugin processes imported data using Flatfile's data processing capabilities.
2. It then generates a static site based on the processed data and user-defined configurations.
3. The generated site includes:
- HTML pages for each data entry
- A sitemap for improved SEO
- SEO metadata for each page
- Interactive features like search and sorting (if configured)
- Data visualizations (if applicable)
4. The generated site is packaged into a zip file and uploaded to Flatfile.
5. If `autoDownload` is set to true, the generated site will be automatically downloaded.

The plugin integrates seamlessly with other Flatfile features like data validation, transformation, and export functionality.
118 changes: 118 additions & 0 deletions validators/StaticSiteGenerator/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"timestamp": "2024-09-20T07-09-51-087Z",
"task": "Create a Static Site Generation Flatfile Listener plugin:\n - Implement a custom action to generate a static website from imported data\n - Allow users to choose between different static site generators (e.g., Gatsby, Next.js, or a custom solution)\n - Generate an index.html file and additional pages based on the data structure\n - Implement customizable templates for different data types and layouts\n - Include options for styling (CSS) and basic interactivity (JavaScript)\n - Generate a sitemap and basic SEO metadata\n - Provide an option to export the generated site as a zip file or deploy directly to a hosting service\n - Implement data visualization components (e.g., charts, tables) for relevant data\n - Include a search functionality for larger datasets\n - Ensure responsive design for mobile and desktop viewing",
"steps": [
[
"Retrieve information about Flatfile Listeners and the Record Hook plugin to understand the structure and implementation details.\n",
"#E1",
"FlatfileLocal",
"Flatfile Listeners structure and Record Hook plugin implementation",
"Plan: Retrieve information about Flatfile Listeners and the Record Hook plugin to understand the structure and implementation details.\n#E1 = FlatfileLocal[Flatfile Listeners structure and Record Hook plugin implementation]"
],
[
"Research static site generators and their integration possibilities with Flatfile.\n",
"#E2",
"Google",
"static site generators integration with Flatfile",
"Plan: Research static site generators and their integration possibilities with Flatfile.\n#E2 = Google[static site generators integration with Flatfile]"
],
[
"Create the basic structure of the Flatfile Listener plugin for static site generation.\n",
"#E3",
"LLM",
"Create a basic Flatfile Listener plugin structure for static site generation using the information from #E1 and #E2",
"Plan: Create the basic structure of the Flatfile Listener plugin for static site generation.\n#E3 = LLM[Create a basic Flatfile Listener plugin structure for static site generation using the information from #E1 and #E2]"
],
[
"Implement the custom action for generating a static website from imported data.\n",
"#E4",
"LLM",
"Implement a custom action in the Flatfile Listener to generate a static website using the structure from #E3",
"Plan: Implement the custom action for generating a static website from imported data.\n#E4 = LLM[Implement a custom action in the Flatfile Listener to generate a static website using the structure from #E3]"
],
[
"Add functionality to allow users to choose between different static site generators.\n",
"#E5",
"LLM",
"Extend the Flatfile Listener to allow users to choose between Gatsby, Next.js, or a custom solution for static site generation using #E4 as a base",
"Plan: Add functionality to allow users to choose between different static site generators.\n#E5 = LLM[Extend the Flatfile Listener to allow users to choose between Gatsby, Next.js, or a custom solution for static site generation using #E4 as a base]"
],
[
"Implement the generation of index.html and additional pages based on the data structure.\n",
"#E6",
"LLM",
"Add functionality to generate index.html and additional pages based on the imported data structure in the Flatfile Listener using #E5 as a base",
"Plan: Implement the generation of index.html and additional pages based on the data structure.\n#E6 = LLM[Add functionality to generate index.html and additional pages based on the imported data structure in the Flatfile Listener using #E5 as a base]"
],
[
"Create customizable templates for different data types and layouts.\n",
"#E7",
"LLM",
"Implement customizable templates for various data types and layouts in the Flatfile Listener using #E6 as a base",
"Plan: Create customizable templates for different data types and layouts.\n#E7 = LLM[Implement customizable templates for various data types and layouts in the Flatfile Listener using #E6 as a base]"
],
[
"Add options for styling (CSS) and basic interactivity (JavaScript).\n",
"#E8",
"LLM",
"Extend the Flatfile Listener to include options for CSS styling and basic JavaScript interactivity using #E7 as a base",
"Plan: Add options for styling (CSS) and basic interactivity (JavaScript).\n#E8 = LLM[Extend the Flatfile Listener to include options for CSS styling and basic JavaScript interactivity using #E7 as a base]"
],
[
"Implement sitemap and basic SEO metadata generation.\n",
"#E9",
"LLM",
"Add functionality to generate a sitemap and basic SEO metadata in the Flatfile Listener using #E8 as a base",
"Plan: Implement sitemap and basic SEO metadata generation.\n#E9 = LLM[Add functionality to generate a sitemap and basic SEO metadata in the Flatfile Listener using #E8 as a base]"
],
[
"Add an option to export the generated site as a zip file or deploy directly to a hosting service.\n",
"#E10",
"LLM",
"Implement export functionality for the generated site as a zip file and direct deployment to a hosting service in the Flatfile Listener using #E9 as a base",
"Plan: Add an option to export the generated site as a zip file or deploy directly to a hosting service.\n#E10 = LLM[Implement export functionality for the generated site as a zip file and direct deployment to a hosting service in the Flatfile Listener using #E9 as a base]"
],
[
"Implement data visualization components for relevant data.\n",
"#E11",
"LLM",
"Add data visualization components (charts, tables) for relevant data in the Flatfile Listener using #E10 as a base",
"Plan: Implement data visualization components for relevant data.\n#E11 = LLM[Add data visualization components (charts, tables) for relevant data in the Flatfile Listener using #E10 as a base]"
],
[
"Include search functionality for larger datasets.\n",
"#E12",
"LLM",
"Implement search functionality for larger datasets in the Flatfile Listener using #E11 as a base",
"Plan: Include search functionality for larger datasets.\n#E12 = LLM[Implement search functionality for larger datasets in the Flatfile Listener using #E11 as a base]"
],
[
"Ensure responsive design for mobile and desktop viewing.\n",
"#E13",
"LLM",
"Add responsive design capabilities for mobile and desktop viewing in the Flatfile Listener using #E12 as a base",
"Plan: Ensure responsive design for mobile and desktop viewing.\n#E13 = LLM[Add responsive design capabilities for mobile and desktop viewing in the Flatfile Listener using #E12 as a base]"
],
[
"Verify that the Flatfile Listener plugin subscribes to valid Event Topics and uses appropriate plugins and utils.\n",
"#E14",
"FlatfileLocal",
"List of valid Event Topics for Flatfile Listeners",
"Plan: Verify that the Flatfile Listener plugin subscribes to valid Event Topics and uses appropriate plugins and utils.\n#E14 = FlatfileLocal[List of valid Event Topics for Flatfile Listeners]"
],
[
"Validate the final Flatfile Listener plugin code, remove unused imports, and ensure all parameters are correct.\n",
"#E15",
"LLM",
"Validate the Flatfile Listener plugin code from #E13, remove unused imports, ensure all parameters are correct, and verify that it only subscribes to valid Event Topics from #E14",
"Plan: Validate the final Flatfile Listener plugin code, remove unused imports, and ensure all parameters are correct.\n#E15 = LLM[Validate the Flatfile Listener plugin code from #E13, remove unused imports, ensure all parameters are correct, and verify that it only subscribes to valid Event Topics from #E14]"
]
],
"metrics": {
"tokens": {
"plan": 24373,
"state": 15545,
"total": 39918
}
}
}
63 changes: 63 additions & 0 deletions validators/StaticSiteGenerator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "flatfile-static-site-generator",
"version": "1.0.0",
"description": "A Flatfile Listener plugin that implements a static site generator with data processing and customization options",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
"types": "./dist/index.d.ts",
"node": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"default": "./dist/index.mjs"
},
"scripts": {
"build": "rollup -c",
"build:watch": "rollup -c --watch",
"build:prod": "NODE_ENV=production rollup -c",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=jest.config.js --runInBand"
},
"keywords": [
"flatfile",
"plugin",
"static-site-generator",
"data-processing",
"flatfile-plugins"
],
"author": "Your Name",
"license": "MIT",
"dependencies": {
"@flatfile/listener": "^1.0.5",
"@flatfile/plugin-xlsx-extractor": "^3.1.4",
"@flatfile/plugin-delimiter-extractor": "^2.1.3",
"@flatfile/plugin-record-hook": "^1.6.1",
"@flatfile/plugin-export-workbook": "^0.3.1",
"@flatfile/plugin-automap": "^0.4.1",
"@flatfile/api": "^1.9.14",
"handlebars": "^4.7.8",
"jszip": "^3.10.1",
"chart.js": "^4.4.4"
},
"devDependencies": {
"@flatfile/hooks": "^1.5.0",
"@flatfile/rollup-config": "^0.1.1",
"@types/node": "^22.5.5",
"typescript": "^5.6.2",
"rollup": "^4.22.0",
"jest": "^29.7.0",
"@types/jest": "^29.5.13"
},
"peerDependencies": {
"@flatfile/listener": "^1.0.5"
},
"repository": {
"type": "git",
"url": "https://github.com/yourusername/flatfile-static-site-generator.git"
},
"engines": {
"node": ">=14.0.0"
}
}
50 changes: 50 additions & 0 deletions validators/StaticSiteGenerator/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { buildConfig } from '@flatfile/rollup-config';
import typescript from '@rollup/plugin-typescript';

const umdExternals = [
'@flatfile/api',
'@flatfile/hooks',
'@flatfile/listener',
'@flatfile/util-common',
'@flatfile/plugin-xlsx-extractor',
'@flatfile/plugin-delimiter-extractor',
'@flatfile/plugin-record-hook',
'@flatfile/plugin-export-workbook',
'@flatfile/plugin-automap',
'fs',
'path',
'child_process',
'util',
'handlebars',
'jszip',
'chart.js'
];

const config = buildConfig({
includeUmd: true,
umdConfig: { name: 'FlatfileStaticSiteGenerator', external: umdExternals },
external: [
...umdExternals,
'fs/promises',
],
});

// Add TypeScript configuration
config.forEach(conf => {
if (!conf.plugins) conf.plugins = [];
conf.plugins.push(typescript({
tsconfig: './tsconfig.json',
declaration: false,
declarationDir: undefined,
}));
});

// Add source mapping
config.forEach(conf => {
conf.output = conf.output.map(output => ({
...output,
sourcemap: true,
}));
});

export default config;
Loading