package models

import (
	"encoding/json"
	"os"
)

const (
	ConfigPath = "config.json"
)

type Config struct {
	PostsDir     string
	AssetsDir    string
	TemplatesDir string
	TemplatesExt string
	LocalIP      string
	LocalPort    string
	ServerIP     string
	ServerPort   string
	ServerDomain string
	Port         string
}

func loadConfig(configPath string) (*Config, error) {
	cfg := &Config{}
	configFile, err := os.ReadFile(configPath)
	if err != nil {
		return nil, err
	}
	err = json.Unmarshal(configFile, cfg)
	if err != nil {
		return nil, err
	}
	return cfg, nil
}
