Skip to content

Commit

Permalink
feat: add language locale plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Oct 24, 2024
1 parent d60e76c commit 0189195
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 11 deletions.
69 changes: 64 additions & 5 deletions data/plugins.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,76 @@
- id: "artalk-plugin-auth"
name: "Auth Plugin"
description: "Provide user authentication and 3rd party login support."
github_repo: "ArtalkJS/Artalk"
npm_package: "@artalk/plugin-auth"
author_name: "Artalk"
author_link: "https://github.com/ArtalkJS/Artalk"
donate_link: "https://buymeacoffee.com/artalk"

- id: "artalk-plugin-katex"
name: "KaTeX Integration"
description: "Render math formulas with KaTeX"
description: "Integrate existing KaTeX library into Artalk."
github_repo: "ArtalkJS/Artalk"
npm_package: "@artalk/plugin-katex"
author_name: "Artalk"
author_link: "https://github.com/ArtalkJS/Artalk"
donate_link: "https://buymeacoffee.com/artalk"

- id: "artalk-plugin-auth"
name: "Auth Plugin"
description: "3rd party social login support"
- id: "artalk-plugin-lightbox"
name: "Lightbox Plugin"
description: "Integrate existing lightbox libraries into Artalk."
github_repo: "ArtalkJS/Artalk"
npm_package: "@artalk/plugin-auth"
npm_package: "@artalk/plugin-lightbox"
author_name: "Artalk"
author_link: "https://github.com/ArtalkJS/Artalk"
donate_link: "https://buymeacoffee.com/artalk"

- id: "artalk-locale-zh-tw"
name: "Locale Plugin (zh-TW)"
description: "Traditional Chinese locale for Artalk."
github_repo: "ArtalkJS/Artalk"
npm_package: "artalk"
source_main: "dist/i18n/zh-TW.js"
author_name: "Artalk"
author_link: "https://github.com/ArtalkJS/Artalk"
donate_link: "https://buymeacoffee.com/artalk"

- id: "artalk-locale-fr"
name: "Locale Plugin (fr)"
description: "French locale for Artalk."
github_repo: "ArtalkJS/Artalk"
npm_package: "artalk"
source_main: "dist/i18n/fr.js"
author_name: "Artalk"
author_link: "https://github.com/ArtalkJS/Artalk"
donate_link: "https://buymeacoffee.com/artalk"

- id: "artalk-locale-ja"
name: "Locale Plugin (ja)"
description: "Japanese locale for Artalk."
github_repo: "ArtalkJS/Artalk"
npm_package: "artalk"
source_main: "dist/i18n/ja.js"
author_name: "Artalk"
author_link: "https://github.com/ArtalkJS/Artalk"
donate_link: "https://buymeacoffee.com/artalk"

- id: "artalk-locale-ko"
name: "Locale Plugin (ko)"
description: "Korean locale for Artalk."
github_repo: "ArtalkJS/Artalk"
npm_package: "artalk"
source_main: "dist/i18n/ko.js"
author_name: "Artalk"
author_link: "https://github.com/ArtalkJS/Artalk"
donate_link: "https://buymeacoffee.com/artalk"

- id: "artalk-locale-ru"
name: "Locale Plugin (ru)"
description: "Russian locale for Artalk."
github_repo: "ArtalkJS/Artalk"
npm_package: "artalk"
source_main: "dist/i18n/ru.js"
author_name: "Artalk"
author_link: "https://github.com/ArtalkJS/Artalk"
donate_link: "https://buymeacoffee.com/artalk"
1 change: 1 addition & 0 deletions scripts/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface LocalEntry {
description: string
github_repo: string
npm_package: string
source_main?: string
author_name: string
author_link: string
donate_link?: string
Expand Down
18 changes: 12 additions & 6 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const generateSRIFromURL = async (url: string, algorithm: string = 'sha512'): Pr

const extractMinArtalkClientVersion = (pkgData: any): string => {
if (!pkgData) return ''
if (pkgData['name'] === 'artalk' && pkgData['version']) return pkgData['version']
const minVersion = pkgData['peerDependencies']['artalk']
if (!minVersion) return ''
return minVersion.replace(/[^0-9.]/g, '')
Expand Down Expand Up @@ -116,7 +117,7 @@ const buildRegistryEntry = async (
repo_name: srcEntry.github_repo,
repo_link: `https://github.com/${srcEntry.github_repo}`,
npm_name: srcEntry.npm_package,
verified: srcEntry.npm_package.startsWith('@artalk/'),
verified: srcEntry.npm_package.startsWith('@artalk/') || srcEntry.npm_package === 'artalk',

version: cacheEntry?.version || '',
source: cacheEntry?.source || '',
Expand All @@ -134,13 +135,18 @@ const buildRegistryEntry = async (

// Update the entry with the latest version
const npmPkgData = npmInfo['versions'][version]
const mainFile = String(npmPkgData['main']).replace(/^(\.\/|\/)/, '')

let mainFile = srcEntry.source_main
if (!mainFile) {
console.error(
`${pc.red('[FAIL]')} ${pc.bold(srcEntry.npm_package)} - No main file found in package.json`,
)
return null
mainFile = String(npmPkgData['main'])
if (!mainFile) {
console.error(
`${pc.red('[FAIL]')} ${pc.bold(srcEntry.npm_package)} - No main file found in package.json`,
)
return null
}
}
mainFile = mainFile.replace(/^(\.\/|\/)/, '')

const cdnBase = `https://cdn.jsdelivr.net/npm/${srcEntry.npm_package}@${version}`
const source = `${cdnBase}/${mainFile}`
Expand Down

0 comments on commit 0189195

Please sign in to comment.