GithubHelp home page GithubHelp logo

sawhney17 / logseq-schrodinger Goto Github PK

View Code? Open in Web Editor NEW
322.0 5.0 38.0 699 KB

A plugin to export pages in Logseq to Hugo.

License: MIT License

HTML 1.17% TypeScript 90.72% CSS 7.29% JavaScript 0.82%
logseq hugo

logseq-schrodinger's Introduction

Contributors Forks Stargazers Issues MIT License


Logo

logseq Schrödinger

An awesome Logseq plugin to jumpstart your digital garden 🌱!
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Installation
  3. Configuration
  4. Issues
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Product Name Screen Shot

Logseq is a great PKM (personal knowledge management) tool, but keeping your knowledge for yourself only gets you so far. As Erwin Schrödinger stated:

If a note is not published, does it really exist? — Erwin Schrödinger

Knowledge is meant to be treasured and expanded, but before all shared. This plugin helps to make that possible, or at least easier.

Note: This project is very much a work-in-progress. Please report issues and questions.

(back to top)

Installation

Preparation

  • Click the 3 dots in the righthand corner and go to Settings.
  • Go to Advanced and enable Plug-in system.
  • Restart the application.
  • Click 3 dots and go to Plugins (or Esc t p).

Install plugin from the Marketplace (recommended)

  • Click the Marketplace button and then click Plugins.
  • Find the plugin and click Install.

Install plugin manually

  • Download a released version assets from Github.
  • Unzip it.
  • Click Load unpacked plugin, and select destination directory to the unzipped folder.

(back to top)

Configuration

  • Click the 3 dots in the righthand corner and go to Settings.
  • Go to Plugin Settings.
  • Select correct plugin.

Configuration screen

(back to top)

Meta-data

This plugin uses YAML for the Hugo front-matter. It will convert Logseq page-properties to Hugo front matter.

Logseq keywords are lowercase converted to Hugo keywords, and category in Logseq is translated to categories for use with Hugo. Logseq links ([[like_this]]) are stripped of [[ and ]].

All other keywords are just converted to Hugo keywords.

For now you must add date with the posts date in the form of "2012-04-06" to your Logseq page-properties.

date:: 2012-04-06

Configuring Hugo

Hugo does not by default support backlinks. Use a snippet like the following to simulate backlinks. It will parse every page for local links. This snippet should be placed in ~yourhugo/layouts/partials/backlinks.html.

{{ $re := $.File.BaseFileName }} {{ $backlinks := slice }} {{ range where
.Site.RegularPages "Type" "page" }} {{ if and (findRE $re .RawContent) (not (eq
$re .File.BaseFileName)) }} {{ $backlinks = $backlinks | append . }} {{ end }}
{{ end }} {{ if gt (len $backlinks) 0 }}
<aside>
  <h3>Backlinks</h3>
  <div class="backlinks">
    <ul>
      {{ range $backlinks }}
      <li class="capitalize"><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
      {{ end }}
    </ul>
  </div>
</aside>
{{ else }}
<aside>
  <h4>No notes link to this note</h4>
</aside>
{{ end }}

<aside class="related">
  {{ $related := .Site.RegularPages.Related . | complement $backlinks | first 3
  -}} {{ with $related -}}
  <h3>slightly related</h3>
  <ul>
    {{ range . -}}
    <li class="capitalize"><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
    {{ end -}}
  </ul>
  {{ end -}}
</aside>

Admonitions

Logseq has several built-in adminitions, namely:

  • caution
  • example
  • important
  • note
  • pinned
  • tip
  • quote
  • warning

These get converted to:

{{< logseq/orgCAUTION >}}Caution here{{< / logseq/orgCAUTION >}}
{{< logseq/orgEXAMPLE >}}This is an example{{< / logseq/orgEXAMPLE >}}
{{< logseq/orgIMPORTANT >}}This is important{{< / logseq/orgIMPORTANT >}}
{{< logseq/orgNOTE >}}This is a note{{< / logseq/orgNOTE >}}
{{< logseq/orgPINNED >}}This is pinned{{< / logseq/orgPINNED >}}
{{< logseq/orgTIP >}}This is a tip{{< / logseq/orgTIP >}}
{{< logseq/orgQUOTE >}}This is a quote{{< / logseq/orgQUOTE >}}
{{< logseq/orgWARNING >}}This is a warning{{< / logseq/orgWARNING >}}

So Hugo needs those in ~yourhugo/layouts/shortcodes/logseq/:

orgCAUTION.html
orgEXAMPLE.html
orgIMPORTANT.html
orgNOTE.html
orgPINNED.html
orgQUOTE.html
orgTIP.html
orgWARNING.html

And they should contain something along the lines of:

