feat(website): add content structure files

This commit is contained in:
Alexander Navarro 2024-12-26 13:18:50 -03:00
parent 9c6d935069
commit 7af58fe829
35 changed files with 214 additions and 18 deletions

View file

@ -1,11 +1,30 @@
import type { BuildConfig, BunPlugin, PluginBuilder } from "bun"; import type { BuildConfig, BunPlugin, PluginBuilder } from "bun";
import { parseArgs } from "node:util";
import { readdir, rm } from "node:fs/promises"; import { readdir, rm } from "node:fs/promises";
import { join } from "node:path"; import { join } from "node:path";
import type { FileImporter } from "sass"; import type { FileImporter } from "sass";
import { HTMLComponents } from "@mini-strap/components"; import { HTMLComponents } from "@mini-strap/components";
const outdir = "./static"; const { values } = parseArgs({
args: Bun.argv,
options: {
filter: {
type: "string",
short: "f",
default: "all",
},
output: {
type: "string",
short: "o",
default: "static",
},
},
strict: true,
allowPositionals: true,
});
const outdir = values.output ?? "./static";
const nodeModuleImporter: FileImporter<"async"> = { const nodeModuleImporter: FileImporter<"async"> = {
findFileUrl(url) { findFileUrl(url) {
@ -35,8 +54,12 @@ const sassPlugin: BunPlugin = {
}, },
}; };
const assets: BuildConfig[] = [ const assets: BuildConfig[] = [];
{
const filter = values.filter ?? "all";
if (["all", "sass"].includes(filter)) {
assets.push({
entrypoints: ["./sass/style.scss"], entrypoints: ["./sass/style.scss"],
outdir: `${outdir}/css`, outdir: `${outdir}/css`,
naming: "[name].css", naming: "[name].css",
@ -46,17 +69,21 @@ const assets: BuildConfig[] = [
// On by default in Bun v1.2+ // On by default in Bun v1.2+
html: true, html: true,
experimentalCss: true, experimentalCss: true,
}, });
}
{ if (["all", "js", "ts"].includes(filter)) {
assets.push({
entrypoints: ["./js/index.ts"], entrypoints: ["./js/index.ts"],
outdir: `${outdir}/js`, outdir: `${outdir}/js`,
target: "browser", target: "browser",
splitting: true, splitting: true,
minify: true, minify: true,
}, });
}
{ if (["all", "html"].includes(filter)) {
assets.push({
entrypoints: Object.values(HTMLComponents), entrypoints: Object.values(HTMLComponents),
outdir: "./templates/ext-components", outdir: "./templates/ext-components",
target: "browser", target: "browser",
@ -69,8 +96,8 @@ const assets: BuildConfig[] = [
// On by default in Bun v1.2+ // On by default in Bun v1.2+
html: true, html: true,
experimentalCss: true, experimentalCss: true,
}, });
]; }
const out = await Promise.all( const out = await Promise.all(
assets.map(async (item) => { assets.map(async (item) => {

View file

@ -9,6 +9,10 @@ compile_sass = false
# Whether to build a search index to be used later on by a JavaScript library # Whether to build a search index to be used later on by a JavaScript library
build_search_index = true build_search_index = true
taxonomies = [
{ name = "section", feed = true }
]
[markdown] [markdown]
# Whether to do syntax highlighting # Whether to do syntax highlighting
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola # Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola

View file

@ -1,4 +1,5 @@
+++ +++
+++ +++
# mini-strap Documentation # mini-strap Documentation

View file

@ -0,0 +1,6 @@
+++
+++
# Components
Complex elements that require custom javascript to run

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Components"]
+++
# accordion.md

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Components"]
+++
# dropdown.md

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Components"]
+++
# modal.md

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Components"]
+++
# offcanvas.md

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Components"]
+++
# tabs.md

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Components"]
+++
# tooltip.md

View file

@ -0,0 +1,4 @@
+++
+++
# Components

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Content"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Content"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Content"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Content"]
+++
# Buttons

View file

@ -0,0 +1,4 @@
+++
+++
foo

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Elements"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Elements"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Elements"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Elements"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Elements"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Elements"]
+++
# Buttons

View file

@ -0,0 +1,4 @@
+++
+++
# Components

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Layout"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Layout"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Layout"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Layout"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Layout"]
+++
# Buttons

View file

@ -0,0 +1,6 @@
+++
[taxonomies]
section = ["Layout"]
+++
# Buttons

View file

@ -3,7 +3,9 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"link-dependencies": "bun run _scripts/link-dependencies.ts", "link-dependencies": "bun run _scripts/link-dependencies.ts",
"dev": "zola serve --port 3000 --fast" "prebuild": "bun run _scripts/build.ts",
"watch-deps": "bun run --watch _scripts/build.ts",
"dev": "zola serve --port 3000 --fast --open"
}, },
"dependencies": { "dependencies": {
"@mini-strap/core": "workspace:*", "@mini-strap/core": "workspace:*",

View file

@ -13,8 +13,8 @@
</head> </head>
<body transition:animate="fade"> <body transition:animate="fade">
<header class="position-sticky py-1 py-lg-3"> <header class="msp-position-sticky msp-py-1 msp-py-lg-3">
{% include "partials/navbar.html" %} {% include "partials/header.html" %}
</header> </header>
<main> <main>
{% block content %}{% endblock %} {% block content %}{% endblock %}

View file

@ -0,0 +1,18 @@
<ul>
<li>
<a href="/">Overview</a>
</li>
{% for item in get_taxonomy(kind="section") | get(key="items") %}
<li>
<a href="{{ get_url(path="@/" ~ item.slug ~ "/_index.md") }}">{{ item.name | title }}</a>
<ul class="msp-d-none">
{% for page in item.pages %}
<li>
<a href="{{ page.permalink }}">{{ page.title | default(value=page.slug) | title }}</a>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>

View file

@ -3,10 +3,4 @@
{% block content %} {% block content %}
{{section.content | safe}} {{section.content | safe}}
<ul>
{% for page in section.pages %}
<li><a href="{{page.permalink}}">{{page.path | safe}}</a></li>
{% endfor %}
</ul>
{% endblock content %} {% endblock content %}