• Townie
    AI
  • Blog
  • Docs
  • Pricing
Log inSign up
arfan

arfan

remark-frontmatter-starter

Remix of jxnblk/remark-frontmatter-starter
Unlisted
Like
1
remark-frontmatter-starter
Home
Code
8
docs
10
src
1
styles
7
svgs
tmp
3
utils
H
App.tsx
README.md
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
tmp
/
plan.md
Code
/
tmp
/
plan.md
Search
4/17/2025
Viewing readonly version of main branch: v532
View latest version
plan.md

Refactor Plan for remark-frontmatter-starter

This plan addresses refactoring, cleanup, organization, and key design principles (KISS, YAGNI, SoC, SRP, DRY) with beginner‑friendly names. Each step includes updating App.tsx for testing and pushing to Val Town.

Step 1: Create Directory Structure and Basic Types

  • 1.1 Create src directory if it doesn't exist
  • 1.2 Create src/builders directory
  • 1.3 Remove empty folders (src/client, src/server) - Note: Created remove_empty_dirs.sh script, needs to be executed manually
  • 1.4 Create src/types.ts with basic shared type definitions
    • Doc interface
    • Config interface
    • Heading interface
  • 1.5 Update App.tsx to import types (minimal change)
  • 1.6 Run vt push to test basic structure - Note: Needs to be executed manually

Step 2: Create Utility Functions

  • 2.1 Create src/utils.ts with helper functions
    • loadDoc function
    • DocTreeNode interface
    • NestedGroupedDocs interface
    • Simple groupByFolder function (renamed from groupDocsByFolder)
  • 2.2 Update App.tsx to use the new utils.ts
  • 2.3 Run vt push to test utility functions - Note: Fixed duplicate import and variable declaration issues. Also fixed document path handling in loadDoc function.

Step 3: Create Plugin System

  • 3.1 Create src/plugins.ts with remark/rehype plugins
    • remarkCallout plugin with fixed regex pattern
    • rehypeCallout plugin
  • 3.2 Update App.tsx to use the new plugins.ts
  • 3.3 Run vt push to test plugins

Step 4: Create Unified Parser

  • 4.1 Create src/parser.ts with unified parser setup
    • Import and configure remark plugins
    • Import and configure rehype plugins
    • Remove remarkLint (move to dev chain)
  • 4.2 Update App.tsx to use the new parser.ts
  • 4.3 Run vt push to test parser

Step 5: Create Configuration

  • 5.1 Create src/config.ts
    • Define config object with all settings
    • Create helper to resolve all stylesheet paths once
    • Define docs array with document list
  • 5.2 Remove any existing config files or duplicate configuration code
  • 5.3 Update App.tsx to use the new config.ts
  • 5.4 Run vt push to test configuration

Step 6: Create Navigation Builder

  • 6.1 Create src/builders/navigation.ts
    • buildNav function (renamed from docLinksHtml)
    • buildSidebar function (renamed from sidebarHtml)
  • 6.2 Remove navigation-related functions from App.tsx
  • 6.3 Update App.tsx to use the new navigation.ts
  • 6.4 Run vt push to test navigation

Step 7: Create Head Builder

  • 7.1 Create src/builders/head.ts
    • buildHead function
  • 7.2 Remove head-related functions from App.tsx
  • 7.3 Update App.tsx to use the new head.ts
  • 7.4 Run vt push to test head builder

Step 8: Create Scripts Builder

  • 8.1 Create src/builders/scripts.ts
    • buildScripts function
  • 8.2 Remove scripts-related functions from App.tsx
  • 8.3 Update App.tsx to use the new scripts.ts
  • 8.4 Run vt push to test scripts builder

Step 9: Create Request Handlers

  • 9.1 Enhance utils.ts with buildToc function
  • 9.2 Create src/handlers.ts
    • renderDoc function (renamed from processDocument)
    • appHandler function (renamed from handleRequest)
  • 9.3 Remove handler-related functions from App.tsx
  • 9.4 Update App.tsx to use the new handlers.ts
  • 9.5 Run vt push to test handlers

Step 10: Final Simplification

  • 10.1 Simplify App.tsx to be a thin wrapper
    • Import appHandler from src/handlers.ts
    • Export appHandler as default
    • Remove ALL remaining implementation code from App.tsx
  • 10.2 Run vt push to test final implementation
  • 10.3 Verify all functionality works as expected

File Removal Checklist

  • Ensure old utility functions are removed from App.tsx as they're moved to utils.ts
  • Ensure old plugin definitions are removed from App.tsx as they're moved to plugins.ts
  • Ensure old parser setup is removed from App.tsx as it's moved to parser.ts
  • Ensure old configuration is removed as it's moved to config.ts
  • Ensure old navigation functions are removed as they're moved to navigation.ts
  • Ensure old head-building functions are removed as they're moved to head.ts
  • Ensure old script-building functions are removed as they're moved to scripts.ts
  • Ensure old handler functions are removed as they're moved to handlers.ts
  • Verify no duplicate code exists between App.tsx and the new module files

Testing Notes

  • After each vt push, verify the app still works correctly
  • If issues are found, fix them before moving to the next step
  • Keep a backup of the working version before each major change
  • Check browser console for any errors during testing
  • When removing code from App.tsx, ensure it's properly moved to the new files first
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareersBrandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.