-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from Nodsoft/feature/web
Add Astro presentation website
- Loading branch information
Showing
61 changed files
with
71,851 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Deploy Astro website to GitHub Pages | ||
|
||
on: | ||
# Trigger the workflow every time you push to the `main` branch | ||
# Using a different branch name? Replace `main` with your branch’s name | ||
push: | ||
branches: [ main, feature/web ] | ||
paths: | ||
- 'nodsoft_moltenobsidian_web/**' | ||
- 'nodsoft_moltenobsidian_ssg_client/**' | ||
- '.github/workflows/deploy-astro-website.yml' | ||
# Allows you to run this workflow manually from the Actions tab on GitHub. | ||
workflow_dispatch: | ||
|
||
# Allow this job to clone the repo and create a page deployment | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup MoltenObsidian | ||
uses: nodsoft/setup-moltenobsidian@main | ||
|
||
- name: Generate Vault manifest | ||
run: moltenobsidian manifest generate "nodsoft_moltenobsidian_web/vault" | ||
|
||
- name: Create output directory (recursive) | ||
run: mkdir -p "nodsoft_moltenobsidian_web/public/vault" | ||
|
||
- name: Generate SSG assets | ||
run: | | ||
moltenobsidian ssg generate \ | ||
--from-folder "nodsoft_moltenobsidian_web/vault" \ | ||
--output-path "nodsoft_moltenobsidian_web/public/vault" \ | ||
--ignored-files ".gitignore" | ||
- name: Install PNPM | ||
run: npm install -g pnpm | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd "nodsoft_moltenobsidian_ssg_client" | ||
pnpm recursive install --prod | ||
- name: Install, build, and upload | ||
uses: withastro/action@v1 | ||
with: | ||
path: nodsoft_moltenobsidian_web # The root location of your Astro project inside the repository. (optional) | ||
# node-version: 18 # The specific version of Node that should be used to build your site. Defaults to 18. (optional) | ||
package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional) | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
|
||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Generate docs manifest" type="ShConfigurationType"> | ||
<option name="SCRIPT_TEXT" value="moltenobsidian manifest generate "./vault" --output "./src/assets/vault" --ignore-file ".gitignore" --force --debug" /> | ||
<option name="INDEPENDENT_SCRIPT_PATH" value="true" /> | ||
<option name="SCRIPT_PATH" value="" /> | ||
<option name="SCRIPT_OPTIONS" value="" /> | ||
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="false" /> | ||
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/nodsoft_moltenobsidian_web" /> | ||
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" /> | ||
<option name="INTERPRETER_PATH" value="" /> | ||
<option name="INTERPRETER_OPTIONS" value="" /> | ||
<option name="EXECUTE_IN_TERMINAL" value="true" /> | ||
<option name="EXECUTE_SCRIPT_FILE" value="false" /> | ||
<envs /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Generate site content" type="ShConfigurationType"> | ||
<option name="SCRIPT_TEXT" value="moltenobsidian ssg generate --from-folder "./vault" --output-path "./src/assets/vault" --ignored-files ".gitignore" --debug" /> | ||
<option name="INDEPENDENT_SCRIPT_PATH" value="true" /> | ||
<option name="SCRIPT_PATH" value="" /> | ||
<option name="SCRIPT_OPTIONS" value="" /> | ||
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="false" /> | ||
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/nodsoft_moltenobsidian_web" /> | ||
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" /> | ||
<option name="INTERPRETER_PATH" value="" /> | ||
<option name="INTERPRETER_OPTIONS" value="" /> | ||
<option name="EXECUTE_IN_TERMINAL" value="true" /> | ||
<option name="EXECUTE_SCRIPT_FILE" value="false" /> | ||
<envs /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import {VaultFile, VaultManifest} from 'vault-manifest' | ||
import YAML from 'yaml' | ||
|
||
/** | ||
* Represents a client for resolving a MoltenObsidian vault's assets from its manifest. | ||
* @class | ||
* @public | ||
*/ | ||
export class VaultManifestClient { | ||
protected _routingTable: Map<string, VaultFile> | undefined; | ||
|
||
public static fromManifest(manifest: VaultManifest) { | ||
return new VaultManifestClient(manifest); | ||
} | ||
|
||
public static async fromPath(path: string | URL) { | ||
// Fetch the manifest from the URL | ||
const response = await fetch(path); | ||
if (!response.ok) { | ||
throw new Error(`Failed to fetch manifest from ${path.toString()}: ${response.statusText}`); | ||
} | ||
|
||
const manifest = await response.json() as VaultManifest; | ||
return VaultManifestClient.fromManifest(manifest); | ||
} | ||
|
||
protected constructor( | ||
public readonly Manifest: VaultManifest | ||
) { } | ||
|
||
public get routingTable() { | ||
if (!this._routingTable) { | ||
this._routingTable = this.buildRoutingTable(); | ||
} | ||
|
||
return this._routingTable; | ||
} | ||
|
||
private buildRoutingTable() { | ||
const routingTable = new Map<string, VaultFile>(); | ||
|
||
for (const file of this.Manifest.files) { | ||
// If markdown, add to routing table | ||
if (!file.path.endsWith('.md')) { | ||
continue; | ||
} | ||
|
||
// Exclusion cases | ||
if ((file.moltenobsidian?.publish ?? file.publish) == false) { | ||
continue; | ||
} | ||
|
||
const indexFileRegex = /(\/?index\.md|readme\.md)$/ig; | ||
if (file.path.match(indexFileRegex)) { | ||
console.log(file.path, file.path.replace(indexFileRegex, '')); | ||
routingTable.set(file.path.replace(indexFileRegex, ''), file); | ||
} | ||
else if (file.path.endsWith('.md')) { | ||
const mdRegex = /\.md$/; | ||
routingTable.set(file.path.replace(mdRegex, ''), file); | ||
// routingTable.set(file.path.replace(mdRegex, '.html'), file); | ||
} | ||
|
||
// routingTable.set(file.path, file); | ||
} | ||
|
||
return routingTable; | ||
} | ||
|
||
getSsgPath(file: { path: string }) { | ||
let path = file.path; | ||
if (path.startsWith('/')) { | ||
path = path.substring(1); | ||
} | ||
|
||
return path.replace(/\.md$/, '.html'); | ||
} | ||
|
||
public static getFrontMatter(file: string | BinaryData) { | ||
if (typeof file !== 'string') { | ||
file = new TextDecoder().decode(file); | ||
} | ||
|
||
return YAML.parse(file); | ||
} | ||
|
||
public getFrontMatterFilePath(path: string) { | ||
return path.replace(/\.md$|\.html$/, '.yaml'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "moltenobsidian-ssg-client", | ||
"author": "Nodsoft Systems", | ||
"description": "SSG Client for MoltenObsidian vaults", | ||
"license": "ISC", | ||
"scripts": { | ||
"build": "tsc" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.1.6" | ||
}, | ||
"dependencies": { | ||
"@types/mime-types": "^2.1.1", | ||
"yaml": "^2.3.1" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.