mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-27 00:58:36 +00:00
Optimize static props a bit.
This commit is contained in:
parent
1051acbe88
commit
ec8981c5da
@ -1,6 +1,10 @@
|
||||
import Layout from '../components/Layout'
|
||||
import SEO from '../components/SEO'
|
||||
import { getConfigSettings, Documentation } from '../utils/doc-utils'
|
||||
import {
|
||||
getConfigSettings,
|
||||
Documentation,
|
||||
filterDesc,
|
||||
} from '../utils/doc-utils'
|
||||
import Docs from '../components/Docs'
|
||||
import { getSearchIndex, SearchIndex } from '../utils/search'
|
||||
|
||||
@ -27,7 +31,7 @@ export default function ConfigSettings(props: ConfigSettingsProps) {
|
||||
}
|
||||
|
||||
export async function getStaticProps() {
|
||||
const config_settings = getConfigSettings()
|
||||
const config_settings = filterDesc(getConfigSettings())
|
||||
const searchIndex = getSearchIndex()
|
||||
|
||||
return { props: { config_settings, searchIndex } }
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Layout from '../components/Layout'
|
||||
import SEO from '../components/SEO'
|
||||
import { getLua, Documentation } from '../utils/doc-utils'
|
||||
import { getLua, Documentation, filterDesc } from '../utils/doc-utils'
|
||||
import Docs from '../components/Docs'
|
||||
import { getSearchIndex, SearchIndex } from '../utils/search'
|
||||
|
||||
@ -24,7 +24,7 @@ export default function Lua(props: LuaProps) {
|
||||
}
|
||||
|
||||
export async function getStaticProps() {
|
||||
const lua = getLua()
|
||||
const lua = filterDesc(getLua())
|
||||
const searchIndex = getSearchIndex()
|
||||
|
||||
return { props: { lua, searchIndex } }
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Layout from '../components/Layout'
|
||||
import SEO from '../components/SEO'
|
||||
import { getVariables, Documentation } from '../utils/doc-utils'
|
||||
import { getVariables, Documentation, filterDesc } from '../utils/doc-utils'
|
||||
import Docs from '../components/Docs'
|
||||
import { getSearchIndex, SearchIndex } from '../utils/search'
|
||||
|
||||
@ -27,7 +27,7 @@ export default function Variables(props: VariablesProps) {
|
||||
}
|
||||
|
||||
export async function getStaticProps() {
|
||||
const variables = getVariables()
|
||||
const variables = filterDesc(getVariables())
|
||||
const searchIndex = getSearchIndex()
|
||||
|
||||
return { props: { variables, searchIndex } }
|
||||
|
@ -40,6 +40,17 @@ function getDocumentation(source: string): Documentation {
|
||||
return docs
|
||||
}
|
||||
|
||||
export function filterDesc(docs: Documentation): Documentation {
|
||||
return {
|
||||
...docs,
|
||||
desc: '',
|
||||
values: docs.values.map((v) => ({
|
||||
...v,
|
||||
desc: '',
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
export function getConfigSettings(): Documentation {
|
||||
return getDocumentation('config_settings.yaml')
|
||||
}
|
||||
|
@ -17,25 +17,22 @@ export function getSearchIndex() {
|
||||
const cs: SearchItem[] = getConfigSettings().values.map((v) => ({
|
||||
kind: 'config',
|
||||
name: v.name,
|
||||
desc: v.desc,
|
||||
desc: v.desc.substring(0, 121),
|
||||
}))
|
||||
const vars: SearchItem[] = getVariables().values.map((v) => ({
|
||||
kind: 'var',
|
||||
name: v.name,
|
||||
desc: v.desc,
|
||||
desc: v.desc.substring(0, 121),
|
||||
}))
|
||||
const lua: SearchItem[] = getLua().values.map((v) => ({
|
||||
kind: 'lua',
|
||||
name: v.name,
|
||||
desc: v.desc,
|
||||
desc: v.desc.substring(0, 121),
|
||||
}))
|
||||
const list: SearchItem[] = [...cs, ...vars, ...lua]
|
||||
|
||||
return {
|
||||
list: list.map((item) => ({
|
||||
...item,
|
||||
desc: item.desc.substring(0, 121),
|
||||
})),
|
||||
list,
|
||||
index: Fuse.createIndex<SearchItem>(['name', 'desc'], list).toJSON(),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user