#522 - Add Astro support

This commit is contained in:
Elio Struyf
2023-03-04 10:45:18 +01:00
parent 541e02e72c
commit 6f45277b49
4 changed files with 32 additions and 3 deletions
+2
View File
@@ -15,6 +15,8 @@
### 🎨 Enhancements
- [#522](https://github.com/estruyf/vscode-front-matter/issues/522): Configuration support added for [Astro](https://astro.build)
### ⚡️ Optimizations
### 🐞 Fixes
+16 -1
View File
@@ -1,4 +1,18 @@
export const FrameworkDetectors = [
{
framework: {
name: 'astro',
dist: 'dist',
static: 'public',
build: 'npm run build',
server: 'http://127.0.0.1:3000'
},
requiredFiles: ['astro.config.mjs'],
requiredDependencies: ['astro'],
commands: {
start: 'npm run dev'
}
},
{
framework: {
name: 'gatsby',
@@ -17,7 +31,8 @@ export const FrameworkDetectors = [
name: 'hugo',
dist: 'public',
static: 'static',
build: 'hugo'
build: 'hugo',
server: 'http://127.0.0.1:1313'
},
requiredFiles: ['config.toml', 'config.yaml', 'config.yml'],
commands: {
+13 -2
View File
@@ -1,7 +1,12 @@
import { join } from 'path';
import { commands, Uri } from 'vscode';
import { Folders } from '../../commands/Folders';
import { COMMAND_NAME, SETTING_CONTENT_STATIC_FOLDER, SETTING_FRAMEWORK_ID } from '../../constants';
import {
COMMAND_NAME,
SETTING_CONTENT_STATIC_FOLDER,
SETTING_FRAMEWORK_ID,
SETTING_PREVIEW_HOST
} from '../../constants';
import { DashboardCommand } from '../../dashboardWebView/DashboardCommand';
import { DashboardMessage } from '../../dashboardWebView/DashboardMessage';
import { DashboardSettings, Settings } from '../../helpers';
@@ -62,12 +67,18 @@ export class SettingsListener extends BaseListener {
if (frameworkId) {
const allFrameworks = FrameworkDetector.getAll();
const framework = allFrameworks.find((f: Framework) => f.name === frameworkId);
const framework: Framework | undefined = allFrameworks.find(
(f: Framework) => f.name === frameworkId
);
if (framework) {
if (framework.static) {
await Settings.update(SETTING_CONTENT_STATIC_FOLDER, framework.static, true);
}
if (framework.server) {
await Settings.update(SETTING_PREVIEW_HOST, framework.server, true);
}
await FrameworkDetector.checkDefaultSettings(framework);
} else {
await Settings.update(SETTING_CONTENT_STATIC_FOLDER, '', true);
+1
View File
@@ -3,4 +3,5 @@ export interface Framework {
dist: string;
static: string;
build: string;
server?: string;
}