Skip to content

Commit

Permalink
build!: build logseq-memos-plugin
Browse files Browse the repository at this point in the history
BREAKING CHANGE: New Logseq Plugin.
  • Loading branch information
EINDEX committed Dec 1, 2022
1 parent 3b05ea6 commit 78a2506
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 75 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/main.yml → .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

name: Releases

env:
PLUGIN_NAME: logseq-plugin-template-react

# Controls when the action will run.
on:
# push:
# branches:
# - "master"
# Allows you to run this workflow manually from the Actions tab
push:
branches:
- "master" # Push events to matching any tag format, i.e. 1.0, 20.15.10
workflow_dispatch:


env:
PLUGIN_NAME: logseq-memos-sync

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down
7 changes: 0 additions & 7 deletions logo.svg

This file was deleted.

Binary file added logo.webp
Binary file not shown.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-plugin-template-react",
"version": "0.0.0",
"name": "logseq-memos-sync",
"version": "0.1.0",
"main": "dist/index.html",
"scripts": {
"dev": "vite",
Expand All @@ -10,6 +10,8 @@
"license": "MIT",
"dependencies": {
"@logseq/libs": "^0.0.10",
"axios": "^1.2.0",
"date-fns": "^2.29.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down Expand Up @@ -37,7 +39,7 @@
"vite-plugin-logseq": "1.1.2"
},
"logseq": {
"id": "_pengx17-logseq-template-react",
"icon": "./logo.svg"
"id": "_eindex-logseq-memos-sync",
"icon": "./logo.webp"
}
}
70 changes: 70 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 23 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
# Logseq Plugin Template React
# logseq-memos-sync

> A memos sync plugin for logseq
<a href="https://www.buymeacoffee.com/eindex"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=eindex&button_colour=40DCA5&font_colour=ffffff&font_family=Cookie&outline_colour=000000&coffee_colour=FFDD00" /></a>

## Features

- plug & play boilerplate with properly defined GitHub action defaults
- develop with HMR, empowered by lightning fast Vite ⚡ with [vite-logseq-plugin](https://github.com/pengx17/vite-plugin-logseq)
- TailwindCSS for styling
- pnpm
- Sync memos to logseq via memos openAPI

## How to use

1. Open plugin setting, setting up openAPI
2. Open command panel
3. Search for Sync Memos
4. Run it

## Limit

- now just can first 1000 memos.
- if memo exist, cannot update the content.
- can not sync content from logseq to memos.

## Thanks

- [Memos](https://github.com/usememos/memos)
87 changes: 34 additions & 53 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,41 @@
import "@logseq/libs";

import React from "react";
import * as ReactDOM from "react-dom/client";
import App from "./App";
import "./index.css";

import { logseq as PL } from "../package.json";

// @ts-expect-error
const css = (t, ...args) => String.raw(t, ...args);

const pluginId = PL.id;
import { IHookEvent } from "@logseq/libs/dist/LSPlugin";
import MemosSync from "./memos";

function main() {
console.info(`#${pluginId}: MAIN`);
const root = ReactDOM.createRoot(document.getElementById("app")!);

root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

function createModel() {
return {
show() {
logseq.showMainUI();
},
};
}

logseq.provideModel(createModel());
logseq.setMainUIInlineStyle({
zIndex: 11,
});

const openIconName = "template-plugin-open";

logseq.provideStyle(css`
.${openIconName} {
opacity: 0.55;
font-size: 20px;
margin-top: 4px;
}
.${openIconName}:hover {
opacity: 0.9;
}
`);

logseq.App.registerUIItem("toolbar", {
key: openIconName,
template: `
<div data-on-click="show" class="${openIconName}">⚙️</div>
`,
});
console.log("Logseq Memos Plugin Loading!")
logseq.useSettingsSchema([{
key: "openAPI",
type: "string",
title: "Open API",
description: "Memos Open API, you can find this in memos setting",
default: "",
},{
key: "includeArchive",
type: "boolean",
title: "Include archive",
description: "Also sync archive memos",
default: false,
},{
key: "mode",
type: "enum",
title: "Mode",
description: "Mode to Sync Memos",
default: "Custom Page",
enumChoices: ["Journal", "Custom Page"],
enumPicker: "select"
},{
key: "customPage",
type: "string",
title: "Custom Page",
description: "When you using `Custom Page` mode. You can choose a page to store Sync Memos",
default: "Memos",
}])

logseq.App.registerCommandPalette({key: "sync-memos", label: "Sync Memos"} , async (e: IHookEvent) => {
(new MemosSync()).syncMemos()
})
}

logseq.ready(main).catch(console.error);
Loading

0 comments on commit 78a2506

Please sign in to comment.