Skip to content

Commit

Permalink
Fix the build
Browse files Browse the repository at this point in the history
  • Loading branch information
RDIL committed Jan 8, 2024
1 parent 3ad5ad3 commit 862f7c8
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/custom-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Peacock supports a broad variety of server side mods (plugins). These include, b

- Broadly speaking, to install plugins, go to either the `plugins` or `#plugin-releases` channel in the Peacock Discord and download a plugin you are interested in.
- - Put your plugins into the `plugins` folder in the Peacock folder.
- Your plugin should end with `.plugin.js` or `Plugin.js` - if it's distributed as a `.zip`, extract it first.
- Your plugin should end with `.plugin.mjs` or `Plugin.js` - if it's distributed as a `.zip`, extract it first.
- Example: ![PluginsFolder](/img/plugins_folder.png)
- Be sure to check for any further instructions in the `#plugin-releases` channel for a given plugin, as certain plugins may require further installation steps or are incompatible with newer versions of Peacock.

Expand Down
14 changes: 7 additions & 7 deletions docusaurus.config.js → docusaurus.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { createRequire } from "module"

const require = createRequire(import.meta.url)

/** @type {import('@docusaurus/types').DocusaurusConfig} */
module.exports = {
export default {
title: "The Peacock Project",
tagline:
"A replacement for the HITMAN™ World of Assassination (1, 2, and 3)'s servers that runs on your machine.",
Expand Down Expand Up @@ -89,10 +93,6 @@ module.exports = {
{
title: "Community",
items: [
{
label: "Testimonials",
to: "/testimonials",
},
{
label: "Ghost Mode",
to: "/wiki/ghost-mode",
Expand Down Expand Up @@ -150,7 +150,7 @@ module.exports = {
[
"@docusaurus/plugin-content-docs",
{
sidebarPath: require.resolve("./sidebars.js"),
sidebarPath: require.resolve("./sidebars.mjs"),
routeBasePath: "/wiki/",
editUrl: ({ locale, docPath }) => {
if (locale !== `en`) {
Expand All @@ -162,7 +162,7 @@ module.exports = {
},
],
"@docusaurus/plugin-content-pages",
require.resolve("./src/search/plugin.js"),
require.resolve("./src/search/plugin.mjs"),
[
"@docusaurus/plugin-sitemap",
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"devDependencies": {
"@docusaurus/types": "^3.1.0",
"@tsconfig/docusaurus": "^2.0.2",
"@types/lunr": "^2.3.7",
"@types/node": "^20.10.7",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
Expand Down
2 changes: 1 addition & 1 deletion sidebars.js → sidebars.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
sidebar: [
{
type: "doc",
Expand Down
18 changes: 9 additions & 9 deletions src/search/html-to-doc.js → src/search/html-to-doc.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const { parentPort } = require("worker_threads")
import { parentPort } from "worker_threads"

// unified imports
const unified = require("unified")
const parse = require("rehype-parse")
const select = require("hast-util-select").select
const selectAll = require("hast-util-select").selectAll
const toText = require("hast-util-to-text")
const is = require("unist-util-is")
const toVfile = require("to-vfile")
import {unified} from "unified"
import parse from "rehype-parse"
import {select} from "hast-util-select"
import {selectAll} from "hast-util-select"
import {toText} from "hast-util-to-text"
import {is} from "unist-util-is"
import {readSync as toVFile_readSync} from "to-vfile"

const sectionHeaderTest = ({ tagName }) => ["h2", "h3"].includes(tagName)

// Build search data for a html
function* scanDocuments({ path, url }) {
let vfile
try {
vfile = toVfile.readSync(path)
vfile = toVFile_readSync(path)
} catch (e) {
if (e.code !== "ENOENT") {
console.error(
Expand Down
16 changes: 8 additions & 8 deletions src/search/plugin.js → src/search/plugin.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const fs = require("fs")
const os = require("os")
const path = require("path")
const lunr = require("lunr")
const { Worker } = require("worker_threads")
import fs from "fs"
import os from "os"
import path from "path"
import lunr from "lunr"
import { Worker } from "worker_threads"

// local imports
const utils = require("./utils")
const utils = require("./utils.mjs")

module.exports = (context, options) => {
export default (context, options) => {
options = options || {}
let languages

Expand Down Expand Up @@ -114,7 +114,7 @@ function buildSearchData(files, addToSearchData) {
if (nextIndex >= files.length) {
break
}
const worker = new Worker(path.join(__dirname, "html-to-doc.js"))
const worker = new Worker(path.join(__dirname, "html-to-doc.mjs"))
worker.on("error", reject)
worker.on("message", (message) => {
handleMessage(message, worker)
Expand Down
23 changes: 13 additions & 10 deletions src/search/utils.js → src/search/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const path = require("path")
const fs = require("fs")
const lunr = require("lunr")
const minimatch = require("minimatch")
import path from "path"
import fs from "fs"
import lunr from "lunr"
import { minimatch } from "minimatch"
import { createRequire } from "module"

const require = createRequire(import.meta.url)

/**
* Based on code from https://github.com/cmfcmf/docusaurus-search-local/
Expand All @@ -14,11 +17,11 @@ function generateLunrClientJS(outDir, language = "en") {
let lunrClient =
"// THIS FILE IS AUTOGENERATED\n" +
"// DO NOT EDIT THIS FILE!\n\n" +
'import * as lunr from "lunr";\n'
"import * as lunr from \"lunr\";\n"

if (language !== "en") {
require("lunr-languages/lunr.stemmer.support")(lunr)
lunrClient += 'require("lunr-languages/lunr.stemmer.support")(lunr);\n'
lunrClient += "require(\"lunr-languages/lunr.stemmer.support\")(lunr);\n"
if (Array.isArray(language)) {
language
.filter((code) => code !== "en")
Expand Down Expand Up @@ -53,7 +56,7 @@ function getFilePaths(routesPaths, outDir, baseUrl, options = {}) {
const addedFiles = new Set()
const { excludeRoutes = [], indexBaseUrl = false } = options
const meta = {
excludedCount: 0,
excludedCount: 0
}

routesPaths.forEach((route) => {
Expand Down Expand Up @@ -83,15 +86,15 @@ function getFilePaths(routesPaths, outDir, baseUrl, options = {}) {

files.push({
path: filePath,
url: route,
url: route
})
addedFiles.add(filePath)
})

return [files, meta]
}

module.exports = {
export {
generateLunrClientJS,
getFilePaths,
getFilePaths
}
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2652,6 +2652,13 @@ __metadata:
languageName: node
linkType: hard

"@types/lunr@npm:^2.3.7":
version: 2.3.7
resolution: "@types/lunr@npm:2.3.7"
checksum: 262a09c908271bb6b3fb1a9f4d312ddea3436022ea7d17cbf4a04215ca8a909c2af8a03af89b931f7cd0d5389f75c606582a050f900c1837f6527544de5ae014
languageName: node
linkType: hard

"@types/mdast@npm:^4.0.0, @types/mdast@npm:^4.0.2":
version: 4.0.3
resolution: "@types/mdast@npm:4.0.3"
Expand Down Expand Up @@ -8912,6 +8919,7 @@ __metadata:
"@docusaurus/types": "npm:^3.1.0"
"@mdx-js/react": "npm:^3.0.0"
"@tsconfig/docusaurus": "npm:^2.0.2"
"@types/lunr": "npm:^2.3.7"
"@types/node": "npm:^20.10.7"
"@types/react": "npm:^18.2.47"
"@types/react-dom": "npm:^18.2.18"
Expand Down

0 comments on commit 862f7c8

Please sign in to comment.