cssitegen/ProjectSettings/ProjectSettings.cs
Robert Morrison af1e340816
feat: Add SiteName replacer
Now the string `%SITENAME%` can be replaced with a value stored in the
`cssitegen.json` file of a project.
2024-06-03 03:22:41 +01:00

50 lines
1.4 KiB
C#

using System.Text.Json.Serialization;
// project settings is a user accessible config to set the Source and destination of a site
// This may include more scope in the future such as holding the site base address etc..
public class ProjectSettings
{
// The Source and Destination need to be public for the json constructor to work properly.
private DirectoryInfo? _ProjectRoot;
public string Source {get; private set;}
public string Destination {get; private set;}
public string? BaseUrl {get; private set;}
public string? SiteName {get; private set;}
public DirectoryInfo InputDirectory {get {
if (_ProjectRoot is null)
{
return new(Source);
}
return new(Path.Combine(_ProjectRoot.FullName,Source));
}}
public DirectoryInfo OutputDirectory {get {
if (_ProjectRoot is null)
{
return new(Destination);
}
return new(Path.Combine(_ProjectRoot.FullName,Destination));
}}
[JsonConstructor]
public ProjectSettings(string source, string destination, string baseUrl, string siteName) {
Source = source;
Destination = destination;
BaseUrl = baseUrl;
SiteName = siteName;
}
public void setProjectRoot(string projectRoot) {
_ProjectRoot = new(projectRoot);
}
public void setProjectRoot(DirectoryInfo projectRoot) {
_ProjectRoot = projectRoot;
}
/*
* public void setBaseUrl(string baseUrl) {
* BaseUrl = baseUrl;
* }
*/
}