diff --git a/README.md b/README.md index 758716e..7f3b6c9 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ -# Astro Starter Kit: Blog +# Astro-WikiBonsai -```sh -npm create astro@latest -- --template blog -``` +[![A WikiBonsai Project](https://img.shields.io/badge/%F0%9F%8E%8B-A%20WikiBonsai%20Project-brightgreen)](https://github.com/wikibonsai/wikibonsai) -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/blog) -[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/blog) -[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/blog/devcontainer.json) +An [Astro base blog](https://github.com/withastro/astro/tree/main/examples/blog) with [wikibonsai](https://github.com/wikibonsai/wikibonsai) support. + +💐 Display your [🎋 WikiBonsai](https://github.com/wikibonsai/wikibonsai) digital garden for others. > 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun! @@ -38,6 +36,12 @@ Inside of your Astro project, you'll see the following folders and files: └── tsconfig.json ``` +#todo + +- entries +- index + - when defining the tree in 'i.bonsai.md', be sure there is a single root node so that the entire tree is processed properly. + Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components. diff --git a/astro.config.mjs b/astro.config.mjs index 3b2f75c..5e14e55 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,10 +1,42 @@ -import { defineConfig } from 'astro/config'; -import mdx from '@astrojs/mdx'; +import { base, defineConfig } from 'astro/config'; import sitemap from '@astrojs/sitemap'; +import { remarkWikiRefs } from 'remark-wikirefs'; +import { remarkCaml } from 'remark-caml'; + +import { + resolveHtmlHref, + resolveHtmlText, + resolveEmbedContent, + generateForeRefsRemarkPlugin, +} from './src/wikibonsai/wikirefs'; + + // https://astro.build/config export default defineConfig({ - site: 'https://example.com', - integrations: [mdx(), sitemap()], + site: 'https://astro-wikibonsai.netlify.app', + integrations: [ + sitemap(), + ], + assetsInclude: true, + markdown: { + // Preserve Astro's default plugins: GitHub-flavored Markdown and Smartypants + extendDefaultPlugins: true, + // Applied to .md and .mdx files + remarkPlugins: [ + remarkCaml, + [ + remarkWikiRefs, + { + baseUrl: base, + resolveHtmlHref: resolveHtmlHref, + resolveHtmlText: resolveHtmlText, + resolveEmbedContent: resolveEmbedContent, + }, + ], + // this plugin is necessary for backrefs to work + generateForeRefsRemarkPlugin, + ], + }, }); diff --git a/package.json b/package.json index 2f30c86..e380ad6 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,16 @@ "name": "astro-wikibonsai", "type": "module", "version": "0.0.1", + "description": "A starter project for a WikiBonsai digital garden using the Astro static site generator.", + "license": "MIT", + "author": { + "name": "manunamz", + "email": "manuanmz@pm.me" + }, + "repository": { + "type": "git", + "url": "https://github.com/wikibonsai/astro-wikibonsai" + }, "scripts": { "dev": "astro dev", "start": "astro dev", @@ -13,6 +23,13 @@ "@astrojs/mdx": "^1.1.0", "@astrojs/rss": "^3.0.0", "@astrojs/sitemap": "^3.0.0", - "astro": "^3.1.4" + "astro": "^3.1.4", + "fast-glob": "^3.3.1", + "gray-matter": "^4.0.3", + "remark-caml": "^0.0.5-rm", + "remark-wikirefs": "^0.0.6-rm", + "semtree": "^0.0.2", + "unist-util-select": "^5.0.0", + "wikirefs": "^0.0.4" } -} \ No newline at end of file +} diff --git a/public/wikibonsai.svg b/public/wikibonsai.svg new file mode 100755 index 0000000..51ccace --- /dev/null +++ b/public/wikibonsai.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/components/BackRefs.astro b/src/components/BackRefs.astro new file mode 100644 index 0000000..2f57d46 --- /dev/null +++ b/src/components/BackRefs.astro @@ -0,0 +1,77 @@ +--- +// import { getCollection } from 'astro:content'; +import { generateBackRefs } from '../wikibonsai/backrefs'; + +const { frontmatter } = Astro.props; + +const res = await generateBackRefs(frontmatter.fname); +const backattrs = res.backattrs; +const backlinks = res.backlinks; +--- + +
+
Links To This Page
+
+
+ Attributes +
    + {Object.entries(backattrs).map(([type, attrs]) => +
  • + {type} : + +
  • + )} +
+
+
+ Links + +
+
diff --git a/src/components/Branch.astro b/src/components/Branch.astro new file mode 100644 index 0000000..896a911 --- /dev/null +++ b/src/components/Branch.astro @@ -0,0 +1,25 @@ +--- +import { getCollection } from 'astro:content'; +import { SITE_TITLE } from '../consts'; +import { bonsai } from '../wikibonsai/semtree'; + +const { nodes } = Astro.props; + +const root = bonsai ? bonsai.root : ''; +const tree = bonsai ? bonsai.tree : []; +--- + + diff --git a/src/components/BreadCrumbs.astro b/src/components/BreadCrumbs.astro new file mode 100644 index 0000000..46deee7 --- /dev/null +++ b/src/components/BreadCrumbs.astro @@ -0,0 +1,48 @@ +--- +import { SITE_TITLE } from '../consts'; +import { bonsai } from '../wikibonsai/semtree'; + +const { current } = Astro.props; + +const root = bonsai ? bonsai.root : ''; +const tree = bonsai ? bonsai.tree : []; + +const curNode = tree.find(node => node.text == current); +const ancestors = curNode ? curNode.ancestors : []; +const ancestorNodes = ancestors.map(n => tree.find(tn => tn.text == n)); +--- + + diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 96c2fce..a84e3dc 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -3,23 +3,9 @@ const today = new Date(); ---