#650 - Use the templates repo

This commit is contained in:
Elio Struyf
2023-09-09 16:56:58 +02:00
parent a2d1100123
commit 0ed93977bc
15 changed files with 489 additions and 508 deletions
+68
View File
@@ -54,6 +54,7 @@
"downshift": "6.0.6",
"eslint": "^8.33.0",
"fuse.js": "6.5.3",
"github-directory-downloader": "^1.3.6",
"glob": "7.1.6",
"gray-matter": "4.0.3",
"html-loader": "1.3.2",
@@ -2146,6 +2147,15 @@
"dev": true,
"license": "MIT"
},
"node_modules/at-least-node": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
"integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==",
"dev": true,
"engines": {
"node": ">= 4.0.0"
}
},
"node_modules/attr-accept": {
"version": "2.2.2",
"dev": true,
@@ -4912,6 +4922,21 @@
"dev": true,
"license": "MIT"
},
"node_modules/fs-extra": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
"dev": true,
"dependencies": {
"at-least-node": "^1.0.0",
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/fs-monkey": {
"version": "1.0.3",
"dev": true,
@@ -5004,6 +5029,20 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/github-directory-downloader": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/github-directory-downloader/-/github-directory-downloader-1.3.6.tgz",
"integrity": "sha512-k43h2cjdE5FIpM+0aYuK4DTdTZ2FcopgbY8kvzR2hihdq/gRyINrLDpLlFrkVID6sTi0vSaBqVJm7goLcbBxQg==",
"dev": true,
"dependencies": {
"fs-extra": "^9.0.1",
"node-fetch": "^2.6.1",
"yargs-parser": "^20.2.4"
},
"bin": {
"github-directory-downloader": "bin/cli.js"
}
},
"node_modules/github-from-package": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz",
@@ -14669,6 +14708,12 @@
"version": "0.4.0",
"dev": true
},
"at-least-node": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
"integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==",
"dev": true
},
"attr-accept": {
"version": "2.2.2",
"dev": true
@@ -16606,6 +16651,18 @@
"version": "1.0.0",
"dev": true
},
"fs-extra": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
"dev": true,
"requires": {
"at-least-node": "^1.0.0",
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
}
},
"fs-monkey": {
"version": "1.0.3",
"dev": true
@@ -16660,6 +16717,17 @@
"get-intrinsic": "^1.1.1"
}
},
"github-directory-downloader": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/github-directory-downloader/-/github-directory-downloader-1.3.6.tgz",
"integrity": "sha512-k43h2cjdE5FIpM+0aYuK4DTdTZ2FcopgbY8kvzR2hihdq/gRyINrLDpLlFrkVID6sTi0vSaBqVJm7goLcbBxQg==",
"dev": true,
"requires": {
"fs-extra": "^9.0.1",
"node-fetch": "^2.6.1",
"yargs-parser": "^20.2.4"
}
},
"github-from-package": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz",
+154 -122
View File
@@ -10,7 +10,8 @@
"color": "#0e131f",
"theme": "dark"
},
"badges": [{
"badges": [
{
"description": "version",
"url": "https://img.shields.io/github/package-json/v/estruyf/vscode-front-matter?color=green&label=vscode-front-matter&style=flat-square",
"href": "https://github.com/estruyf/vscode-front-matter"
@@ -70,7 +71,8 @@
"**/.frontmatter/config/*.json": "jsonc"
}
},
"keybindings": [{
"keybindings": [
{
"command": "frontMatter.dashboard",
"key": "alt+d"
},
@@ -88,20 +90,24 @@
}
],
"viewsContainers": {
"activitybar": [{
"id": "frontmatter-explorer",
"title": "Front Matter",
"icon": "assets/frontmatter-short-min.svg"
}]
"activitybar": [
{
"id": "frontmatter-explorer",
"title": "Front Matter",
"icon": "assets/frontmatter-short-min.svg"
}
]
},
"views": {
"frontmatter-explorer": [{
"id": "frontMatter.explorer",
"name": "Front Matter",
"icon": "assets/frontmatter-short-min.svg",
"contextualTitle": "Front Matter",
"type": "webview"
}]
"frontmatter-explorer": [
{
"id": "frontMatter.explorer",
"name": "Front Matter",
"icon": "assets/frontmatter-short-min.svg",
"contextualTitle": "Front Matter",
"type": "webview"
}
]
},
"configuration": {
"title": "%settings.configuration.title%",
@@ -164,7 +170,8 @@
"frontMatter.content.defaultFileType": {
"type": "string",
"default": "md",
"oneOf": [{
"oneOf": [
{
"enum": [
"md",
"mdx"
@@ -180,7 +187,8 @@
"frontMatter.content.defaultSorting": {
"type": "string",
"default": "",
"oneOf": [{
"oneOf": [
{
"enum": [
"LastModifiedAsc",
"LastModifiedDesc",
@@ -527,7 +535,8 @@
"command": {
"$id": "#scriptCommand",
"type": "string",
"anyOf": [{
"anyOf": [
{
"enum": [
"node",
"bash",
@@ -727,7 +736,8 @@
"title",
"file"
],
"anyOf": [{
"anyOf": [
{
"required": [
"schema"
]
@@ -781,7 +791,8 @@
"id",
"path"
],
"anyOf": [{
"anyOf": [
{
"required": [
"schema"
]
@@ -1149,7 +1160,8 @@
"default": "",
"description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.taxonomyId.description%",
"not": {
"anyOf": [{
"anyOf": [
{
"const": ""
},
{
@@ -1343,7 +1355,8 @@
"type",
"name"
],
"allOf": [{
"allOf": [
{
"if": {
"properties": {
"type": {
@@ -1529,48 +1542,51 @@
"fields"
]
},
"default": [{
"name": "default",
"pageBundle": false,
"fields": [{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"title": "Publishing date",
"name": "date",
"type": "datetime",
"default": "{{now}}",
"isPublishDate": true
},
{
"title": "Content preview",
"name": "preview",
"type": "image"
},
{
"title": "Is in draft",
"name": "draft",
"type": "boolean"
},
{
"title": "Tags",
"name": "tags",
"type": "tags"
},
{
"title": "Categories",
"name": "categories",
"type": "categories"
}
]
}],
"default": [
{
"name": "default",
"pageBundle": false,
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"title": "Publishing date",
"name": "date",
"type": "datetime",
"default": "{{now}}",
"isPublishDate": true
},
{
"title": "Content preview",
"name": "preview",
"type": "image"
},
{
"title": "Is in draft",
"name": "draft",
"type": "boolean"
},
{
"title": "Tags",
"name": "tags",
"type": "tags"
},
{
"title": "Categories",
"name": "categories",
"type": "categories"
}
]
}
],
"scope": "Taxonomy"
},
"frontMatter.taxonomy.customTaxonomy": {
@@ -1583,7 +1599,8 @@
"type": "string",
"description": "%setting.frontMatter.taxonomy.customTaxonomy.items.properties.id.description%",
"not": {
"anyOf": [{
"anyOf": [
{
"const": ""
},
{
@@ -1769,7 +1786,8 @@
}
}
},
"commands": [{
"commands": [
{
"command": "frontMatter.project.switch",
"title": "%command.frontMatter.project.switch%",
"category": "Front Matter",
@@ -2104,12 +2122,15 @@
"category": "Front Matter"
}
],
"submenus": [{
"id": "frontmatter.submenu",
"label": "Front Matter"
}],
"submenus": [
{
"id": "frontmatter.submenu",
"label": "Front Matter"
}
],
"menus": {
"editor/title": [{
"editor/title": [
{
"command": "frontMatter.markup.heading",
"group": "navigation@-133",
"when": "frontMatter:file:isValid == true && frontMatter:markdown:wysiwyg"
@@ -2190,11 +2211,14 @@
"when": "resourceFilename == 'frontmatter.json'"
}
],
"explorer/context": [{
"submenu": "frontmatter.submenu",
"group": "frontmatter@1"
}],
"frontmatter.submenu": [{
"explorer/context": [
{
"submenu": "frontmatter.submenu",
"group": "frontmatter@1"
}
],
"frontmatter.submenu": [
{
"command": "frontMatter.createFromTemplate",
"when": "explorerResourceIsFolder",
"group": "frontmatter@1"
@@ -2210,7 +2234,8 @@
"group": "frontmatter@3"
}
],
"commandPalette": [{
"commandPalette": [
{
"command": "frontMatter.init",
"when": "frontMatterCanInit"
},
@@ -2355,7 +2380,8 @@
"when": "frontMatter:file:isValid == true"
}
],
"view/title": [{
"view/title": [
{
"command": "frontMatter.chatbot",
"group": "navigation@0",
"when": "view == frontMatter.explorer"
@@ -2386,52 +2412,57 @@
}
]
},
"grammars": [{
"path": "./syntaxes/hugo.tmLanguage.json",
"scopeName": "frontmatter.markdown.hugo",
"injectTo": [
"text.html.markdown"
]
}],
"walkthroughs": [{
"id": "frontmatter.welcome",
"title": "Get started with Front Matter",
"description": "Discover the features of Front Matter and learn how to use the CMS for your SSG or static site.",
"steps": [{
"id": "frontmatter.welcome.init",
"title": "Get started",
"description": "Initial steps to get started.\n[Open dashboard](command:frontMatter.dashboard)",
"media": {
"markdown": "assets/walkthrough/get-started.md"
"grammars": [
{
"path": "./syntaxes/hugo.tmLanguage.json",
"scopeName": "frontmatter.markdown.hugo",
"injectTo": [
"text.html.markdown"
]
}
],
"walkthroughs": [
{
"id": "frontmatter.welcome",
"title": "Get started with Front Matter",
"description": "Discover the features of Front Matter and learn how to use the CMS for your SSG or static site.",
"steps": [
{
"id": "frontmatter.welcome.init",
"title": "Get started",
"description": "Initial steps to get started.\n[Open dashboard](command:frontMatter.dashboard)",
"media": {
"markdown": "assets/walkthrough/get-started.md"
},
"completionEvents": [
"onContext:frontMatterInitialized"
]
},
"completionEvents": [
"onContext:frontMatterInitialized"
]
},
{
"id": "frontmatter.welcome.documentation",
"title": "Documentation",
"description": "Check out the documentation for Front Matter.\n[View our documentation](https://frontmatter.codes/docs)",
"media": {
"markdown": "assets/walkthrough/documentation.md"
{
"id": "frontmatter.welcome.documentation",
"title": "Documentation",
"description": "Check out the documentation for Front Matter.\n[View our documentation](https://frontmatter.codes/docs)",
"media": {
"markdown": "assets/walkthrough/documentation.md"
},
"completionEvents": [
"onLink:https://frontmatter.codes/docs"
]
},
"completionEvents": [
"onLink:https://frontmatter.codes/docs"
]
},
{
"id": "frontmatter.welcome.supporter",
"title": "Support the project",
"description": "Become a supporter.\n[Support the project](https://github.com/sponsors/estruyf)",
"media": {
"markdown": "assets/walkthrough/support-the-project.md"
},
"completionEvents": [
"onLink:https://github.com/sponsors/estruyf"
]
}
]
}]
{
"id": "frontmatter.welcome.supporter",
"title": "Support the project",
"description": "Become a supporter.\n[Support the project](https://github.com/sponsors/estruyf)",
"media": {
"markdown": "assets/walkthrough/support-the-project.md"
},
"completionEvents": [
"onLink:https://github.com/sponsors/estruyf"
]
}
]
}
]
},
"scripts": {
"dev:ext": "npm run clean && npm run localization:generate && npm-run-all --parallel watch:*",
@@ -2504,6 +2535,7 @@
"downshift": "6.0.6",
"eslint": "^8.33.0",
"fuse.js": "6.5.3",
"github-directory-downloader": "^1.3.6",
"glob": "7.1.6",
"gray-matter": "4.0.3",
"html-loader": "1.3.2",
@@ -2565,4 +2597,4 @@
"vsce": {
"dependencies": false
}
}
}
-12
View File
@@ -1,12 +0,0 @@
import { FrameworkTemplate } from '../models';
export const FrameworkTemplates: FrameworkTemplate[] = [
{
id: 'astro-starlight',
framework: 'astro',
name: 'Starlight',
description: 'Adds the Astro Starlight configuration for Front Matter CMS',
template: 'astro-starlight',
showDashboardOnComplete: true
}
];
+3
View File
@@ -0,0 +1,3 @@
export const Templates = {
url: 'https://frontmatter.github.io/templates/templates.json'
};
+1 -1
View File
@@ -6,7 +6,6 @@ export * from './Extension';
export * from './ExtensionState';
export * from './Features';
export * from './FrameworkDetectors';
export * from './FrameworkTemplates';
export * from './GeneralCommands';
export * from './Links';
export * from './LocalStore';
@@ -17,6 +16,7 @@ export * from './SentryIgnore';
export * from './Snippet';
export * from './StaticFolderPlaceholder';
export * from './TelemetryEvent';
export * from './Templates';
export * from './charCode';
export * from './charMap';
export * from './context';
@@ -7,7 +7,7 @@ import { Step } from './Step';
import { useMemo, useState } from 'react';
import { Menu } from '@headlessui/react';
import { MenuItem } from '../Menu';
import { ContentFolder, Framework, FrameworkTemplate, StaticFolder } from '../../../models';
import { ContentFolder, Framework, StaticFolder, Template } from '../../../models';
import { ChevronDownIcon } from '@heroicons/react/outline';
import { FrameworkDetectors } from '../../../constants/FrameworkDetectors';
import { join } from 'path';
@@ -15,7 +15,7 @@ import useThemeColors from '../../hooks/useThemeColors';
import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../../../localization';
import { SelectItem } from './SelectItem';
import { FrameworkTemplates } from '../../../constants';
import { Templates } from '../../../constants';
export interface IStepsToGetStartedProps {
settings: Settings;
@@ -52,6 +52,7 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
}: React.PropsWithChildren<IStepsToGetStartedProps>) => {
const [framework, setFramework] = useState<string | null>(null);
const [taxImported, setTaxImported] = useState<boolean>(false);
const [templates, setTemplates] = useState<Template[]>([]);
const { getColors } = useThemeColors();
const frameworks: Framework[] = FrameworkDetectors.map((detector: any) => detector.framework);
@@ -69,7 +70,7 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
Messenger.send(DashboardMessage.addAssetsFolder, folder);
}
const triggerTemplate = (template: FrameworkTemplate) => {
const triggerTemplate = (template: Template) => {
messageHandler.request<boolean>(DashboardMessage.triggerTemplate, template).then((result) => {
if (result) {
reload();
@@ -93,205 +94,207 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
setTaxImported(true);
};
const templates = useMemo(() => {
if (!settings.crntFramework) {
const crntTemplates = useMemo(() => {
if (!templates || templates.length === 0 || !settings.crntFramework) {
return [];
}
return FrameworkTemplates.filter((t) => t.framework === settings.crntFramework);
}, [settings.crntFramework])
return templates.filter((t) => t.type === settings.crntFramework);
}, [templates, settings.crntFramework])
const steps = [
{
id: `welcome-init`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedInitializeProjectName),
description: <>{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedInitializeProjectDescription)}</>,
show: true,
status: settings.initialized ? Status.Completed : Status.NotStarted,
onClick: settings.initialized
? undefined
: () => {
Messenger.send(DashboardMessage.initializeProject);
}
},
{
id: `welcome-framework`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedFrameworkName),
description: (
<div>
const steps = useMemo(() => (
[
{
id: `welcome-init`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedInitializeProjectName),
description: <>{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedInitializeProjectDescription)}</>,
show: true,
status: settings.initialized ? Status.Completed : Status.NotStarted,
onClick: settings.initialized
? undefined
: () => {
Messenger.send(DashboardMessage.initializeProject);
}
},
{
id: `welcome-framework`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedFrameworkName),
description: (
<div>
{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedFrameworkDescription)}
</div>
<Menu as="div" className="relative inline-block text-left mt-4">
<div>
<Menu.Button className={`group flex justify-center p-2 rounded-md border ${getColors(
'text-vulcan-500 hover:text-vulcan-600 dark:text-whisper-500 dark:hover:text-whisper-600 border-vulcan-400 dark:border-white',
'text-[var(--vscode-tab-inactiveForeground)] hover:text-[var(--vscode-tab-activeForeground)]'
)
}`}>
{framework ? framework : l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedFrameworkSelect)}
<ChevronDownIcon
className={`flex-shrink-0 -mr-1 ml-1 h-5 w-5 ${getColors(
'text-gray-400 group-hover:text-gray-500 dark:text-whisper-600 dark:group-hover:text-whisper-700',
''
)
}`}
aria-hidden="true"
/>
</Menu.Button>
{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedFrameworkDescription)}
</div>
<Menu.Items
className={`w-40 origin-top-left absolute left-0 z-10 mt-2 rounded-md shadow-2xl ring-1 ring-opacity-5 focus:outline-none text-sm max-h-96 overflow-auto ${getColors(
'bg-white dark:bg-vulcan-500 ring-vulcan-400 dark:ring-white',
'bg-[var(--vscode-sideBar-background)] ring-[var(--frontmatter-border)]'
)
}`}
>
<div className="py-1">
<MenuItem
title={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedFrameworkSelectOther)}
value={`other`}
isCurrent={!framework}
onClick={(value: string) => setFrameworkAndSendMessage(value)}
/>
<Menu as="div" className="relative inline-block text-left mt-4">
<div>
<Menu.Button className={`group flex justify-center p-2 rounded-md border ${getColors(
'text-vulcan-500 hover:text-vulcan-600 dark:text-whisper-500 dark:hover:text-whisper-600 border-vulcan-400 dark:border-white',
'text-[var(--vscode-tab-inactiveForeground)] hover:text-[var(--vscode-tab-activeForeground)]'
)
}`}>
{framework ? framework : l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedFrameworkSelect)}
<ChevronDownIcon
className={`flex-shrink-0 -mr-1 ml-1 h-5 w-5 ${getColors(
'text-gray-400 group-hover:text-gray-500 dark:text-whisper-600 dark:group-hover:text-whisper-700',
''
)
}`}
aria-hidden="true"
/>
</Menu.Button>
</div>
<hr className={`border-[var(--frontmatter-border)]`} />
{frameworks.map((f) => (
<Menu.Items
className={`w-40 origin-top-left absolute left-0 z-10 mt-2 rounded-md shadow-2xl ring-1 ring-opacity-5 focus:outline-none text-sm max-h-96 overflow-auto ${getColors(
'bg-white dark:bg-vulcan-500 ring-vulcan-400 dark:ring-white',
'bg-[var(--vscode-sideBar-background)] ring-[var(--frontmatter-border)]'
)
}`}
>
<div className="py-1">
<MenuItem
key={f.name}
title={f.name}
value={f.name}
isCurrent={f.name === framework}
title={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedFrameworkSelectOther)}
value={`other`}
isCurrent={!framework}
onClick={(value: string) => setFrameworkAndSendMessage(value)}
/>
))}
</div>
</Menu.Items>
</Menu>
</div>
),
show: true,
status: settings.crntFramework ? Status.Completed : Status.NotStarted,
onClick: undefined
},
{
id: `welcome-template`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedTemplateName),
description: (
<div className='mt-4'>
<div className="text-sm">{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedTemplateDescription)}</div>
<div className="mt-1 space-y-1">
{
templates && (templates || []).map(template => (
<SelectItem
key={template.id}
title={template.name}
icon='add'
buttonTitle={template.name}
isSelected={false}
onClick={() => triggerTemplate(template)} />
))
}
<hr className={`border-[var(--frontmatter-border)]`} />
{frameworks.map((f) => (
<MenuItem
key={f.name}
title={f.name}
value={f.name}
isCurrent={f.name === framework}
onClick={(value: string) => setFrameworkAndSendMessage(value)}
/>
))}
</div>
</Menu.Items>
</Menu>
</div>
</div>
),
show: (templates || []).length > 0,
status: Status.Active,
},
{
id: `welcome-assets`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderName),
description: (
<div className='mt-4'>
<div className="text-sm">{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderDescription)}</div>
<div className="mt-1 space-y-1">
<SelectItem
title={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderPublicTitle)}
buttonTitle={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderPublicTitle)}
isSelected={settings.staticFolder === "public"}
onClick={() => addAssetFolder(`public`)} />
<SelectItem
title={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderAssetsTitle)}
buttonTitle={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderAssetsTitle)}
isSelected={settings.staticFolder === "src/assets"}
onClick={() => addAssetFolder({
"path": "src/assets",
"relative": true
})} />
<p className='text-sm'>
<b>{l10n.t(LocalizationKey.commonInformation)}</b>: {l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderOtherDescription)}</p>
</div>
</div>
),
show: settings.crntFramework === 'astro' || framework === 'astro',
status: settings.initialized && settings.staticFolder && settings.staticFolder !== "/" ? Status.Completed : Status.NotStarted,
},
{
id: `welcome-content-folders`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedContentFoldersName),
description: (
<>
<p>
{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedContentFoldersDescription)}
</p>
{settings?.dashboardState?.welcome?.contentFolders?.length > 0 && (
<div className="mt-4">
<div className="text-sm">{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedContentFoldersLabel)}</div>
<div className="mt-1 space-y-1">
{settings?.dashboardState?.welcome?.contentFolders?.map((folder: string) => (
<Folder
key={folder}
folder={folder}
addFolder={addFolder}
wsFolder={settings.wsFolder}
folders={settings.contentFolders}
/>
))}
</div>
),
show: true,
status: settings.crntFramework ? Status.Completed : Status.NotStarted,
onClick: undefined
},
{
id: `welcome-template`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedTemplateName),
description: (
<div className='mt-4'>
<div className="text-sm">{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedTemplateDescription)}</div>
<div className="mt-1 space-y-1">
{
crntTemplates && (crntTemplates || []).map(template => (
<SelectItem
key={template.name.toLowerCase().replace(/ /g, '-')}
title={template.name}
icon='add'
buttonTitle={template.name}
isSelected={false}
onClick={() => triggerTemplate(template)} />
))
}
</div>
)}
</div>
),
show: (crntTemplates || []).length > 0,
status: Status.Active,
},
{
id: `welcome-assets`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderName),
description: (
<div className='mt-4'>
<div className="text-sm">{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderDescription)}</div>
<div className="mt-1 space-y-1">
<SelectItem
title={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderPublicTitle)}
buttonTitle={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderPublicTitle)}
isSelected={settings.staticFolder === "public"}
onClick={() => addAssetFolder(`public`)} />
<p className={`mt-4 ${getColors('text-vulcan-300 dark:text-gray-400', '')}`}>
<b>{l10n.t(LocalizationKey.commonInformation)}</b>: {l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedContentFoldersInformationDescription)}.
</p>
</>
),
show: true,
status:
settings.contentFolders && settings.contentFolders.length > 0
? Status.Completed
: Status.NotStarted
},
{
id: `welcome-import`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedTagsName),
description: <>{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedTagsDescription)}</>,
show: true,
status: taxImported ? Status.Completed : Status.NotStarted,
onClick:
settings.contentFolders && settings.contentFolders.length > 0 ? importTaxonomy : undefined
},
{
id: `welcome-show-dashboard`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedShowDashboardName),
description: <>{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedShowDashboardDescription)}</>,
show: true,
status:
settings.initialized && settings.contentFolders && settings.contentFolders.length > 0
? Status.Active
: Status.NotStarted,
onClick:
settings.initialized && settings.contentFolders && settings.contentFolders.length > 0
? reload
: undefined
}
];
<SelectItem
title={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderAssetsTitle)}
buttonTitle={l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderAssetsTitle)}
isSelected={settings.staticFolder === "src/assets"}
onClick={() => addAssetFolder({
"path": "src/assets",
"relative": true
})} />
<p className='text-sm'>
<b>{l10n.t(LocalizationKey.commonInformation)}</b>: {l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedAssetsFolderOtherDescription)}</p>
</div>
</div>
),
show: settings.crntFramework === 'astro' || framework === 'astro',
status: settings.initialized && settings.staticFolder && settings.staticFolder !== "/" ? Status.Completed : Status.NotStarted,
},
{
id: `welcome-content-folders`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedContentFoldersName),
description: (
<>
<p>
{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedContentFoldersDescription)}
</p>
{settings?.dashboardState?.welcome?.contentFolders?.length > 0 && (
<div className="mt-4">
<div className="text-sm">{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedContentFoldersLabel)}</div>
<div className="mt-1 space-y-1">
{settings?.dashboardState?.welcome?.contentFolders?.map((folder: string) => (
<Folder
key={folder}
folder={folder}
addFolder={addFolder}
wsFolder={settings.wsFolder}
folders={settings.contentFolders}
/>
))}
</div>
</div>
)}
<p className={`mt-4 ${getColors('text-vulcan-300 dark:text-gray-400', '')}`}>
<b>{l10n.t(LocalizationKey.commonInformation)}</b>: {l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedContentFoldersInformationDescription)}.
</p>
</>
),
show: true,
status:
settings.contentFolders && settings.contentFolders.length > 0
? Status.Completed
: Status.NotStarted
},
{
id: `welcome-import`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedTagsName),
description: <>{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedTagsDescription)}</>,
show: true,
status: taxImported ? Status.Completed : Status.NotStarted,
onClick:
settings.contentFolders && settings.contentFolders.length > 0 ? importTaxonomy : undefined
},
{
id: `welcome-show-dashboard`,
name: l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedShowDashboardName),
description: <>{l10n.t(LocalizationKey.dashboardStepsStepsToGetStartedShowDashboardDescription)}</>,
show: true,
status:
settings.initialized && settings.contentFolders && settings.contentFolders.length > 0
? Status.Active
: Status.NotStarted,
onClick:
settings.initialized && settings.contentFolders && settings.contentFolders.length > 0
? reload
: undefined
}
]
), [settings, framework, taxImported, templates]);
React.useEffect(() => {
if (settings.crntFramework || settings.framework?.name) {
@@ -299,6 +302,23 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
}
}, [settings.crntFramework, settings.framework]);
React.useEffect(() => {
const fetchTemplates = async () => {
try {
const response = await fetch(Templates.url);
if (response.ok) {
const data = await response.json();
setTemplates(data);
}
} catch (e) {
setTemplates([]);
}
};
fetchTemplates();
}, []);
return (
<nav aria-label="Progress">
<ol role="list">
+7 -2
View File
@@ -64,6 +64,7 @@ export class Settings {
private static configDebouncer = debounceCallback();
public static async init() {
const allCommands = await commands.getCommands(true);
await Settings.readConfig();
const projects = Settings.getProjects();
@@ -92,10 +93,14 @@ export class Settings {
if (!Settings.isInitialized) {
Settings.isInitialized = true;
commands.registerCommand(COMMAND_NAME.reloadConfig, Settings.rebindWatchers);
if (!allCommands.includes(COMMAND_NAME.reloadConfig)) {
commands.registerCommand(COMMAND_NAME.reloadConfig, Settings.rebindWatchers);
}
}
commands.registerCommand(COMMAND_NAME.settingsRefresh, Settings.reloadConfig);
if (!allCommands.includes(COMMAND_NAME.settingsRefresh)) {
commands.registerCommand(COMMAND_NAME.settingsRefresh, Settings.reloadConfig);
}
Settings.config = vscode.workspace.getConfiguration(CONFIG_KEY);
+40 -26
View File
@@ -1,5 +1,5 @@
import { join } from 'path';
import { commands, FileType, Uri, workspace } from 'vscode';
import { commands, FileType, Uri, workspace, window, ProgressLocation } from 'vscode';
import { Folders } from '../../commands/Folders';
import {
COMMAND_NAME,
@@ -12,7 +12,7 @@ import { DashboardCommand } from '../../dashboardWebView/DashboardCommand';
import { DashboardMessage } from '../../dashboardWebView/DashboardMessage';
import { DashboardSettings, Extension, Notifications, Settings } from '../../helpers';
import { FrameworkDetector } from '../../helpers/FrameworkDetector';
import { Framework, FrameworkTemplate, PostMessageData, StaticFolder } from '../../models';
import { Framework, Template, PostMessageData, StaticFolder } from '../../models';
import { BaseListener } from './BaseListener';
import { Cache } from '../../commands/Cache';
import { Preview } from '../../commands';
@@ -24,6 +24,7 @@ import { PagesListener } from './PagesListener';
import { existsAsync } from '../../utils';
import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../../localization';
import download from 'github-directory-downloader/esm';
export class SettingsListener extends BaseListener {
/**
@@ -152,32 +153,45 @@ export class SettingsListener extends BaseListener {
* Adds the template files to the workspace
* @param template
*/
private static async triggerTemplate(requestId?: string, template?: FrameworkTemplate) {
if (template && template.template) {
const templateFileLocation = join(
Extension.getInstance().extensionPath.fsPath,
'templates',
template.template
);
private static async triggerTemplate(requestId?: string, template?: Template) {
if (template && template.url) {
const wsFolder = Folders.getWorkspaceFolder();
if (await existsAsync(templateFileLocation)) {
const allFiles = await workspace.fs.readDirectory(Uri.file(templateFileLocation));
await this.copyTemplateFiles(allFiles, templateFileLocation);
await Settings.init();
await SettingsListener.getSettings(true);
if (template.showDashboardOnComplete) {
if (requestId) {
this.sendRequest(DashboardMessage.triggerTemplate as any, requestId, true);
}
} else {
Notifications.info(
l10n.t(LocalizationKey.listenersDashboardSettingsListenerTriggerTemplateNotification)
);
}
if (!wsFolder) {
return;
}
await window.withProgress(
{
location: ProgressLocation.Notification,
title: 'Downloading and initializing the template...',
cancellable: false
},
async (progress) => {
try {
const ghFolder = await download(template.url, wsFolder.fsPath);
if (!ghFolder.downloaded) {
Notifications.error('Failed to download the template.');
return;
}
await Settings.init();
await SettingsListener.getSettings(true);
if (requestId) {
this.sendRequest(DashboardMessage.triggerTemplate as any, requestId, true);
Notifications.info(
l10n.t(
LocalizationKey.listenersDashboardSettingsListenerTriggerTemplateNotification
)
);
}
} catch (e) {
Notifications.error(`Failed to initialize the template.`);
}
}
);
}
}
-8
View File
@@ -1,8 +0,0 @@
export interface FrameworkTemplate {
id: string;
framework: string;
name: string;
description: string;
template: string;
showDashboardOnComplete: boolean;
}
+8
View File
@@ -0,0 +1,8 @@
export interface Template {
name: string;
description: string;
url: string;
version: string;
author: string;
type: string;
}
+1 -1
View File
@@ -11,7 +11,6 @@ export * from './DataFolder';
export * from './DataType';
export * from './DraftField';
export * from './Framework';
export * from './FrameworkTemplate';
export * from './GitSettings';
export * from './MediaPaths';
export * from './Mode';
@@ -25,4 +24,5 @@ export * from './SortingSetting';
export * from './StaticFolder';
export * from './TaxonomyData';
export * from './TaxonomyType';
export * from './Template';
export * from './VersionInfo';
@@ -1,41 +0,0 @@
{
"$schema": "https://beta.frontmatter.codes/frontmatter.schema.json",
"frontMatter.content.snippets": {
"Aside": {
"description": "Create an admonitions or callout",
"body": [
":::<<type>><<#label>>[<<label>>]<</label>>",
"<<&content>>",
":::"
],
"openingTags": "<<",
"closingTags": ">>",
"fields": [{
"name": "type",
"title": "type",
"type": "choice",
"choices": [
"note",
"tip",
"caution",
"danger"
],
"default": "note"
},
{
"name": "label",
"title": "label",
"type": "string",
"single": true
},
{
"name": "content",
"title": "content",
"type": "string",
"single": false,
"default": "FM_SELECTED_TEXT"
}
]
}
}
}
@@ -1,80 +0,0 @@
{
"$schema": "https://beta.frontmatter.codes/frontmatter.schema.json",
"frontMatter.taxonomy.contentTypes": [{
"name": "default",
"pageBundle": false,
"previewPath": null,
"filePrefix": null,
"clearEmpty": true,
"fields": [{
"title": "Title",
"name": "title",
"type": "string",
"single": true
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"name": "divider",
"type": "divider"
},
{
"name": "heading",
"title": "Optional configuration",
"type": "heading"
},
{
"title": "Edit URL",
"name": "editUrl",
"type": "string",
"single": true
},
{
"name": "banner",
"title": "Banner",
"type": "fields",
"fields": [{
"name": "content",
"title": "Banner content",
"type": "string"
}]
},
{
"name": "template",
"title": "Page template",
"type": "choice",
"choices": [
"doc",
"splash"
]
},
{
"name": "tableOfContents",
"title": "Table of content settings",
"type": "fields",
"fields": [{
"name": "minHeadingLevel",
"title": "Minimum heading level",
"type": "number",
"numberOptions": {
"min": 2,
"max": 6
}
},
{
"name": "maxHeadingLevel",
"title": "Maximum heading level",
"type": "number",
"numberOptions": {
"min": 2,
"max": 6
}
}
]
}
]
}]
}
@@ -1,14 +0,0 @@
{
"$schema": "https://beta.frontmatter.codes/frontmatter.schema.json",
"frontMatter.content.pageFolders": [{
"title": "Guides",
"path": "[[workspace]]/src/content/docs/guides",
"previewPath": "guides"
},
{
"title": "References",
"path": "[[workspace]]/src/content/docs/reference",
"previewPath": "reference"
}
]
}
@@ -1,14 +0,0 @@
{
"$schema": "https://beta.frontmatter.codes/frontmatter.schema.json",
"frontMatter.framework.id": "astro",
"frontMatter.preview.host": "http://localhost:4321",
"frontMatter.content.publicFolder": {
"path": "src/assets",
"relative": true
},
"frontMatter.extends": [
".frontmatter/starlight/contenttypes.json",
".frontmatter/starlight/pagefolders.json",
".frontmatter/starlight/aside.json"
]
}