mirror of https://github.com/vapor/docs.git
Add script to fix search index
This commit is contained in:
parent
8ddc141d29
commit
2967397019
|
|
@ -16,9 +16,8 @@ copyright: "Copyright © Vapor Community"
|
||||||
theme:
|
theme:
|
||||||
name: material
|
name: material
|
||||||
custom_dir: theme/
|
custom_dir: theme/
|
||||||
|
|
||||||
# Language
|
|
||||||
language: en
|
language: en
|
||||||
|
locale: en
|
||||||
|
|
||||||
palette:
|
palette:
|
||||||
primary: black
|
primary: black
|
||||||
|
|
@ -46,8 +45,6 @@ extra:
|
||||||
link: https://discord.gg/vapor
|
link: https://discord.gg/vapor
|
||||||
- icon: fontawesome/brands/github
|
- icon: fontawesome/brands/github
|
||||||
link: https://github.com/vapor
|
link: https://github.com/vapor
|
||||||
search:
|
|
||||||
language: 'en'
|
|
||||||
|
|
||||||
# Custom code highlighting syntax (uncomment if you want to use this. css is in `docs/stylesheets/extra.css`)
|
# Custom code highlighting syntax (uncomment if you want to use this. css is in `docs/stylesheets/extra.css`)
|
||||||
extra_css:
|
extra_css:
|
||||||
|
|
@ -73,6 +70,7 @@ plugins:
|
||||||
- i18n:
|
- i18n:
|
||||||
default_language: 'en'
|
default_language: 'en'
|
||||||
search_reconfigure: false
|
search_reconfigure: false
|
||||||
|
material_alternate: true
|
||||||
# Add the new languages here. DON'T CHANGE THE DEFAULT LANGUAGE
|
# Add the new languages here. DON'T CHANGE THE DEFAULT LANGUAGE
|
||||||
languages:
|
languages:
|
||||||
en:
|
en:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/swift
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct SearchIndex: Codable {
|
||||||
|
let config: SearchIndexConfig
|
||||||
|
var docs: [SearchIndexDocs]
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SearchIndexConfig: Codable {
|
||||||
|
let indexing: String
|
||||||
|
let lang: [String]
|
||||||
|
let minSearchLength: Int
|
||||||
|
let prebuildIndex: Bool
|
||||||
|
let separator: String
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case indexing
|
||||||
|
case lang
|
||||||
|
case minSearchLength = "min_search_length"
|
||||||
|
case prebuildIndex = "prebuild_index"
|
||||||
|
case separator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SearchIndexDocs: Codable {
|
||||||
|
let location: String
|
||||||
|
let text: String
|
||||||
|
let title: String
|
||||||
|
}
|
||||||
|
|
||||||
|
let searchIndexPath = "site/4.0/search/search_index.json"
|
||||||
|
|
||||||
|
let fileURL = URL(fileURLWithPath: searchIndexPath)
|
||||||
|
let indexData = try Data(contentsOf: fileURL)
|
||||||
|
let searchIndex = try JSONDecoder().decode(SearchIndex.self, from: indexData)
|
||||||
|
var newSearchIndex = searchIndex
|
||||||
|
var searchIndexDocs = [SearchIndexDocs]()
|
||||||
|
|
||||||
|
for doc in newSearchIndex.docs {
|
||||||
|
if !doc.location.starts(with: "en/")
|
||||||
|
&& !doc.location.starts(with: "fr/")
|
||||||
|
&& !doc.location.starts(with: "nl/") {
|
||||||
|
searchIndexDocs.append(doc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newSearchIndex.docs = searchIndexDocs
|
||||||
|
|
||||||
|
try JSONEncoder().encode(newSearchIndex).write(to: fileURL)
|
||||||
Loading…
Reference in New Issue