You've already forked AstralRinth
forked from didirus/AstralRinth
move to cloudflare workers (#1229)
* move to cloudflare workers * remove junk
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,7 +5,9 @@ node_modules
|
|||||||
.cache
|
.cache
|
||||||
.output
|
.output
|
||||||
.env
|
.env
|
||||||
|
.dev.vars
|
||||||
dist
|
dist
|
||||||
|
.wrangler/
|
||||||
|
|
||||||
generated/
|
generated/
|
||||||
!.gitkeep
|
!.gitkeep
|
||||||
|
|||||||
@@ -258,8 +258,10 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
runtimeConfig: {
|
runtimeConfig: {
|
||||||
apiBaseUrl: process.env.BASE_URL ?? getApiUrl(),
|
// @ts-ignore
|
||||||
rateLimitKey: process.env.RATE_LIMIT_IGNORE_KEY,
|
apiBaseUrl: process.env.BASE_URL ?? globalThis.BASE_URL ?? getApiUrl(),
|
||||||
|
// @ts-ignore
|
||||||
|
rateLimitKey: process.env.RATE_LIMIT_IGNORE_KEY ?? globalThis.RATE_LIMIT_IGNORE_KEY,
|
||||||
public: {
|
public: {
|
||||||
apiBaseUrl: getApiUrl(),
|
apiBaseUrl: getApiUrl(),
|
||||||
ariadneBaseUrl: getAriadneUrl(),
|
ariadneBaseUrl: getAriadneUrl(),
|
||||||
@@ -294,11 +296,13 @@ export default defineNuxtConfig({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function getApiUrl() {
|
function getApiUrl() {
|
||||||
return process.env.BROWSER_BASE_URL ?? STAGING_API_URL
|
// @ts-ignore
|
||||||
|
return process.env.BROWSER_BASE_URL ?? globalThis.BROWSER_BASE_URL ?? STAGING_API_URL
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAriadneUrl() {
|
function getAriadneUrl() {
|
||||||
return process.env.BROWSER_ARIADNE_URL ?? STAGING_ARIADNE_URL
|
// @ts-ignore
|
||||||
|
return process.env.BROWSER_ARIADNE_URL ?? globalThis.BROWSER_ARIADNE_URL ?? STAGING_ARIADNE_URL
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDomain() {
|
function getDomain() {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"dev": "nuxi dev",
|
"dev": "nuxi dev",
|
||||||
"generate": "nuxi generate",
|
"generate": "nuxi generate",
|
||||||
"preview": "nuxi preview",
|
"preview": "nuxi preview",
|
||||||
"postinstall": "nuxi prepare",
|
"postinstall": "nuxi prepare && patch-package",
|
||||||
"lint:js": "eslint . --ext .js,.vue,.ts",
|
"lint:js": "eslint . --ext .js,.vue,.ts",
|
||||||
"lint": "npm run lint:js && prettier --check .",
|
"lint": "npm run lint:js && prettier --check .",
|
||||||
"fix": "eslint . --fix --ext .js,.vue,.ts && prettier --write .",
|
"fix": "eslint . --fix --ext .js,.vue,.ts && prettier --write .",
|
||||||
@@ -33,7 +33,8 @@
|
|||||||
"typescript": "^5.0.4",
|
"typescript": "^5.0.4",
|
||||||
"vite-plugin-eslint": "^1.8.1",
|
"vite-plugin-eslint": "^1.8.1",
|
||||||
"vite-svg-loader": "^4.0.0",
|
"vite-svg-loader": "^4.0.0",
|
||||||
"vue-tsc": "^1.6.5"
|
"vue-tsc": "^1.6.5",
|
||||||
|
"patch-package": "^7.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ltd/j-toml": "^1.38.0",
|
"@ltd/j-toml": "^1.38.0",
|
||||||
|
|||||||
@@ -341,7 +341,7 @@
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script setup>
|
||||||
import { Multiselect } from 'vue-multiselect'
|
import { Multiselect } from 'vue-multiselect'
|
||||||
import ProjectCard from '~/components/ui/ProjectCard.vue'
|
import ProjectCard from '~/components/ui/ProjectCard.vue'
|
||||||
import Pagination from '~/components/ui/Pagination.vue'
|
import Pagination from '~/components/ui/Pagination.vue'
|
||||||
@@ -361,477 +361,429 @@ import ImageIcon from '~/assets/images/utils/image.svg'
|
|||||||
|
|
||||||
import Promotion from '~/components/ads/Promotion.vue'
|
import Promotion from '~/components/ads/Promotion.vue'
|
||||||
|
|
||||||
export default defineNuxtComponent({
|
const sidebarMenuOpen = ref(false)
|
||||||
components: {
|
const showAllLoaders = ref(false)
|
||||||
LogoAnimated,
|
|
||||||
Promotion,
|
|
||||||
ProjectCard,
|
|
||||||
Pagination,
|
|
||||||
Multiselect,
|
|
||||||
SearchFilter,
|
|
||||||
Checkbox,
|
|
||||||
ClientIcon,
|
|
||||||
ServerIcon,
|
|
||||||
SearchIcon,
|
|
||||||
ClearIcon,
|
|
||||||
FilterIcon,
|
|
||||||
GridIcon,
|
|
||||||
ListIcon,
|
|
||||||
ImageIcon,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
previousMaxResults: 20,
|
|
||||||
|
|
||||||
maxResultsForView: {
|
const data = useNuxtApp()
|
||||||
list: [5, 10, 15, 20, 50, 100],
|
const route = useRoute()
|
||||||
grid: [6, 12, 18, 24, 48, 96],
|
|
||||||
gallery: [6, 10, 16, 20, 50, 100],
|
|
||||||
},
|
|
||||||
|
|
||||||
sidebarMenuOpen: false,
|
const query = ref('')
|
||||||
showAllLoaders: false,
|
const facets = ref([])
|
||||||
}
|
const orFacets = ref([])
|
||||||
},
|
const selectedVersions = ref([])
|
||||||
setup() {
|
const onlyOpenSource = ref(false)
|
||||||
const data = useNuxtApp()
|
const showSnapshots = ref(false)
|
||||||
const route = useRoute()
|
const selectedEnvironments = ref([])
|
||||||
|
const sortTypes = shallowReadonly([
|
||||||
|
{ display: 'Relevance', name: 'relevance' },
|
||||||
|
{ display: 'Download count', name: 'downloads' },
|
||||||
|
{ display: 'Follow count', name: 'follows' },
|
||||||
|
{ display: 'Recently published', name: 'newest' },
|
||||||
|
{ display: 'Recently updated', name: 'updated' },
|
||||||
|
])
|
||||||
|
const sortType = ref({ display: 'Relevance', name: 'relevance' })
|
||||||
|
const maxResults = ref(20)
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const projectType = ref({ id: 'mod', display: 'mod', actual: 'mod' })
|
||||||
|
|
||||||
const query = ref('')
|
const metaDescription = computed(
|
||||||
const facets = ref([])
|
() =>
|
||||||
const orFacets = ref([])
|
`Search and browse thousands of Minecraft ${data.$formatProjectType(
|
||||||
const selectedVersions = ref([])
|
projectType.value.display
|
||||||
const onlyOpenSource = ref(false)
|
)}s on Modrinth with instant, accurate search results. Our filters help you quickly find the best Minecraft ${data.$formatProjectType(
|
||||||
const showSnapshots = ref(false)
|
projectType.value.display
|
||||||
const selectedEnvironments = ref([])
|
)}s.`
|
||||||
const sortTypes = shallowReadonly([
|
)
|
||||||
{ display: 'Relevance', name: 'relevance' },
|
if (route.query.q) {
|
||||||
{ display: 'Download count', name: 'downloads' },
|
query.value = route.query.q
|
||||||
{ display: 'Follow count', name: 'follows' },
|
}
|
||||||
{ display: 'Recently published', name: 'newest' },
|
if (route.query.f) {
|
||||||
{ display: 'Recently updated', name: 'updated' },
|
facets.value = getArrayOrString(route.query.f)
|
||||||
])
|
}
|
||||||
const sortType = ref({ display: 'Relevance', name: 'relevance' })
|
if (route.query.g) {
|
||||||
const maxResults = ref(20)
|
orFacets.value = getArrayOrString(route.query.g)
|
||||||
const currentPage = ref(1)
|
}
|
||||||
const projectType = ref({ id: 'mod', display: 'mod', actual: 'mod' })
|
if (route.query.v) {
|
||||||
|
selectedVersions.value = getArrayOrString(route.query.v)
|
||||||
|
}
|
||||||
|
if (route.query.l) {
|
||||||
|
onlyOpenSource.value = route.query.l === 'true'
|
||||||
|
}
|
||||||
|
if (route.query.h) {
|
||||||
|
showSnapshots.value = route.query.h === 'true'
|
||||||
|
}
|
||||||
|
if (route.query.e) {
|
||||||
|
selectedEnvironments.value = getArrayOrString(route.query.e)
|
||||||
|
}
|
||||||
|
if (route.query.s) {
|
||||||
|
sortType.value.name = route.query.s
|
||||||
|
|
||||||
const metaDescription = computed(
|
switch (sortType.value.name) {
|
||||||
() =>
|
case 'relevance':
|
||||||
`Search and browse thousands of Minecraft ${data.$formatProjectType(
|
sortType.value.display = 'Relevance'
|
||||||
projectType.value.display
|
break
|
||||||
)}s on Modrinth with instant, accurate search results. Our filters help you quickly find the best Minecraft ${data.$formatProjectType(
|
case 'downloads':
|
||||||
projectType.value.display
|
sortType.value.display = 'Downloads'
|
||||||
)}s.`
|
break
|
||||||
)
|
case 'newest':
|
||||||
if (route.query.q) {
|
sortType.value.display = 'Recently published'
|
||||||
query.value = route.query.q
|
break
|
||||||
}
|
case 'updated':
|
||||||
if (route.query.f) {
|
sortType.value.display = 'Recently updated'
|
||||||
facets.value = getArrayOrString(route.query.f)
|
break
|
||||||
}
|
case 'follows':
|
||||||
if (route.query.g) {
|
sortType.value.display = 'Follow count'
|
||||||
orFacets.value = getArrayOrString(route.query.g)
|
break
|
||||||
}
|
}
|
||||||
if (route.query.v) {
|
}
|
||||||
selectedVersions.value = getArrayOrString(route.query.v)
|
|
||||||
}
|
|
||||||
if (route.query.l) {
|
|
||||||
onlyOpenSource.value = route.query.l === 'true'
|
|
||||||
}
|
|
||||||
if (route.query.h) {
|
|
||||||
showSnapshots.value = route.query.h === 'true'
|
|
||||||
}
|
|
||||||
if (route.query.e) {
|
|
||||||
selectedEnvironments.value = getArrayOrString(route.query.e)
|
|
||||||
}
|
|
||||||
if (route.query.s) {
|
|
||||||
sortType.value.name = route.query.s
|
|
||||||
|
|
||||||
switch (sortType.value.name) {
|
if (route.query.m) {
|
||||||
case 'relevance':
|
maxResults.value = route.query.m
|
||||||
sortType.value.display = 'Relevance'
|
}
|
||||||
break
|
if (route.query.o) {
|
||||||
case 'downloads':
|
currentPage.value = Math.ceil(route.query.o / maxResults.value) + 1
|
||||||
sortType.value.display = 'Downloads'
|
}
|
||||||
break
|
|
||||||
case 'newest':
|
projectType.value = data.$tag.projectTypes.find(
|
||||||
sortType.value.display = 'Recently published'
|
(x) => x.id === route.path.substring(1, route.path.length - 1)
|
||||||
break
|
)
|
||||||
case 'updated':
|
|
||||||
sortType.value.display = 'Recently updated'
|
const noLoad = ref(false)
|
||||||
break
|
const {
|
||||||
case 'follows':
|
data: rawResults,
|
||||||
sortType.value.display = 'Follow count'
|
refresh: refreshSearch,
|
||||||
break
|
pending: searchLoading,
|
||||||
}
|
} = useLazyFetch(
|
||||||
|
() => {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const base = process.server ? config.apiBaseUrl : config.public.apiBaseUrl
|
||||||
|
|
||||||
|
const params = [`limit=${maxResults.value}`, `index=${sortType.value.name}`]
|
||||||
|
|
||||||
|
if (query.value.length > 0) {
|
||||||
|
params.push(`query=${encodeURIComponent(query.value.replace(/ /g, '+'))}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route.query.m) {
|
if (
|
||||||
maxResults.value = route.query.m
|
facets.value.length > 0 ||
|
||||||
}
|
orFacets.value.length > 0 ||
|
||||||
if (route.query.o) {
|
selectedVersions.value.length > 0 ||
|
||||||
currentPage.value = Math.ceil(route.query.o / maxResults.value) + 1
|
selectedEnvironments.value.length > 0 ||
|
||||||
}
|
projectType.value
|
||||||
|
) {
|
||||||
projectType.value = data.$tag.projectTypes.find(
|
let formattedFacets = []
|
||||||
(x) => x.id === route.path.substring(1, route.path.length - 1)
|
for (const facet of facets.value) {
|
||||||
)
|
formattedFacets.push([facet])
|
||||||
|
|
||||||
const noLoad = ref(false)
|
|
||||||
const {
|
|
||||||
data: rawResults,
|
|
||||||
refresh: refreshSearch,
|
|
||||||
pending: searchLoading,
|
|
||||||
} = useLazyFetch(
|
|
||||||
() => {
|
|
||||||
const config = useRuntimeConfig()
|
|
||||||
const base = process.server ? config.apiBaseUrl : config.public.apiBaseUrl
|
|
||||||
|
|
||||||
const params = [`limit=${maxResults.value}`, `index=${sortType.value.name}`]
|
|
||||||
|
|
||||||
if (query.value.length > 0) {
|
|
||||||
params.push(`query=${query.value.replace(/ /g, '+')}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
facets.value.length > 0 ||
|
|
||||||
orFacets.value.length > 0 ||
|
|
||||||
selectedVersions.value.length > 0 ||
|
|
||||||
selectedEnvironments.value.length > 0 ||
|
|
||||||
projectType.value
|
|
||||||
) {
|
|
||||||
let formattedFacets = []
|
|
||||||
for (const facet of facets.value) {
|
|
||||||
formattedFacets.push([facet])
|
|
||||||
}
|
|
||||||
|
|
||||||
// loaders specifier
|
|
||||||
if (orFacets.value.length > 0) {
|
|
||||||
formattedFacets.push(orFacets.value)
|
|
||||||
} else if (projectType.value.id === 'plugin') {
|
|
||||||
formattedFacets.push(
|
|
||||||
data.$tag.loaderData.allPluginLoaders.map(
|
|
||||||
(x) => `categories:'${encodeURIComponent(x)}'`
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else if (projectType.value.id === 'mod') {
|
|
||||||
formattedFacets.push(
|
|
||||||
data.$tag.loaderData.modLoaders.map((x) => `categories:'${encodeURIComponent(x)}'`)
|
|
||||||
)
|
|
||||||
} else if (projectType.value.id === 'datapack') {
|
|
||||||
formattedFacets.push(
|
|
||||||
data.$tag.loaderData.dataPackLoaders.map(
|
|
||||||
(x) => `categories:'${encodeURIComponent(x)}'`
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedVersions.value.length > 0) {
|
|
||||||
const versionFacets = []
|
|
||||||
for (const facet of selectedVersions.value) {
|
|
||||||
versionFacets.push('versions:' + facet)
|
|
||||||
}
|
|
||||||
formattedFacets.push(versionFacets)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onlyOpenSource.value) {
|
|
||||||
formattedFacets.push(['open_source:true'])
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedEnvironments.value.length > 0) {
|
|
||||||
let environmentFacets = []
|
|
||||||
|
|
||||||
const includesClient = selectedEnvironments.value.includes('client')
|
|
||||||
const includesServer = selectedEnvironments.value.includes('server')
|
|
||||||
if (includesClient && includesServer) {
|
|
||||||
environmentFacets = [['client_side:required'], ['server_side:required']]
|
|
||||||
} else {
|
|
||||||
if (includesClient) {
|
|
||||||
environmentFacets = [
|
|
||||||
['client_side:optional', 'client_side:required'],
|
|
||||||
['server_side:optional', 'server_side:unsupported'],
|
|
||||||
]
|
|
||||||
}
|
|
||||||
if (includesServer) {
|
|
||||||
environmentFacets = [
|
|
||||||
['client_side:optional', 'client_side:unsupported'],
|
|
||||||
['server_side:optional', 'server_side:required'],
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
formattedFacets = [...formattedFacets, ...environmentFacets]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (projectType.value) {
|
|
||||||
formattedFacets.push([`project_type:${projectType.value.actual}`])
|
|
||||||
}
|
|
||||||
|
|
||||||
params.push(`facets=${JSON.stringify(formattedFacets)}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const offset = (currentPage.value - 1) * maxResults.value
|
|
||||||
if (currentPage.value !== 1) {
|
|
||||||
params.push(`offset=${offset}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
let url = 'search'
|
|
||||||
|
|
||||||
if (params.length > 0) {
|
|
||||||
for (let i = 0; i < params.length; i++) {
|
|
||||||
url += i === 0 ? `?${params[i]}` : `&${params[i]}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${base}${url}`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
transform(hits) {
|
|
||||||
noLoad.value = false
|
|
||||||
return hits
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const results = shallowRef(toRaw(rawResults))
|
|
||||||
const pageCount = computed(() =>
|
|
||||||
results.value ? Math.ceil(results.value.total_hits / results.value.limit) : 1
|
|
||||||
)
|
|
||||||
|
|
||||||
const onSearchChange = (newPageNumber) => {
|
|
||||||
noLoad.value = true
|
|
||||||
|
|
||||||
currentPage.value = newPageNumber
|
|
||||||
|
|
||||||
if (query.value === null) {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshSearch()
|
// loaders specifier
|
||||||
|
|
||||||
if (process.client) {
|
|
||||||
const router = useRouter()
|
|
||||||
const obj = getSearchUrl((currentPage.value - 1) * maxResults.value, true)
|
|
||||||
router.replace({ path: route.path, query: obj })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const getSearchUrl = (offset, useObj) => {
|
|
||||||
const queryItems = []
|
|
||||||
const obj = {}
|
|
||||||
|
|
||||||
if (query.value) {
|
|
||||||
queryItems.push(`q=${encodeURIComponent(query.value)}`)
|
|
||||||
obj.q = query.value
|
|
||||||
}
|
|
||||||
if (offset > 0) {
|
|
||||||
queryItems.push(`o=${offset}`)
|
|
||||||
obj.o = offset
|
|
||||||
}
|
|
||||||
if (facets.value.length > 0) {
|
|
||||||
queryItems.push(`f=${encodeURIComponent(facets.value)}`)
|
|
||||||
obj.f = facets.value
|
|
||||||
}
|
|
||||||
if (orFacets.value.length > 0) {
|
if (orFacets.value.length > 0) {
|
||||||
queryItems.push(`g=${encodeURIComponent(orFacets.value)}`)
|
formattedFacets.push(orFacets.value)
|
||||||
obj.g = orFacets.value
|
} else if (projectType.value.id === 'plugin') {
|
||||||
}
|
formattedFacets.push(
|
||||||
if (selectedVersions.value.length > 0) {
|
data.$tag.loaderData.allPluginLoaders.map((x) => `categories:'${encodeURIComponent(x)}'`)
|
||||||
queryItems.push(`v=${encodeURIComponent(selectedVersions.value)}`)
|
)
|
||||||
obj.v = selectedVersions.value
|
} else if (projectType.value.id === 'mod') {
|
||||||
}
|
formattedFacets.push(
|
||||||
if (onlyOpenSource.value) {
|
data.$tag.loaderData.modLoaders.map((x) => `categories:'${encodeURIComponent(x)}'`)
|
||||||
queryItems.push('l=true')
|
)
|
||||||
obj.l = true
|
} else if (projectType.value.id === 'datapack') {
|
||||||
}
|
formattedFacets.push(
|
||||||
if (showSnapshots.value) {
|
data.$tag.loaderData.dataPackLoaders.map((x) => `categories:'${encodeURIComponent(x)}'`)
|
||||||
queryItems.push('h=true')
|
|
||||||
obj.h = true
|
|
||||||
}
|
|
||||||
if (selectedEnvironments.value.length > 0) {
|
|
||||||
queryItems.push(`e=${encodeURIComponent(selectedEnvironments.value)}`)
|
|
||||||
obj.e = selectedEnvironments.value
|
|
||||||
}
|
|
||||||
if (sortType.value.name !== 'relevance') {
|
|
||||||
queryItems.push(`s=${encodeURIComponent(sortType.value.name)}`)
|
|
||||||
obj.s = sortType.value.name
|
|
||||||
}
|
|
||||||
if (maxResults.value !== 20) {
|
|
||||||
queryItems.push(`m=${encodeURIComponent(maxResults.value)}`)
|
|
||||||
obj.m = maxResults.value
|
|
||||||
}
|
|
||||||
|
|
||||||
let url = `${route.path}`
|
|
||||||
|
|
||||||
if (queryItems.length > 0) {
|
|
||||||
url += `?${queryItems[0]}`
|
|
||||||
|
|
||||||
for (let i = 1; i < queryItems.length; i++) {
|
|
||||||
url += `&${queryItems[i]}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return useObj ? obj : url
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
query,
|
|
||||||
results,
|
|
||||||
facets,
|
|
||||||
orFacets,
|
|
||||||
selectedVersions,
|
|
||||||
onlyOpenSource,
|
|
||||||
showSnapshots,
|
|
||||||
selectedEnvironments,
|
|
||||||
sortTypes,
|
|
||||||
sortType,
|
|
||||||
maxResults,
|
|
||||||
currentPage,
|
|
||||||
pageCount,
|
|
||||||
projectType,
|
|
||||||
onSearchChange,
|
|
||||||
getSearchUrl,
|
|
||||||
searchLoading,
|
|
||||||
noLoad,
|
|
||||||
metaDescription,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
categoriesMap() {
|
|
||||||
const categories = {}
|
|
||||||
|
|
||||||
for (const category of this.$sortedCategories) {
|
|
||||||
if (categories[category.header]) {
|
|
||||||
categories[category.header].push(category)
|
|
||||||
} else {
|
|
||||||
categories[category.header] = [category]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const newVals = Object.keys(categories).reduce((obj, key) => {
|
|
||||||
obj[key] = categories[key]
|
|
||||||
return obj
|
|
||||||
}, {})
|
|
||||||
|
|
||||||
return newVals
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
clearFilters() {
|
|
||||||
for (const facet of [...this.facets]) {
|
|
||||||
this.toggleFacet(facet, true)
|
|
||||||
}
|
|
||||||
for (const facet of [...this.orFacets]) {
|
|
||||||
this.toggleOrFacet(facet, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onlyOpenSource = false
|
|
||||||
this.selectedVersions = []
|
|
||||||
this.selectedEnvironments = []
|
|
||||||
this.onSearchChange(1)
|
|
||||||
},
|
|
||||||
toggleFacet(elementName, doNotSendRequest = false) {
|
|
||||||
const index = this.facets.indexOf(elementName)
|
|
||||||
|
|
||||||
if (index !== -1) {
|
|
||||||
this.facets.splice(index, 1)
|
|
||||||
} else {
|
|
||||||
this.facets.push(elementName)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!doNotSendRequest) {
|
|
||||||
this.onSearchChange(1)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toggleOrFacet(elementName, doNotSendRequest) {
|
|
||||||
const index = this.orFacets.indexOf(elementName)
|
|
||||||
if (index !== -1) {
|
|
||||||
this.orFacets.splice(index, 1)
|
|
||||||
} else {
|
|
||||||
if (elementName === 'categories:purpur') {
|
|
||||||
if (!this.orFacets.includes('categories:paper')) {
|
|
||||||
this.orFacets.push('categories:paper')
|
|
||||||
}
|
|
||||||
if (!this.orFacets.includes('categories:spigot')) {
|
|
||||||
this.orFacets.push('categories:spigot')
|
|
||||||
}
|
|
||||||
if (!this.orFacets.includes('categories:bukkit')) {
|
|
||||||
this.orFacets.push('categories:bukkit')
|
|
||||||
}
|
|
||||||
} else if (elementName === 'categories:paper') {
|
|
||||||
if (!this.orFacets.includes('categories:spigot')) {
|
|
||||||
this.orFacets.push('categories:spigot')
|
|
||||||
}
|
|
||||||
if (!this.orFacets.includes('categories:bukkit')) {
|
|
||||||
this.orFacets.push('categories:bukkit')
|
|
||||||
}
|
|
||||||
} else if (elementName === 'categories:spigot') {
|
|
||||||
if (!this.orFacets.includes('categories:bukkit')) {
|
|
||||||
this.orFacets.push('categories:bukkit')
|
|
||||||
}
|
|
||||||
} else if (elementName === 'categories:waterfall') {
|
|
||||||
if (!this.orFacets.includes('categories:bungeecord')) {
|
|
||||||
this.orFacets.push('categories:bungeecord')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.orFacets.push(elementName)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!doNotSendRequest) {
|
|
||||||
this.onSearchChange(1)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toggleEnv(environment, sendRequest) {
|
|
||||||
const index = this.selectedEnvironments.indexOf(environment)
|
|
||||||
if (index !== -1) {
|
|
||||||
this.selectedEnvironments.splice(index, 1)
|
|
||||||
} else {
|
|
||||||
this.selectedEnvironments.push(environment)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sendRequest) {
|
|
||||||
this.onSearchChange(1)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onSearchChangeToTop(newPageNumber) {
|
|
||||||
if (process.client) {
|
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onSearchChange(newPageNumber)
|
|
||||||
},
|
|
||||||
onMaxResultsChange(newPageNumber) {
|
|
||||||
newPageNumber = Math.max(
|
|
||||||
1,
|
|
||||||
Math.min(
|
|
||||||
Math.floor(newPageNumber / (this.maxResults / this.previousMaxResults)),
|
|
||||||
this.pageCount
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
this.previousMaxResults = this.maxResults
|
|
||||||
this.onSearchChange(newPageNumber)
|
|
||||||
},
|
|
||||||
cycleSearchDisplayMode() {
|
|
||||||
this.$cosmetics.searchDisplayMode[this.projectType.id] = this.$cycleValue(
|
|
||||||
this.$cosmetics.searchDisplayMode[this.projectType.id],
|
|
||||||
this.$tag.projectViewModes
|
|
||||||
)
|
|
||||||
saveCosmetics()
|
|
||||||
this.setClosestMaxResults()
|
|
||||||
},
|
|
||||||
setClosestMaxResults() {
|
|
||||||
const view = this.$cosmetics.searchDisplayMode[this.projectType.id]
|
|
||||||
const maxResultsOptions = this.maxResultsForView[view] ?? [20]
|
|
||||||
const currentMax = this.maxResults
|
|
||||||
if (!maxResultsOptions.includes(currentMax)) {
|
|
||||||
this.maxResults = maxResultsOptions.reduce(function (prev, curr) {
|
|
||||||
return Math.abs(curr - currentMax) <= Math.abs(prev - currentMax) ? curr : prev
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
if (selectedVersions.value.length > 0) {
|
||||||
|
const versionFacets = []
|
||||||
|
for (const facet of selectedVersions.value) {
|
||||||
|
versionFacets.push('versions:' + facet)
|
||||||
|
}
|
||||||
|
formattedFacets.push(versionFacets)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlyOpenSource.value) {
|
||||||
|
formattedFacets.push(['open_source:true'])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedEnvironments.value.length > 0) {
|
||||||
|
let environmentFacets = []
|
||||||
|
|
||||||
|
const includesClient = selectedEnvironments.value.includes('client')
|
||||||
|
const includesServer = selectedEnvironments.value.includes('server')
|
||||||
|
if (includesClient && includesServer) {
|
||||||
|
environmentFacets = [['client_side:required'], ['server_side:required']]
|
||||||
|
} else {
|
||||||
|
if (includesClient) {
|
||||||
|
environmentFacets = [
|
||||||
|
['client_side:optional', 'client_side:required'],
|
||||||
|
['server_side:optional', 'server_side:unsupported'],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
if (includesServer) {
|
||||||
|
environmentFacets = [
|
||||||
|
['client_side:optional', 'client_side:unsupported'],
|
||||||
|
['server_side:optional', 'server_side:required'],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
formattedFacets = [...formattedFacets, ...environmentFacets]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (projectType.value) {
|
||||||
|
formattedFacets.push([`project_type:${projectType.value.actual}`])
|
||||||
|
}
|
||||||
|
|
||||||
|
params.push(`facets=${encodeURIComponent(JSON.stringify(formattedFacets))}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const offset = (currentPage.value - 1) * maxResults.value
|
||||||
|
if (currentPage.value !== 1) {
|
||||||
|
params.push(`offset=${offset}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = 'search'
|
||||||
|
|
||||||
|
if (params.length > 0) {
|
||||||
|
for (let i = 0; i < params.length; i++) {
|
||||||
|
url += i === 0 ? `?${params[i]}` : `&${params[i]}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${base}${url}`
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
transform: (hits) => {
|
||||||
|
noLoad.value = false
|
||||||
|
return hits
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const results = shallowRef(toRaw(rawResults))
|
||||||
|
const pageCount = computed(() =>
|
||||||
|
results.value ? Math.ceil(results.value.total_hits / results.value.limit) : 1
|
||||||
|
)
|
||||||
|
|
||||||
|
function onSearchChange(newPageNumber) {
|
||||||
|
noLoad.value = true
|
||||||
|
|
||||||
|
currentPage.value = newPageNumber
|
||||||
|
|
||||||
|
if (query.value === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshSearch()
|
||||||
|
|
||||||
|
if (process.client) {
|
||||||
|
const router = useRouter()
|
||||||
|
const obj = getSearchUrl((currentPage.value - 1) * maxResults.value, true)
|
||||||
|
router.replace({ path: route.path, query: obj })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSearchUrl(offset, useObj) {
|
||||||
|
const queryItems = []
|
||||||
|
const obj = {}
|
||||||
|
|
||||||
|
if (query.value) {
|
||||||
|
queryItems.push(`q=${encodeURIComponent(query.value)}`)
|
||||||
|
obj.q = query.value
|
||||||
|
}
|
||||||
|
if (offset > 0) {
|
||||||
|
queryItems.push(`o=${offset}`)
|
||||||
|
obj.o = offset
|
||||||
|
}
|
||||||
|
if (facets.value.length > 0) {
|
||||||
|
queryItems.push(`f=${encodeURIComponent(facets.value)}`)
|
||||||
|
obj.f = facets.value
|
||||||
|
}
|
||||||
|
if (orFacets.value.length > 0) {
|
||||||
|
queryItems.push(`g=${encodeURIComponent(orFacets.value)}`)
|
||||||
|
obj.g = orFacets.value
|
||||||
|
}
|
||||||
|
if (selectedVersions.value.length > 0) {
|
||||||
|
queryItems.push(`v=${encodeURIComponent(selectedVersions.value)}`)
|
||||||
|
obj.v = selectedVersions.value
|
||||||
|
}
|
||||||
|
if (onlyOpenSource.value) {
|
||||||
|
queryItems.push('l=true')
|
||||||
|
obj.l = true
|
||||||
|
}
|
||||||
|
if (showSnapshots.value) {
|
||||||
|
queryItems.push('h=true')
|
||||||
|
obj.h = true
|
||||||
|
}
|
||||||
|
if (selectedEnvironments.value.length > 0) {
|
||||||
|
queryItems.push(`e=${encodeURIComponent(selectedEnvironments.value)}`)
|
||||||
|
obj.e = selectedEnvironments.value
|
||||||
|
}
|
||||||
|
if (sortType.value.name !== 'relevance') {
|
||||||
|
queryItems.push(`s=${encodeURIComponent(sortType.value.name)}`)
|
||||||
|
obj.s = sortType.value.name
|
||||||
|
}
|
||||||
|
if (maxResults.value !== 20) {
|
||||||
|
queryItems.push(`m=${encodeURIComponent(maxResults.value)}`)
|
||||||
|
obj.m = maxResults.value
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = `${route.path}`
|
||||||
|
|
||||||
|
if (queryItems.length > 0) {
|
||||||
|
url += `?${queryItems[0]}`
|
||||||
|
|
||||||
|
for (let i = 1; i < queryItems.length; i++) {
|
||||||
|
url += `&${queryItems[i]}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return useObj ? obj : url
|
||||||
|
}
|
||||||
|
|
||||||
|
const categoriesMap = computed(() => {
|
||||||
|
const categories = {}
|
||||||
|
|
||||||
|
for (const category of data.$sortedCategories) {
|
||||||
|
if (categories[category.header]) {
|
||||||
|
categories[category.header].push(category)
|
||||||
|
} else {
|
||||||
|
categories[category.header] = [category]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.keys(categories).reduce((obj, key) => {
|
||||||
|
obj[key] = categories[key]
|
||||||
|
return obj
|
||||||
|
}, {})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function clearFilters() {
|
||||||
|
for (const facet of [...facets.value]) {
|
||||||
|
toggleFacet(facet, true)
|
||||||
|
}
|
||||||
|
for (const facet of [...orFacets.value]) {
|
||||||
|
toggleOrFacet(facet, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
onlyOpenSource.value = false
|
||||||
|
selectedVersions.value = []
|
||||||
|
selectedEnvironments.value = []
|
||||||
|
onSearchChange(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleFacet(elementName, doNotSendRequest = false) {
|
||||||
|
const index = facets.value.indexOf(elementName)
|
||||||
|
|
||||||
|
if (index !== -1) {
|
||||||
|
facets.value.splice(index, 1)
|
||||||
|
} else {
|
||||||
|
facets.value.push(elementName)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!doNotSendRequest) {
|
||||||
|
onSearchChange(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleOrFacet(elementName, doNotSendRequest) {
|
||||||
|
const index = orFacets.value.indexOf(elementName)
|
||||||
|
if (index !== -1) {
|
||||||
|
orFacets.value.splice(index, 1)
|
||||||
|
} else {
|
||||||
|
if (elementName === 'categories:purpur') {
|
||||||
|
if (!orFacets.value.includes('categories:paper')) {
|
||||||
|
orFacets.value.push('categories:paper')
|
||||||
|
}
|
||||||
|
if (!orFacets.value.includes('categories:spigot')) {
|
||||||
|
orFacets.value.push('categories:spigot')
|
||||||
|
}
|
||||||
|
if (!orFacets.value.includes('categories:bukkit')) {
|
||||||
|
orFacets.value.push('categories:bukkit')
|
||||||
|
}
|
||||||
|
} else if (elementName === 'categories:paper') {
|
||||||
|
if (!orFacets.value.includes('categories:spigot')) {
|
||||||
|
orFacets.value.push('categories:spigot')
|
||||||
|
}
|
||||||
|
if (!orFacets.value.includes('categories:bukkit')) {
|
||||||
|
orFacets.value.push('categories:bukkit')
|
||||||
|
}
|
||||||
|
} else if (elementName === 'categories:spigot') {
|
||||||
|
if (!orFacets.value.includes('categories:bukkit')) {
|
||||||
|
orFacets.value.push('categories:bukkit')
|
||||||
|
}
|
||||||
|
} else if (elementName === 'categories:waterfall') {
|
||||||
|
if (!orFacets.value.includes('categories:bungeecord')) {
|
||||||
|
orFacets.value.push('categories:bungeecord')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
orFacets.value.push(elementName)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!doNotSendRequest) {
|
||||||
|
onSearchChange(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleEnv(environment, sendRequest) {
|
||||||
|
const index = selectedEnvironments.value.indexOf(environment)
|
||||||
|
if (index !== -1) {
|
||||||
|
selectedEnvironments.value.splice(index, 1)
|
||||||
|
} else {
|
||||||
|
selectedEnvironments.value.push(environment)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sendRequest) {
|
||||||
|
onSearchChange(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSearchChangeToTop(newPageNumber) {
|
||||||
|
if (process.client) {
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||||
|
}
|
||||||
|
|
||||||
|
onSearchChange(newPageNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
function cycleSearchDisplayMode() {
|
||||||
|
data.$cosmetics.searchDisplayMode[projectType.value.id] = data.$cycleValue(
|
||||||
|
data.$cosmetics.searchDisplayMode[projectType.value.id],
|
||||||
|
data.$tag.projectViewModes
|
||||||
|
)
|
||||||
|
saveCosmetics()
|
||||||
|
setClosestMaxResults()
|
||||||
|
}
|
||||||
|
|
||||||
|
const previousMaxResults = ref(20)
|
||||||
|
const maxResultsForView = ref({
|
||||||
|
list: [5, 10, 15, 20, 50, 100],
|
||||||
|
grid: [6, 12, 18, 24, 48, 96],
|
||||||
|
gallery: [6, 10, 16, 20, 50, 100],
|
||||||
|
})
|
||||||
|
|
||||||
|
function onMaxResultsChange(newPageNumber) {
|
||||||
|
newPageNumber = Math.max(
|
||||||
|
1,
|
||||||
|
Math.min(
|
||||||
|
Math.floor(newPageNumber / (maxResults.value / previousMaxResults.value)),
|
||||||
|
pageCount.value
|
||||||
|
)
|
||||||
|
)
|
||||||
|
previousMaxResults.value = maxResults.value
|
||||||
|
onSearchChange(newPageNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setClosestMaxResults() {
|
||||||
|
const view = data.$cosmetics.searchDisplayMode[projectType.value.id]
|
||||||
|
const maxResultsOptions = maxResultsForView.value[view] ?? [20]
|
||||||
|
const currentMax = maxResults.value
|
||||||
|
if (!maxResultsOptions.includes(currentMax)) {
|
||||||
|
maxResults.value = maxResultsOptions.reduce(function (prev, curr) {
|
||||||
|
return Math.abs(curr - currentMax) <= Math.abs(prev - currentMax) ? curr : prev
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
482
patches/markdown-it+13.0.1.patch
Normal file
482
patches/markdown-it+13.0.1.patch
Normal file
File diff suppressed because one or more lines are too long
1335
pnpm-lock.yaml
generated
1335
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
9
wrangler.toml
Normal file
9
wrangler.toml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
name = "knossos"
|
||||||
|
main = "./.output/server/index.mjs"
|
||||||
|
workers_dev = true
|
||||||
|
compatibility_date = "2022-07-12"
|
||||||
|
account_id = "9ddae624c98677d68d93df6e524a6061"
|
||||||
|
node_compat = true
|
||||||
|
|
||||||
|
[site]
|
||||||
|
bucket = ".output/public"
|
||||||
Reference in New Issue
Block a user