Skip to content

Commit

Permalink
feat: add example project (#8)
Browse files Browse the repository at this point in the history
This commit adds an /example/ folder that contains a logseq graph and its export in the form of Hugo page
  • Loading branch information
viktomas authored Aug 4, 2023
1 parent 03e5782 commit 6db04a9
Show file tree
Hide file tree
Showing 22 changed files with 674 additions and 3 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/hugo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Hugo example to Pages

on:
# Runs on pushes targeting the default branch
push:
branches:
- main
- example

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

# Default to bash
defaults:
run:
shell: bash

jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.116.1
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout
uses: actions/checkout@v3
# with:
# submodules: recursive
# fetch-depth: 0
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
# - name: Install Node.js dependencies
# run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
cd example/logseq-export-example
hugo mod get -u
hugo \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./example/logseq-export-example/public

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
logseq-export
export-*
test/test-output
example/logseq-export-example/public
37 changes: 34 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL = /bin/bash
.SILENT: # comment this one out if you need to debug the Makefile
APP=logseq-export

.PHONY: build
Expand All @@ -9,10 +11,39 @@ build:
test:
go test ./...

.PHONY: watch
watch:
fswatch --exclude 'test/test-output' -o ./ | xargs -n1 -I{} go test ./...
.PHONY: watch-test
watch-test:
fswatch \
--exclude '.git' \
--exclude 'logseq-export$$' \
--exclude 'test/test-output' \
--exclude 'example/' \
-o . | \
xargs -n1 -I{} go test ./...

.PHONY: clean
clean:
go clean

.PHONY: example
example:
$(MAKE) build
tmp_export_folder=$$(mktemp -d); \
./logseq-export \
--logseqFolder "$(CURDIR)/example/logseq-graph" \
--outputFolder "$$tmp_export_folder"; \
./import_to_hugo.sh "$$tmp_export_folder" "$(CURDIR)/example/logseq-export-example"

.PHONY: watch-example
watch-example:
fswatch \
--exclude '.git' \
--exclude 'logseq-export$$' \
--exclude 'test/test-output' \
--exclude 'example/logseq-export-example/content/graph' \
--exclude 'example/logseq-export-example/static/assets/graph' \
-xn . | \
while read file event; do \
echo "File $$file has changed, Event: $$event"; \
$(MAKE) example; \
done
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Tool to export raw [Logseq](https://github.com/logseq/logseq) Markdown pages (wi
- Takes Logseq page properties (`title:: Hello world`) and turns them into [Front Matter properties](https://gohugo.io/content-management/front-matter/) `title: Hello World`.
- Changes the Markdown syntax to remove the top-level bullet points.

See an **example of a deployed graph** on [viktomas.github.io/logseq-export](https://viktomas.github.io/logseq-export/). The graph and the [Hugo](https://gohugo.io/) project can be found in the [example](/example/) folder. Run the example locally with ``

**Note: I completely reworked `logseq-export` to be a bit more versatile and universal. See the [version `v0.0.3`](https://github.com/viktomas/logseq-export/tree/v0.0.3) if you are not ready to move on.**

## Install
Expand Down Expand Up @@ -113,3 +115,13 @@ have

Multi-line strings
~~~

## Local development

- Have golang installed
- Use unix or WSL2 on Windows
- `make build` - builds the binary
- `make test` - tests the project
- `make watch-test` - (only on macOS) - run test on every file change
- `make example` - export the example Logseq graph into the example Hugo site
- `make watch-example` (only on macOS) - run `make example` on any file change
Empty file.
6 changes: 6 additions & 0 deletions example/logseq-export-example/archetypes/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
---

16 changes: 16 additions & 0 deletions example/logseq-export-example/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
languageCode: 'en-us'
title: 'Logseq-Export example site'
menu:
main:
- name: "<u>H</u>ome"
url: /
weight: 1
module:
imports:
- path: github.com/barklan/hugo-dead-simple
# Even though this setting is deprecated, I have to put it in here because GitHub pages
# prepend the project name (/logseq-export/) to the whole site and the relative links
# in the graph Markdown files are pointing to /graph/page instead of /logseq-export/graph/page
# this setting prepends the `baseURL` to each of the links
canonifyURLs: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
date: 2022-09-25
public: true
slug: test-page
title: "Test page"
---

This is an example paragraph

- Second level means bullet points
- `logseq-export` also supports multi-level bullet points

```ts
const v = "Hello world"
```

You can
also
have

Multi-line strings
21 changes: 21 additions & 0 deletions example/logseq-export-example/content/graph/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
public: true
slug: _index
title: "Index"
---

## Welcome

Welcome to this example page.

This site is generated from a [Logseq](https://logseq.com/) graph using [logseq-export](https://github.com/viktomas/logseq-export)

## See other pages

Se how we can link to other pages [Most important page](/graph/most-important-page)

Or see the [Test page](/graph/test-page)

## Credit

This example site uses [Hugo](https://gohugo.io/) with [barklan/hugo-dead-simple](https://github.com/barklan/hugo-dead-simple) theme.
13 changes: 13 additions & 0 deletions example/logseq-export-example/content/graph/most-important-page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
public: true
slug: most-important-page
title: "Most important page"
---

This page seems quite important

Here is a picture of a cute shabby dog

![dog-316598_1280.jpg](/assets/graph/dog-316598_1280_1690970151376_0.jpg)

Continue to the [Test page](/graph/test-page)
5 changes: 5 additions & 0 deletions example/logseq-export-example/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module logseq-export-example

go 1.19

require github.com/barklan/hugo-dead-simple v1.67.0 // indirect
2 changes: 2 additions & 0 deletions example/logseq-export-example/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/barklan/hugo-dead-simple v1.67.0 h1:pGpxybvfH550M2Sv/TwYKmPs6IhiolRVRS4spqJwUH4=
github.com/barklan/hugo-dead-simple v1.67.0/go.mod h1:Ql5njM3SwZWMqWD1bt6UQoebKHIuRt37HeEkiWMUxXo=
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions example/logseq-graph/export.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
unquotedProperties:
- date
- slug
- public
- tags
- shelves
- audiobook
- started
assetsRelativePath: 'static/images/logseq'
webAssetsPathPrefix: "/images/logseq"
Loading

0 comments on commit 6db04a9

Please sign in to comment.