-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
225 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ resources/_gen | |
.hugo_build.lock | ||
.vscode | ||
.DS_Store | ||
|
||
# Local Netlify folder | ||
.netlify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,4 +98,4 @@ <h1>{{ with $st.Title }}{{ . | markdownify | emojify }}{{ end }}</h1> | |
|
||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{ $_hugo_config := `{ "version": 1 }` }} | ||
<div class="expand"> | ||
<div class="expand-label" style="cursor: pointer;" onclick="$h = $(this);$h.next('div').slideToggle(100,function () {$h.children('i').attr('class',function () {return $h.next('div').is(':visible') ? 'fas fa-chevron-down' : 'fas fa-chevron-right';});});"> | ||
<i style="font-size:x-small;" class="fas fa-chevron-right"></i> | ||
<span> | ||
{{$expandMessage := T "Expand-title"}} | ||
{{ if .IsNamedParams }} | ||
{{.Get "default" | default $expandMessage}} | ||
{{else}} | ||
{{.Get 0 | default $expandMessage}} | ||
{{end}} | ||
</span> | ||
</div> | ||
<div class="expand-content" style="display: none;"> | ||
{{.Inner | safeHTML}} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const getFolderName = (rootfolder) => { | ||
const configPath = path.join( | ||
rootfolder, | ||
"exampleSite/config/_default/hugo.toml" | ||
); | ||
const getConfig = fs.readFileSync(configPath, "utf8"); | ||
const match = getConfig.match(/theme\s*=\s*\[?"([^"\]]+)"\]?/); | ||
let selectedTheme = null; | ||
if (match && match[1]) { | ||
selectedTheme = match[1]; | ||
} | ||
return selectedTheme; | ||
}; | ||
|
||
const deleteFolder = (folderPath) => { | ||
if (fs.existsSync(folderPath)) { | ||
fs.rmSync(folderPath, { recursive: true, force: true }); | ||
} | ||
}; | ||
|
||
const createNewfolder = (rootfolder, folderName) => { | ||
const newFolder = path.join(rootfolder, folderName); | ||
fs.mkdirSync(newFolder, { recursive: true }); | ||
return newFolder; | ||
}; | ||
|
||
const iterateFilesAndFolders = (rootFolder, { destinationRoot }) => { | ||
const directory = path.join(rootFolder); | ||
const items = fs.readdirSync(directory, { withFileTypes: true }); | ||
items.forEach((item) => { | ||
if (item.isDirectory()) { | ||
createNewfolder(destinationRoot, item.name); | ||
iterateFilesAndFolders(path.join(directory, item.name), { | ||
currentFolder: item.name, | ||
destinationRoot: path.join(destinationRoot, item.name), | ||
}); | ||
} else { | ||
const sourceFile = path.join(directory, item.name); | ||
const destinationFile = path.join(destinationRoot, item.name); | ||
fs.renameSync(sourceFile, destinationFile); | ||
} | ||
}); | ||
}; | ||
|
||
const setupProject = () => { | ||
const rootfolder = path.join(__dirname, "../"); | ||
if (!fs.existsSync(path.join(rootfolder, "themes"))) { | ||
const folderList = ["layouts", "assets", "static"]; | ||
const folderName = getFolderName(rootfolder); | ||
const newfolderName = createNewfolder( | ||
path.join(rootfolder, "themes"), | ||
folderName | ||
); | ||
|
||
folderList.forEach((folder) => { | ||
const source = path.join(rootfolder, folder); | ||
const destination = path.join(newfolderName, folder); | ||
if (fs.existsSync(source)) { | ||
fs.mkdirSync(destination, { recursive: true }); | ||
iterateFilesAndFolders(source, { | ||
currentFolder: folder, | ||
destinationRoot: destination, | ||
}); | ||
deleteFolder(source); | ||
} | ||
}); | ||
|
||
const exampleSite = path.join(rootfolder, "exampleSite"); | ||
iterateFilesAndFolders(exampleSite, { destinationRoot: rootfolder }); | ||
deleteFolder(exampleSite); | ||
} | ||
}; | ||
|
||
setupProject(); |
Oops, something went wrong.