Skip to content

Commit

Permalink
Merge pull request #8 from knowsys/favicons
Browse files Browse the repository at this point in the history
Derive Favicons from SVG logo
  • Loading branch information
mmarx authored Sep 25, 2024
2 parents 918b16d + ea0e450 commit fa09383
Show file tree
Hide file tree
Showing 3 changed files with 622 additions and 173 deletions.
104 changes: 80 additions & 24 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,40 +1,96 @@
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";

import tailwind from "@astrojs/tailwind";
import { favicons } from "favicons";

const base = "/nemo-doc";

async function faviconPlugin(options) {
const icons = await favicons("./logo/build/without-text/nemo-logo-rusty-nomargin.svg", options);
return {
name: "vite-plugin-favicons",
order: "pre",
sequential: true,
transform(src, id) {
if (id.endsWith("@astrojs/starlight/components/Page.astro")) {
src = src.replace("</head>", icons.html.join("") + "</head>");
}
return src;
},
configureServer(server) {
for (const icon of icons.images) {
server.middlewares.use(`/${icon.name}`, (req, res) => {
res.end(icon.contents);
});
}
},
generateBundle(options, bundle) {
for (const icon of icons.images) {
bundle[icon.name] = {
type: "asset",
fileName: icon.name,
source: icon.contents,
};
}
},
};
}

// https://astro.build/config
export default defineConfig({
site: 'https://knowsys.github.io/',
base: '/nemo-doc',
outDir: './dist/nemo-doc',
site: "https://knowsys.github.io/",
base,
outDir: "./dist/nemo-doc",
integrations: [
starlight({
title: 'Nemo Rule Engine',
customCss: [
'./src/tailwind.css'
],
title: "Nemo Rule Engine",
customCss: ["./src/tailwind.css"],
favicon: "/favicon.svg",
social: {
github: 'https://github.com/knowsys/nemo'
github: "https://github.com/knowsys/nemo",
},
sidebar: [
{
label: 'Guides',
items: [ // Each item here is one entry in the navigation menu.
{ label: 'Installing', slug: 'guides/installing' },
{ label: 'Command Line', slug: 'guides/cli' },
{ label: 'Rule Language', slug: 'guides/tour' },
{ label: 'Browser Integration', slug: 'guides/wasm' },
{ label: 'Python API', slug: 'guides/python' }
]
label: "Guides",
items: [
// Each item here is one entry in the navigation menu.
{ label: "Installing", slug: "guides/installing" },
{ label: "Command Line", slug: "guides/cli" },
{ label: "Rule Language", slug: "guides/tour" },
{ label: "Browser Integration", slug: "guides/wasm" },
{ label: "Python API", slug: "guides/python" },
],
},
{
label: 'Language Reference',
label: "Language Reference",
// todo: reorder
autogenerate: { directory: 'reference' }
}
]
autogenerate: { directory: "reference" },
},
],
}),
tailwind()
]
tailwind(),
],
vite: {
plugins: [
faviconPlugin({
path: base,
background: "#134e4a",
icons: {
favicons: [
"favicon.svg",
"favicon.ico",
"favicon-16x16.png",
"favicon-32x32.png",
"favicon-48x48.png",
],
android: false,
appleIcon: true,
appleStartup: false,
windows: false,
yandex: false,
},
}),
],
},
});
Loading

0 comments on commit fa09383

Please sign in to comment.