Skip to content

Commit

Permalink
v0.0.1 - drummer blog publishing correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
scottrblock committed Apr 30, 2022
1 parent 3a8acad commit e5c0ceb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions logseq-opml-drummer/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const addBlogPostOutlineToOutline = (
export const replace = (object, source, target, blogDate): [any, Date] => {
// grab the content and children (source key) from the object
// but only the children if the length is greater than 0
let newObject = (({ content }) => ({ content }))(object);
let newObject = (({ content }) => ({ text: content }))(object);
if (Array.isArray(object[source]) && object[source].length > 0) {
newObject[source] = object[source];
}
Expand All @@ -166,16 +166,21 @@ export const replace = (object, source, target, blogDate): [any, Date] => {
let newV = v;
let newDateToBump = new Date();

if (v && Array.isArray(v)) {
[[newV, newDateToBump]] = v.map((item) => {
if (v && Array.isArray(v) && v.length > 0) {
const valuesAndDates = v.map((item) => {
return replace(item, source, target, bumpedDate);
});

newV = valuesAndDates.map(([item, _]) => item);
newDateToBump = valuesAndDates.map(([_, date]) => date)[
valuesAndDates.length - 1
];
} else if (
v &&
typeof v === "object" &&
Object.keys(v).includes(source)
) {
[newV, newDateToBump] = replace(v, source, target, bumpedDate);
return replace(v, source, target, bumpedDate);
}

return {
Expand Down
1 change: 1 addition & 0 deletions logseq-opml-drummer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ function main(baseInfo: LSPluginBaseInfo) {
if (opmlResponseErr.message !== "") {
console.log("opmlResponse.err.message == " + opmlResponseErr.message);
} else {
// TODO unclear if `blog.opml` is supposed to be hard coded, but I think it is
const params = {
relpath: "blog.opml",
type: "text/xml",
Expand Down

0 comments on commit e5c0ceb

Please sign in to comment.