refactor: use templates/ folder as single source of truth and cleanup unused code

This commit is contained in:
Aleix Soler 2026-03-18 17:25:48 +01:00
parent 2537227678
commit bd0469f7c7
4 changed files with 17 additions and 275 deletions

View file

@ -113,9 +113,10 @@ You can contribute your own status templates to the plugin!
]
}
```
4. Submit a Pull Request with your JSON file!
4. Register your template in `constants/predefinedTemplates.ts` by adding an import and adding it to the `PREDEFINED_TEMPLATES` array.
5. Submit a Pull Request!
Once accepted, maintainers will include your template in the next plugin update.
Once accepted, your template will be available in the marketplace for all users.
## Installation

View file

@ -1,251 +1,18 @@
import { StatusTemplate } from "types/pluginSettings";
import academic from "../templates/academic.json";
import colorful from "../templates/colorful.json";
import creativeWriting from "../templates/creative-writing.json";
import minimal from "../templates/minimal.json";
import project from "../templates/project.json";
/**
* Predefined status templates generated from the templates directory
* Predefined status templates imported directly from the templates directory.
* This file serves as an index for the marketplace.
*/
export const PREDEFINED_TEMPLATES: StatusTemplate[] = [
{
id: "academic",
name: "Academic research",
description: "Status workflow for academic research and writing",
author: "Obsidian Note Status",
github: "https://github.com/devonthesofa/obsidian-note-status",
statuses: [
{
name: "research",
icon: "🔍",
color: "#2196F3",
templateId: "academic",
},
{
name: "outline",
icon: "📑",
color: "#9E9E9E",
templateId: "academic",
},
{
name: "draft",
icon: "✏️",
color: "#FFC107",
templateId: "academic",
},
{
name: "review",
icon: "🔬",
color: "#9C27B0",
templateId: "academic",
},
{
name: "revision",
icon: "📝",
color: "#FF5722",
templateId: "academic",
},
{
name: "final",
icon: "📚",
color: "#4CAF50",
templateId: "academic",
},
{
name: "published",
icon: "🎓",
color: "#795548",
templateId: "academic",
},
],
},
{
id: "colorful",
name: "Colorful workflow",
description:
"A colorful set of workflow statuses with descriptive icons",
author: "Obsidian Note Status",
github: "https://github.com/devonthesofa/obsidian-note-status",
statuses: [
{
name: "idea",
icon: "💡",
color: "#FFEB3B",
templateId: "colorful",
},
{
name: "draft",
icon: "📝",
color: "#E0E0E0",
templateId: "colorful",
},
{
name: "inProgress",
icon: "🔧",
color: "#FFC107",
templateId: "colorful",
},
{
name: "editing",
icon: "🖊️",
color: "#2196F3",
templateId: "colorful",
},
{
name: "pending",
icon: "⏳",
color: "#9C27B0",
templateId: "colorful",
},
{
name: "onHold",
icon: "⏸",
color: "#9E9E9E",
templateId: "colorful",
},
{
name: "needsUpdate",
icon: "🔄",
color: "#FF5722",
templateId: "colorful",
},
{
name: "completed",
icon: "✅",
color: "#4CAF50",
templateId: "colorful",
},
{
name: "archived",
icon: "📦",
color: "#795548",
templateId: "colorful",
},
],
},
{
id: "creative-writing",
name: "Creative Writing",
description: "Workflow for novelists and creative writers",
author: "Obsidian Community",
github: "https://github.com/obsidian-community",
statuses: [
{
name: "idea",
icon: "🧠",
color: "#FFD700",
templateId: "creative-writing",
},
{
name: "outline",
icon: "🗺️",
color: "#87CEEB",
templateId: "creative-writing",
},
{
name: "first-draft",
icon: "✍️",
color: "#FFA07A",
templateId: "creative-writing",
},
{
name: "revision",
icon: "🔍",
color: "#DA70D6",
templateId: "creative-writing",
},
{
name: "final-polish",
icon: "✨",
color: "#32CD32",
templateId: "creative-writing",
},
],
},
{
id: "minimal",
name: "Minimal workflow",
description: "A simplified set of essential workflow statuses",
author: "Obsidian Note Status",
github: "https://github.com/devonthesofa/obsidian-note-status",
statuses: [
{
name: "todo",
icon: "📌",
color: "#F44336",
templateId: "minimal",
},
{
name: "inProgress",
icon: "⚙️",
color: "#2196F3",
templateId: "minimal",
},
{
name: "review",
icon: "👀",
color: "#9C27B0",
templateId: "minimal",
},
{
name: "done",
icon: "✓",
color: "#4CAF50",
templateId: "minimal",
},
],
},
{
id: "project",
name: "Project management",
description: "Status workflow for project management and tracking",
author: "Obsidian Note Status",
github: "https://github.com/devonthesofa/obsidian-note-status",
statuses: [
{
name: "planning",
icon: "🗓️",
color: "#9E9E9E",
templateId: "project",
},
{
name: "backlog",
icon: "📋",
color: "#E0E0E0",
templateId: "project",
},
{
name: "ready",
icon: "🚦",
color: "#8BC34A",
templateId: "project",
},
{
name: "inDevelopment",
icon: "👨‍💻",
color: "#2196F3",
templateId: "project",
},
{
name: "testing",
icon: "🧪",
color: "#9C27B0",
templateId: "project",
},
{
name: "review",
icon: "👁️",
color: "#FFC107",
templateId: "project",
},
{
name: "approved",
icon: "👍",
color: "#4CAF50",
templateId: "project",
},
{
name: "live",
icon: "🚀",
color: "#3F51B5",
templateId: "project",
},
],
},
academic as StatusTemplate,
colorful as StatusTemplate,
creativeWriting as StatusTemplate,
minimal as StatusTemplate,
project as StatusTemplate,
];

View file

@ -26,7 +26,8 @@
"lib": ["DOM", "ES5", "ES6", "ES7"],
"jsx": "react-jsx",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true
},
"include": ["**/*.ts", "**/*.tsx"]
}

View file

@ -105,30 +105,3 @@ export const generateTemplateId = (
return id;
};
/**
* Generate a GitHub URL to submit a template to the marketplace
*/
export const getMarketplaceSubmissionUrl = (
template: StatusTemplate,
): string => {
const baseUrl =
"https://github.com/devonthesofa/obsidian-note-status/new/master/templates";
const filename = `${template.id.replace(/^custom-/, "")}.json`;
// Create a clean version of the template for the marketplace
const marketplaceTemplate = {
...template,
// Ensure the ID doesn't have the 'custom-' prefix for the marketplace
id: template.id.replace(/^custom-/, ""),
// Ensure statuses use the new ID
statuses: template.statuses.map((s) => ({
...s,
templateId: template.id.replace(/^custom-/, ""),
})),
};
const value = encodeURIComponent(
JSON.stringify(marketplaceTemplate, null, 2),
);
return `${baseUrl}?filename=${filename}&value=${value}`;
};