<div class="caution {{ .Get 0 }}">{{ .Inner | $.Page.RenderString }}</div>

(back to top)

Website templates

There are some basic website templates you can take it as a reference.

  1. logseq-hugo-template, by sawhney17.
    1. You can host your personal website with your favorite web hosting providers.
  2. Logseq-Hugo-Template, by CharlesChiuGit.
    1. Host your personal website with free GitHub pages.

(back to top)

Issues

See the open issues for a full list of proposed features (and known issues).

What works

  • Local Hugo links (but Logseq uses one folder for everything, so Hugo does too)
  • Block refs(!) — On conversion the block is pulled from the other location
  • Images
  • Basic Markdown styling (including highlighting!)

What is known to not work

  • Indentation Logseq ➡ Hugo is still a work-in-progress

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Aryan Sawhney - @Aryan Sawhney

Project Link: https://github.com/sawhney17/logseq-schrodinger

(back to top)

Acknowledgments

I would like to thank Alex Qwxlea (@twitter_handle) for the idea to write this Logseq plugin. Also for breaking the plugin after I wrote it. And finally, thank him for adding this note: Qwxlea, you're the best 😁!

logseq-schrodinger's People

Contributors

charleschiugit avatar dom8509 avatar gaga5lala avatar kshitij-banerjee avatar qwxlea avatar sawhney17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

logseq-schrodinger's Issues

Is there block level publishing support?

Hi! I tried with "logseq-schrodinger version 1.3.0" first time today the "hugo-single-export" on a page today. I got a nice output. Pretty cool! Thanks!

For logseq, I like the "write everything in Journal/Daily view, referring to specific nodes as you go"

and currently I manually select the block I want to publish in a "YYY_MM_DD.md" and manually put that into my hugo content/en/post/YYY-MM-DD-stuff.md . I am getting tired just writing that sentence 😅 .

With your plugin I tried to select just a block

and "hugo-single-export" and in the sidebar I get Uncaught (in promise) Error: Expected string, got: nil ,

Screen Shot 2023-02-18 at 1 01 55 PM

From what I see "Line 151, Column 57" of "helpers.js" refers to the global.document of the line 151,

var injectionPoint = global.document.head || global.document.body;

so I am guessing in logseq, for a block global.document is not a thing?

I also tried embedding

So I created a new evergreen note, and I added

{{embed ((63f10b5d-f204-4ce6-8e4d-52f975e644fe))}}

in there, and when I ran "hugo-single-export", here the embedded part, only included the text from the parent block being embedded but not from the children.

Maybe the block publish is not common?

My first basic question is whether the publishing of blocks is supported and maybe I'm doing this wrong.
And second I am wondering what are your thoughts on how common this publishing style is and whether you think the idea belongs in "logseq-schrodinger" in some future future iteration or whether maybe it is not worth it?

-Michal

Feature Add - Superscripts

Just adding this as I noticed it wasn't working in my instance, but it appears that the Superscript formatting isn't working when I export it to my Hugo instance.

For context, ^{superscript} should create a superscript of whatever's inside of the brackets, which should just be <sup>superscript</sup>.

Feature request: export page bundles with images for single page export

Hi! Thanks for the great plugin, I have been looking for something like this for a long time.

I think it will be good if there could be an option to export a singe page as page bundle i.e. the markdown file and the image that used in the the page packaged together, just as the "export public pages" do.

Logseq itself just put all assets in a single folder without organized file names, so it would be difficult to sort images out when one just want to export single pages.

Remote image display issue & Filtering extra image formatting text

In Logseq:
image

Exported md:

Illustration of Logseq's implemented task states:

