Skip to content

Commit

Permalink
#2333 Add layouts folder for templates (#2334)
Browse files Browse the repository at this point in the history
* #2333 Improve templates structure and add global settings

* revert global settings changes

* revert globalSettings changes
  • Loading branch information
TheHadiAhmadi authored Dec 13, 2024
1 parent 02bb4fb commit c6796c0
Show file tree
Hide file tree
Showing 50 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Backend/FluentCMS.Services/ServiceConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ public static class ServiceConstants
public const string SetupTemplatesFolder = "Templates";
public const string SetupFilesFolder = "Files";
public const string SetupPagesFolder = "Pages";
public const string SetupBlocksFolder = "Blocks";
public const string SetupLayoutsFolder = "Layouts";
public const string SetupManifestFile = "manifest.json";
public const string SetupSiteTemplateFile = "site.json";
public const string DefaultTemplateFolder = "Templates/Default";
Expand Down
6 changes: 3 additions & 3 deletions src/Backend/FluentCMS.Services/SiteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public async Task<Site> Create(SiteTemplate siteTemplate, CancellationToken canc
// loading layout data from files
foreach (var layout in siteTemplate.Layouts)
{
var bodyLayoutFilePath = Path.Combine(ServiceConstants.SetupTemplatesFolder, siteTemplate.Template, $"{layout.Name}.body.html");
var headLayoutFilePath = Path.Combine(ServiceConstants.SetupTemplatesFolder, siteTemplate.Template, $"{layout.Name}.head.html");
var bodyLayoutFilePath = Path.Combine(ServiceConstants.SetupTemplatesFolder, siteTemplate.Template, ServiceConstants.SetupLayoutsFolder, $"{layout.Name}.body.html");
var headLayoutFilePath = Path.Combine(ServiceConstants.SetupTemplatesFolder, siteTemplate.Template, ServiceConstants.SetupLayoutsFolder, $"{layout.Name}.head.html");
layout.Body = await System.IO.File.ReadAllTextAsync(bodyLayoutFilePath, cancellationToken);
layout.Head = await System.IO.File.ReadAllTextAsync(headLayoutFilePath, cancellationToken);
}

foreach (var block in siteTemplate.Blocks)
{
var blockContentFilePath = Path.Combine(ServiceConstants.SetupTemplatesFolder, siteTemplate.Template, "Blocks", block.Category, $"{block.Name}.html");
var blockContentFilePath = Path.Combine(ServiceConstants.SetupTemplatesFolder, siteTemplate.Template, ServiceConstants.SetupBlocksFolder, block.Category, $"{block.Name}.html");
block.Content = await System.IO.File.ReadAllTextAsync(blockContentFilePath, cancellationToken);
}

Expand Down

0 comments on commit c6796c0

Please sign in to comment.