-
Notifications
You must be signed in to change notification settings - Fork 1
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 #8 from knowsys/favicons
Derive Favicons from SVG logo
- Loading branch information
Showing
3 changed files
with
622 additions
and
173 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
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, | ||
}, | ||
}), | ||
], | ||
}, | ||
}); |
Oops, something went wrong.