Skip to content

Commit

Permalink
Added search, updated Vitepress to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
sinnwise committed Dec 28, 2023
1 parent 0b2eec2 commit ebf3ef8
Show file tree
Hide file tree
Showing 17 changed files with 1,529 additions and 734 deletions.
84 changes: 55 additions & 29 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import {defineConfig} from 'vitepress'
import './syntax/syntax'
import footnote from 'markdown-it-footnote'

// import splunk_syntax from './syntax/splunk.tmLanguage.json'
// import sumo_syntax from './syntax/sumologic.tmLanguage.json'
// import bash_syntax from './syntax/bash.tmLanguage.json'

export default defineConfig({
title: 'Sigma',
titleTemplate: 'Sigma Website',
description: 'A generic and open signature format that allows you to describe relevant log events in a straight-forward manner.',
sitemap: {
hostname: 'https://sigmahq.io'
},
head: [
['link', {
media: "(prefers-color-scheme: dark)",
Expand Down Expand Up @@ -103,16 +109,16 @@ export default defineConfig({
['meta', {property: "og:url", content: "https://sigmahq.io/"}],
['meta', {property: "og:image", content: "https://sigmahq.io/images/og_image.jpg"}],
[
'script',
{
async: true,
src: 'https://www.googletagmanager.com/gtag/js?id=UA-288648316-1',
},
'script',
{
async: '',
src: 'https://www.googletagmanager.com/gtag/js?id=UA-288648316-1',
},
],
[
'script',
{},
`window.dataLayer = window.dataLayer || [];
'script',
{},
`window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-288648316-1');`
Expand Down Expand Up @@ -160,7 +166,7 @@ export default defineConfig({
{
text: 'Sigma Basics',
items: [
{text: 'Rules', link: '/docs/basics/rules'},
{text: 'Rules', link: '/docs/basics/rules'},
{text: 'Modifiers', link: '/docs/basics/modifiers'},
{text: 'Conditions', link: '/docs/basics/conditions'},
// {text: 'Validation', link: '/docs/basics/validation'},
Expand Down Expand Up @@ -188,9 +194,21 @@ export default defineConfig({
text: 'Backends',
items: [
{text: 'Splunk', link: 'https://github.com/SigmaHQ/pySigma-backend-splunk', rel: "_target"},
{text: 'InsightEDR', link: 'https://github.com/SigmaHQ/pySigma-backend-insightidr', rel: "_target"},
{text: 'ElasticSearch', link: 'https://github.com/SigmaHQ/pySigma-backend-elasticsearch', rel: "_target"},
{text: 'OpenSearch', link: 'https://github.com/SigmaHQ/pySigma-backend-opensearch', rel: "_target"},
{
text: 'InsightEDR',
link: 'https://github.com/SigmaHQ/pySigma-backend-insightidr',
rel: "_target"
},
{
text: 'ElasticSearch',
link: 'https://github.com/SigmaHQ/pySigma-backend-elasticsearch',
rel: "_target"
},
{
text: 'OpenSearch',
link: 'https://github.com/SigmaHQ/pySigma-backend-opensearch',
rel: "_target"
},
{text: 'More  ›', link: '/docs/digging-deeper/backends.html'},
]
},
Expand Down Expand Up @@ -243,24 +261,32 @@ export default defineConfig({
{icon: 'twitter', link: 'https://twitter.com/Sigma_HQ/'},
{icon: 'github', link: 'https://github.com/SigmaHQ/sigma'},
],
// search: {
// provider: 'local',
// options: {
// _render(src, env, md) {
// const html = md.render(src, env)
// console.log(src)
// // return (env.frontmatter?.title)
// if (env.frontmatter?.title) {
// return md.render(`# ${env.frontmatter.title}`) + html
// }
// if (env.frontmatter?.search === false) return ''
// if (env.relativePath.startsWith('docs/v1')) return ''
// return html
// }
// }
// }
search: {
provider: 'local',
options: {
_render(src, env, md) {
let html = md.render(src, env)

const title_regex = /{{\s\$frontmatter\.title\s}}/
html = html.replace(title_regex, env.frontmatter?.title || "")

if(env.frontmatter?.search == false) {
return ""
}
return html
}
}
}

},
markdown: {
languageAlias: {
'conf': 'ini'
},
languages: [
// splunk_syntax,
// sumo_syntax
],
config: (md) => {
// @ts-ignore
md.use(footnote)
Expand Down
1 change: 1 addition & 0 deletions .vitepress/syntax/splunk.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Splunk Query Language",
"scopeName": "source.splunk",
"embeddedLangs": ["splunk"],
"fileTypes": ["splunk", "spl"],
"uuid": "8fbbb1e7-8311-4bdc-aaef-a1639ca8d0ad",

Expand Down
45 changes: 0 additions & 45 deletions .vitepress/syntax/syntax.ts
Original file line number Diff line number Diff line change
@@ -1,45 +0,0 @@
import {BUNDLED_LANGUAGES} from 'shiki'

// @ts-ignore
import splunk_syntax from './splunk.tmLanguage.json'
// @ts-ignore
import sumo_syntax from './sumologic.tmLanguage.json'
// @ts-ignore
import bash_syntax from './bash.tmLanguage.json'

// @ts-ignore
BUNDLED_LANGUAGES.push({
id: "splunk",
scopeName: 'source.splunk',
aliases: [],
grammar: splunk_syntax,
})

// @ts-ignore
BUNDLED_LANGUAGES.push({
id: "sumologic",
scopeName: 'source.sumologic',
aliases: [],
grammar: sumo_syntax,
})

// @ts-ignore
BUNDLED_LANGUAGES.push({
id: "shell",
scopeName: 'source.shell',
aliases: ['bash'],
grammar: bash_syntax,
})


// @ts-ignore
BUNDLED_LANGUAGES.find(lang => lang.id === 'yaml').aliases.push('yaml-vue');

// @ts-ignore
BUNDLED_LANGUAGES.find(lang => lang.id === 'shell').aliases.push('bash-vue');

// @ts-ignore
BUNDLED_LANGUAGES.find(lang => lang.id === 'sumologic').aliases.push('sumologic-vue');

// @ts-ignore
BUNDLED_LANGUAGES.find(lang => lang.id === 'splunk').aliases.push('splunk-vue');
2 changes: 1 addition & 1 deletion .vitepress/theme/components/DraftWarning.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="whitespace-pre-wrap text-center">
<div
class="lg:inline-block rounded-lg border border-[var(--vp-badge-warning-border)] px-4 py-1 bg-[var(--vp-badge-warning-bg)] text-[var(--vp-badge-warning-text)]">
class="rounded-lg border border-[var(--vp-badge-warning-border)] px-4 py-1 bg-[var(--vp-badge-warning-bg)] text-[var(--vp-badge-warning-text)]">
<b class="text-xs bold inline">WIP Version</b>
<p class=" text-xs hidden">This documentation is a work in progress.</p>
</div>
Expand Down
23 changes: 9 additions & 14 deletions .vitepress/theme/layouts/Docsv2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import DefaultTheme from 'vitepress/theme'
import {useData} from "vitepress/dist/client/theme-default/composables/data";
import {BookOpenIcon, RectangleGroupIcon} from "@heroicons/vue/20/solid";
import {useRoute, useRouter, withBase} from "vitepress";
import DraftWarning from "../components/DraftWarning.vue";
const { Layout } = DefaultTheme
const { frontmatter } = useData()
import VPLink from 'vitepress/dist/client/theme-default/components/VPLink.vue'
function active_link(link: string) {
return useRoute().data.relativePath.includes(link)
Expand All @@ -22,21 +20,18 @@ function active_link(link: string) {
</div>
</template>

<template #nav-bar-content-before>
<div class="flex space-x-2 px-2 w-full justify-end">
<!-- Draft -->
<DraftWarning class="hidden md:block"/>
</div>

<template #nav-bar-content-before>
<div class="hidden xl:block w-full"></div>
</template>

<template #doc-before>
<div class="flex flex-col gap-4 pb-8">
<!-- Draft -->
<DraftWarning class="block md:hidden w-full mb-0"/>
</div>
<slot name="doc-before" />
</template>
<!-- <template #doc-before>-->
<!-- <div class="flex flex-col gap-4 pb-8">-->
<!-- &lt;!&ndash; Draft &ndash;&gt;-->
<!-- <DraftWarning class="block md:hidden w-full mb-0"/>-->
<!-- </div>-->
<!-- <slot name="doc-before" />-->
<!-- </template>-->

<template #sidebar-nav-before>
<div class="flex flex-col gap-2 pt-6 pb-4 group">
Expand Down
Loading

0 comments on commit ebf3ef8

Please sign in to comment.