Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
Signed-off-by: Chawye Hsu <[email protected]>
  • Loading branch information
chawyehsu committed Jan 12, 2025
1 parent e385004 commit a51deee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions packages/@alterjs/saber-plugin-search/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { join } = require('path')
const { join } = require('node:path')

const ID = 'search'

Expand All @@ -13,9 +13,9 @@ function getLocale(locale) {
exports.apply = (api, options) => {
const { index } = Object.assign(
{
index: ['type', 'title', 'excerpt', 'permalink']
index: ['type', 'title', 'excerpt', 'permalink'],
},
options
options,
)

const { fs } = api.utils
Expand All @@ -24,7 +24,7 @@ exports.apply = (api, options) => {
const pages = []

await Promise.all(
[...api.pages.values()].map(async page => {
[...api.pages.values()].map(async (page) => {
if (page.draft || !page.type) {
return
}
Expand All @@ -41,7 +41,7 @@ exports.apply = (api, options) => {
if (value !== undefined) {
if (element === 'content') {
item.content = await api.renderer.renderPageContent(
page.permalink
page.permalink,
)
} else {
item[element] = page[element]
Expand All @@ -50,7 +50,7 @@ exports.apply = (api, options) => {
}

pages.push(item)
})
}),
)

return pages
Expand All @@ -60,7 +60,7 @@ exports.apply = (api, options) => {
const allLocalePaths = ['/'].concat(Object.keys(api.config.locales || {}))

const results = await Promise.all(
allLocalePaths.map(localePath => generateLocale(localePath))
allLocalePaths.map(localePath => generateLocale(localePath)),
)

const localDb = {}
Expand All @@ -75,13 +75,13 @@ exports.apply = (api, options) => {
api.browserApi.add(join(__dirname, 'saber-browser.js'))

if (api.dev) {
api.hooks.onCreateServer.tap(ID, server => {
api.hooks.onCreateServer.tap(ID, (server) => {
server.get('/_saber/plugin-search/:locale.json', async (req, res) => {
db = await generateDatabase()
const dbByLocale = getLocale(req.params.locale)
if (dbByLocale) {
res.writeHead(200, {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
})
return res.end(JSON.stringify(dbByLocale))
}
Expand All @@ -98,7 +98,7 @@ exports.apply = (api, options) => {
const path = api.resolveOutDir(
'_saber',
'plugin-search',
`${locale}.json`
`${locale}.json`,
)
await fs.ensureDir(api.resolveOutDir('_saber', 'plugin-search'))
await fs.writeJson(path, items)
Expand Down
2 changes: 1 addition & 1 deletion packages/@alterjs/saber-plugin-search/lib/saber-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* globals __PUBLIC_URL__ */

export default ({ Vue }) => {
Vue.prototype.$fetchSearchDatabase = function() {
Vue.prototype.$fetchSearchDatabase = function () {
const locale = this.$localePath.slice(1) || 'default'
return window
.fetch(`${__PUBLIC_URL__}_saber/plugin-search/${locale}.json`)
Expand Down

0 comments on commit a51deee

Please sign in to comment.