This plugin allows the user to easily import the contents of files from a Github repository that the Github user has acess to. The main goal is to enhance the ability to document code development and final code using Logseq.
A new logseq graph can be located in the code repository under a \docs
folder.
The logseq Journal can be used to document day-by-day development progress.
As code is developed and pushed to Github, the code can be retrieved and inserted into a Logseq page block.
The code can then be documented using Logseq's extensive note taking capabilities.
When a code file is updated and the changes pushed to Github, the code in Logseq can be immediately updated to the latest version using the refresh
icon.
- Click on the gear icon in the bottom-left of the
logseq-plugin-github-code
card. - Select
Open Settings
. - Enter your github
username
(not your email address) in the first field labeledgithubAccount
. - Enter a personal access token will full repo access rights in the second field labeled
githubPat
. For more information on how to generate a personal access token, look here - Optionally, enter the name of a repository that will be used if none is provided when running the
Embed Github Code
command.
- Open the local version of the repository that you want to document within your IDE (VS Code is used in the example given above).
- Create a root directory called
docs
. - Open Logseq and select
Add a graph
from the left sidebar graph menu item. - Navigate to the docs
folder
that you have just created. - Use Logseq to document your development process.
- When you are ready to document specific code in the repository, follow the per-file to embed process described below.
- Ensure that the file is pushed to your Github repository. The plugin will retrieve the most recent version of the file.
- Select the file within your IDE that you wish to embed within LogSeq.
- Copy the relative path of the file from the root of the local copy. (You can obtain this in VS Code by right-clicking on the file in the Explorer and selecting
Copy Relative Path
from the context menu). - Select an empty block in LogSeq where you want to import the file.
- If you have not set a default repository, or are copyinf from a different repository, type the name of the repository into the block folloed by
:
. Paste the relative path of the file immediately after the colon. - Run the
Github Code Embed
command by entering/Github Code Embed
after the file path. - If the configuration and file path are correctly entered the code should appear immediately below the selected block.
- Clone the plugin repo to a local folder.
- In logseq, open
Logseq→Settings
, enable developer mode. - Open
Logseq→Plugins
, chooseLoad unpacked plugin
, and select the location where you saved the source code. - Follow the configuration steps given above.
- The
Github Code Embed
command should now be installed and active.