- [Discoed Link](https://discord.com/channels/725182569297215569/725182570131751005/952564162792402976)

![logseq_implemented_task_states](https://raw.githubusercontent.com/charleschiu2012/image-hosting/main/img/logseq_implemented_task_states.png){:height 290, :width 1216}

---

In Hugo:
image

Shortcut/Hotkey and Default Location for Graph Export (Feature Request)

Hi,

Thanks for making this great plugin. I spent a weekend and was able to create a working workflow to publish my blog from logseq. Thanks again.

However, I hope you are also able to provide a Shortcut/Hotkey setting and default location where the file zip file can be saved. This will further help automate the workflow.

Thanks!
Ravi

Does not respect `:publishing/all-pages-public? true` setting

I've been trying to get this set up, and every time I try to export the pages to Hugo nothing was happening.

I have the :publishing/all-pages-public? true setting configured in Logseq.

I tried setting one single page to public:: true, and then export, and finally got the destination dialog.

In my case, all pages in Logseq should be presumed public unless explicitly specified public:: false, since I'm using it as a topic-specific blogging tool, and I'd prefer not to have to remember to set all pages to public:: true, especially since I hierarchically nest pages in some cases, using the upper nodes of the hierarchy just as aggregation points. Eg:

  • [[Mr Color/GX 3 Red]]
  • [[Mr Color/Surfacer/500]]
  • [[Mr Color/Surfacer/1000 Mahogany]]

In these cases, [[Mr Color]] and [[Mr Color/Surfacer]] don't need full pages of their own--they're useful primarily as catalogs of their child pages. I do this a lot (also for dates), so having to go through and edit each of these upper nodes would be tedious.

DNP?

This is incredible. Does it support export of daily notes pages as well?

Where is the demo?

Hi, I would really love to see a demo of this project, however, If you click the "view demo" link, it doesn't really take you to a demo site, it only loops you back to the same github repo page.

Linked images do not render with bullet point, breaks bullet point formatting

I have the following logseq entry
Screenshot 2023-10-03 at 13 05 59

When exporting with bullet points I get this

  + ## Progress

    + ### 2023-10-02

      + Disassembled TronXY S5 3d printer and scavenged parts

![IMG_20231002_221639851.jpg](/assets/img_20231002_221639851_1696332184660_0.jpg)

The loss of + next to the ! is causing all other bullets to fail to render correctly in Hugo. Manually adding it fixes the issue.

Exploring the possibility of creating a Github action

The process of exporting manually to Hugo pages seems a bit painful, and I was wondering if we can figure out a way to automate this. Broadly speaking, a setup that I could see working would be:

  1. Add your Logseq graph as a submodule to your Hugo website
  2. On push to the graph, run a Github action to generate Hugo files using Logseq Schrodinger's logic
  3. Deploy to GH pages.

Before I go ahead and explore something like this, I was wondering if there's something more obvious that I'm missing? I'd be interested to hear your thoughts in general about this approach.

Twitter embeds

Hello!

Would it be possible to make tweet embeds work like the YouTube video embeds?

Also, related: For the YouTube embeds, I see in the code that it is prompted by {{youtube insertidhere}}, but the embed in Logseq defaults to {{video insertidhere}}. Would you be able to change it so either works?

Thanks!

Option to filter out tasks

Having tasks on a page is useful, but might not be nice for export. Add a global option to filter out all tasks (if block/marker is present then drop the block during export).

Option to customize export folder

Currently all exported markdown is placed into the “pages” folder. Although it works fine this way, it would be nice to have a setting to allow us to choose the destination folder. For example, I’d like to place the exported markdown in a folder called “notes”.

Generate page hierarchies

As noted in #29, I make use of Logseq's built-in hierarchy functionality, where creating a page like [[Mr Color/GX/3 Red]] creates a new page nested underneath parent pages. In this case, [[Mr Color]], [[Mr Color/GX]], and finally [[Mr Color/GX/3 Red]]. If the parent pages do not exist,they are added to the graph automatically, analogous to mkdir -p mr-color/gx/3-red.

Additionally, the generated pages are aware of their hierarchies:

  • parents know about their children, and list them
  • children know their path, and list it

Parent:

Screen Shot 2022-11-05 at 4 40 16 PM

(Grand) child:

Screen Shot 2022-11-05 at 4 40 31 PM

Schrodinger already creates these pages, but they lose awareness of their hierarchy links. It would be useful for these to be surfaceable in a published site link backlinks. Unfortunately, because they are not links present in the content, they do not get generated, and would require new work to do so.

Could these be added to page front matter? Maybe

# Mr Color
hierarchy:
  - {{ ref . "pages/mr-color/gx" }}
  - {{ ref . "pages/mr-color/gx/3-red" }}
  - {{ ref . "pages/mr-color/gx/1-white" }}
  - {{ ref . "pages/mr-color/surfacer" }}
  - {{ ref . "pages/mr-color/surfacer/500" }}

# Mr Color/GX
hierarchy:
  - {{ ref . "pages/mr-color/gx/3-red" }}
  - {{ ref . "pages/mr-color/gx/1-white" }}

# Mr Color/GX/1 White
hierarchy:
  - {{ ref . "pages/mr-color/gx" }}

some User usage issues

hello, Sawhney17,

Thank u for this plugin which helps me public my logseq notes to hugo conveniently.

I encountered several software usage problems,about export of single note instead of batch notes——Single note export property value recognition is missing.

For example:

I make a note in logseq with all property and value

I make a note with property in logseq like this:

if I export of single note,something is wrong

1) I export of single note without information

2)the file form is incorrect and the file name is blank

3)the property value is missing

but export of batch notes,it will work well

1)right file form and name the file with note title

2)the property and the value are right and work well

the property “slug” instead of “fileName”, and make “lastMod” as the date when export the note

so whether I can set the export of single note as export of batch notes?

Thank u!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.