mirror of
https://gitlab.com/octtspacc/sitoctt
synced 2025-06-05 22:09:20 +02:00
Init con Hugo, conversione ListedDownsync.js, fix metadati post
This commit is contained in:
@ -87,12 +87,14 @@ const GetLinkElem = Dom => {
|
||||
const MakeMetaStr = Post => {
|
||||
let Str = '';
|
||||
['Meta', 'Macros'].forEach((Type) => {
|
||||
const Marks = { Meta: "%", Macros: "$", };
|
||||
const Marks = { Meta: "%", Macros: "$" };
|
||||
Object.keys(Post[Type]).forEach((Key) => {
|
||||
Str += `// ${Marks[Type]} ${Key} = ${Post[Type][Key]}\n`;
|
||||
//Str += `// ${Marks[Type]} ${Key} = ${Post[Type][Key]}\n`;
|
||||
// TODO: should this properly handle non-strings?
|
||||
Str += `${Key} = ${JSON.stringify(Post[Type][Key])}\n`;
|
||||
});
|
||||
});
|
||||
return Str;
|
||||
return `+++\n${Str}+++\n`; //Str;
|
||||
};
|
||||
|
||||
const HandlePost = (PostSrc, Output) => {
|
||||
@ -109,9 +111,10 @@ const HandlePost = (PostSrc, Output) => {
|
||||
// Handle .MetadataBlock elements
|
||||
Array.from(ContentDom.querySelectorAll(MetadataBlockSelect)).forEach((Elem) => {
|
||||
if (Elem.textContent) {
|
||||
const Meta = ParseMeta(Elem.textContent);
|
||||
const Meta = ParseMeta(Post.RawMeta = Elem.textContent);
|
||||
Post.Meta = Object.assign(Post.Meta, Meta.Meta);
|
||||
Post.Macros = Object.assign(Post.Macros, Meta.Macros);
|
||||
Post.IsToml = Meta.IsToml;
|
||||
};
|
||||
Elem.outerHTML = '';
|
||||
});
|
||||
@ -150,7 +153,7 @@ const HandlePost = (PostSrc, Output) => {
|
||||
Post.Content = GetFragHTML(ContentDom);
|
||||
|
||||
const PathFile = LinkPath.split('/').slice(-1)[0];
|
||||
const PathDir = LinkPath.split('/').slice(0, (LinkPath.split('/').length - 1)).join('/');
|
||||
const PathDir = ('./content/' + LinkPath.split('/').slice(0, (LinkPath.split('/').length - 1)).join('/'));
|
||||
const DatePrefix = PostsFileDate ? Post.Meta.CreatedOn + '-' : '';
|
||||
const FinalFilePath = `${PathDir}/${DatePrefix}${PathFile.substring(0, (PathFile.length - 4))}md`;
|
||||
if (!CheckDownsync(TryReadFileSync(FinalFilePath))) {
|
||||
@ -197,8 +200,8 @@ const HandlePost = (PostSrc, Output) => {
|
||||
if (Output == 'file') {
|
||||
TryMkdirSync(PathDir);
|
||||
Fs.writeFileSync(FinalFilePath, `\
|
||||
<!-- < Autogenerated by ListedDownsync.js. Do not edit (unless also set "% Downsync = False") - it would be overwritten. > -->
|
||||
${MakeMetaStr(Post)}
|
||||
${/* Post.IsToml ? Post.RawMeta : */ MakeMetaStr(Post)}
|
||||
<!-- Autogenerated by ListedDownsync.js. Do not edit (unless also set "% Downsync = False") - it would be overwritten. -->
|
||||
<h1>${Post.Meta.HTMLTitle ? Post.Meta.HTMLTitle : Post.Meta.Title}</h1>
|
||||
|
||||
${Post.Content}
|
||||
|
Reference in New Issue
Block a user