mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-07-04 17:01:05 +02:00
#323 - Added additional SSGs
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
- [#308](https://github.com/estruyf/vscode-front-matter/issues/308): New `File` field
|
||||
- [#314](https://github.com/estruyf/vscode-front-matter/issues/314): New preview actions to open the page in the browser and refresh the preview
|
||||
- [#322](https://github.com/estruyf/vscode-front-matter/issues/322): Show parent folder name when file is an index page (`index.md` / `_index.md`)
|
||||
- [#323](https://github.com/estruyf/vscode-front-matter/issues/323): Added 11ty, jekyll, and docusaurus to the framework selection list
|
||||
|
||||
### ⚡️ Optimizations
|
||||
|
||||
|
||||
@@ -1,33 +1,89 @@
|
||||
export const FrameworkDetectors = [
|
||||
{
|
||||
"framework": {"name": "gatsby", "dist": "public", "static": "static", "build": "gatsby build"},
|
||||
"requiredFiles": ["gatsby-config.js"],
|
||||
"requiredDependencies": ["gatsby"],
|
||||
"commands": {
|
||||
"start": "npx gatsby develop"
|
||||
export const FrameworkDetectors = [{
|
||||
framework: {
|
||||
name: "gatsby",
|
||||
dist: "public",
|
||||
static: "static",
|
||||
build: "gatsby build"
|
||||
},
|
||||
requiredFiles: ["gatsby-config.js"],
|
||||
requiredDependencies: ["gatsby"],
|
||||
commands: {
|
||||
start: "npx gatsby develop"
|
||||
}
|
||||
},
|
||||
{
|
||||
"framework": {"name": "hugo", "dist": "public", "static": "static", "build": "hugo"},
|
||||
"requiredFiles": ["config.toml", "config.yaml", "config.yml"],
|
||||
"commands": {
|
||||
"start": "hugo server -D"
|
||||
framework: {
|
||||
name: "hugo",
|
||||
dist: "public",
|
||||
static: "static",
|
||||
build: "hugo"
|
||||
},
|
||||
requiredFiles: ["config.toml", "config.yaml", "config.yml"],
|
||||
commands: {
|
||||
start: "hugo server -D"
|
||||
}
|
||||
},
|
||||
{
|
||||
"framework": {"name": "next", "dist": ".next", "static": "public", "build": "next build"},
|
||||
"requiredFiles": ["next.config.js"],
|
||||
"requiredDependencies": ["next"],
|
||||
"commands": {
|
||||
"start": "npx next dev"
|
||||
framework: {
|
||||
name: "next",
|
||||
dist: ".next",
|
||||
static: "public",
|
||||
build: "next build"
|
||||
},
|
||||
requiredFiles: ["next.config.js"],
|
||||
requiredDependencies: ["next"],
|
||||
commands: {
|
||||
start: "npx next dev"
|
||||
}
|
||||
},
|
||||
{
|
||||
"framework": {"name": "nuxt", "dist": "dist", "static": "static", "build": "nuxt"},
|
||||
"requiredFiles": ["nuxt.config.js"],
|
||||
"requiredDependencies": ["nuxt"],
|
||||
"commands": {
|
||||
"start": "npx nuxt"
|
||||
framework: {
|
||||
name: "nuxt",
|
||||
dist: "dist",
|
||||
static: "static",
|
||||
build: "nuxt"
|
||||
},
|
||||
requiredFiles: ["nuxt.config.js"],
|
||||
requiredDependencies: ["nuxt"],
|
||||
commands: {
|
||||
start: "npx nuxt"
|
||||
}
|
||||
},
|
||||
{
|
||||
framework: {
|
||||
name: "jekyll",
|
||||
dist: "_site",
|
||||
static: "assets",
|
||||
build: "bundle exec jekyll build"
|
||||
},
|
||||
requiredFiles: ["Gemfile"],
|
||||
requiredDependencies: ["jekyll"],
|
||||
commands: {
|
||||
start: "bundle exec jekyll serve --livereload"
|
||||
}
|
||||
},
|
||||
{
|
||||
framework: {
|
||||
name: "docusaurus",
|
||||
dist: "build",
|
||||
static: "static",
|
||||
build: "npx docusaurus build"
|
||||
},
|
||||
requiredFiles: ["docusaurus.config.js"],
|
||||
requiredDependencies: ["@docusaurus/core"],
|
||||
commands: {
|
||||
start: "npx docusaurus start"
|
||||
}
|
||||
},
|
||||
{
|
||||
framework: {
|
||||
name: "11ty",
|
||||
dist: "_site",
|
||||
build: "npx @11ty/eleventy"
|
||||
},
|
||||
requiredDependencies: ["@11ty/eleventy"],
|
||||
commands: {
|
||||
start: "npx @11ty/eleventy --serve"
|
||||
}
|
||||
}
|
||||
];
|
||||
@@ -1,5 +1,5 @@
|
||||
import { existsSync } from "fs";
|
||||
import { resolve } from "path";
|
||||
import { existsSync, readFileSync } from "fs";
|
||||
import { join, resolve } from "path";
|
||||
import { FrameworkDetectors } from "../constants/FrameworkDetectors";
|
||||
import { Extension } from "./Extension";
|
||||
|
||||
@@ -14,18 +14,52 @@ export class FrameworkDetector {
|
||||
}
|
||||
|
||||
private static check(folder: string) {
|
||||
const { dependencies, devDependencies } = Extension.getInstance().packageJson;
|
||||
let dependencies = null;
|
||||
let devDependencies = null;
|
||||
let gemContent = null;
|
||||
|
||||
// Try fetching the package JSON file
|
||||
try {
|
||||
const pkgFile = join(folder, 'package.json');
|
||||
if (existsSync(pkgFile)) {
|
||||
let packageJson: any = readFileSync(pkgFile, "utf8");
|
||||
if (packageJson) {
|
||||
packageJson = typeof packageJson === "string" ? JSON.parse(packageJson) : packageJson;
|
||||
|
||||
dependencies = packageJson.dependencies || null;
|
||||
devDependencies = packageJson.devDependencies || null;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// Try fetching the Gemfile
|
||||
try {
|
||||
const gemFile = join(folder, 'Gemfile');
|
||||
if (existsSync(gemFile)) {
|
||||
gemContent = readFileSync(gemFile, "utf8");
|
||||
}
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
for (const detector of FrameworkDetectors) {
|
||||
if (detector && folder) {
|
||||
|
||||
// Verify by dependencies
|
||||
for (const dependency of detector.requiredDependencies ?? []) {
|
||||
// Checks for package.json dependencies
|
||||
const inDependencies = dependencies && dependencies[dependency]
|
||||
const inDevDependencies = devDependencies && devDependencies[dependency]
|
||||
if (inDependencies || inDevDependencies) {
|
||||
return detector.framework;
|
||||
}
|
||||
|
||||
// Checks for Gemfile
|
||||
if (gemContent && gemContent.includes(dependency)) {
|
||||
return detector.framework;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify by files
|
||||
|
||||
Reference in New Issue
Block a user