diff --git a/pkgs/LoadMore/.npmignore b/pkgs/Scripts/.npmignore similarity index 100% rename from pkgs/LoadMore/.npmignore rename to pkgs/Scripts/.npmignore diff --git a/pkgs/LoadMore/README.md b/pkgs/Scripts/README.md similarity index 100% rename from pkgs/LoadMore/README.md rename to pkgs/Scripts/README.md diff --git a/pkgs/LoadMore/cmd.mjs b/pkgs/Scripts/cmd.mjs similarity index 81% rename from pkgs/LoadMore/cmd.mjs rename to pkgs/Scripts/cmd.mjs index 09213a2..f35e7d7 100644 --- a/pkgs/LoadMore/cmd.mjs +++ b/pkgs/Scripts/cmd.mjs @@ -5,13 +5,12 @@ const bundleFile = async () => { const getPkg = JSON.parse(readFileSync('./package.json')) const Opts = { - entryPoints: ['src/index.ts'], + entryPoints: ['src/loadmore/index.ts', 'src/gisqus.ts'], bundle: true, minify: true, outdir: 'dist', platform: 'node', format: 'esm', - outExtension: { '.js': '.mjs' }, external: [ 'vite', ...Object.keys(getPkg.dependencies || {}), @@ -19,9 +18,6 @@ const bundleFile = async () => { ], } - await build(Opts) - Opts.format = 'cjs' - Opts.outExtension = { '.js': '.cjs' } await build(Opts) const replaceHtml = (PATH) => { @@ -30,8 +26,7 @@ const bundleFile = async () => { writeFileSync(PATH, result) } - replaceHtml('./dist/index.mjs') - replaceHtml('./dist/index.cjs') + replaceHtml('./dist/loadmore/index.js') } const isBuild = process.env.BUILD === 'true' diff --git a/pkgs/LoadMore/package.json b/pkgs/Scripts/package.json similarity index 80% rename from pkgs/LoadMore/package.json rename to pkgs/Scripts/package.json index 1079eb7..1bc0668 100644 --- a/pkgs/LoadMore/package.json +++ b/pkgs/Scripts/package.json @@ -1,5 +1,5 @@ { - "name": "loadmore", + "name": "myscript", "version": "1.0.0", "description": "vite plugin for html literal and ", "scripts": { @@ -25,13 +25,13 @@ "module": "dist/index.js", "types": "dist/index.d.ts", "exports": { - ".": { - "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", - "import": "./dist/index.mjs" + "./loadmore": { + "types": "./dist/loadmore/index.d.ts", + "import": "./dist/loadmore/index.js" }, - "./type": { - "types": "./dist/types.d.ts" + "./giscus": { + "types": "./dist/gisqus.d.ts", + "import": "./dist/gisqus.js" } }, "files": [ diff --git a/pkgs/Scripts/src/gisqus.ts b/pkgs/Scripts/src/gisqus.ts new file mode 100644 index 0000000..642c485 --- /dev/null +++ b/pkgs/Scripts/src/gisqus.ts @@ -0,0 +1,44 @@ +;(function () { + let isClick = false + const ELEMENT_COMMENT = document.getElementById('content-comment')! + const BtnToggle = document.getElementById('toggle-comment')! + BtnToggle.onclick = () => { + ELEMENT_COMMENT.classList.toggle('hidden') + let isHide = true + if (isHide) { + isClick = false + BtnToggle.innerHTML = 'Hide Comments' + } else { + isClick = true + BtnToggle.innerHTML = 'Show Comments' + } + if (!isClick) { + isClick = true + const REPO = 'alifprihantoro/pawartatech' + const REPO_ID = 'R_kgDONCtgBQ' + const DATA_CATEGORY = 'Gisqus' + const CATEGORY_ID = 'DIC_kwDONCtgBc4CkVdt' + const DATA_MAPPING = 'pathname' + const isLazy = true + const DATA_THEMES = 'dark' + const script = document.createElement('script') + script.src = 'https://giscus.app/client.js' + script.setAttribute('data-repo', REPO) + script.setAttribute('data-repo-id', REPO_ID) + script.setAttribute('data-category', DATA_CATEGORY) + script.setAttribute('data-category-id', CATEGORY_ID) + script.setAttribute('data-mapping', DATA_MAPPING) + script.setAttribute('data-strict', '1') + script.setAttribute('data-reactions-enabled', '1') + script.setAttribute('data-emit-metadata', '1') + script.setAttribute('data-input-position', 'top') + script.setAttribute('data-theme', DATA_THEMES) + if (isLazy) { + script.setAttribute('data-loading', 'lazy') + } + script.setAttribute('data-lang', 'id') + script.setAttribute('crossorigin', 'anonymous') + ELEMENT_COMMENT.appendChild(script) + } + } +})() diff --git a/pkgs/LoadMore/src/Render.ts b/pkgs/Scripts/src/loadmore/Render.ts similarity index 100% rename from pkgs/LoadMore/src/Render.ts rename to pkgs/Scripts/src/loadmore/Render.ts diff --git a/pkgs/LoadMore/src/event.ts b/pkgs/Scripts/src/loadmore/event.ts similarity index 100% rename from pkgs/LoadMore/src/event.ts rename to pkgs/Scripts/src/loadmore/event.ts diff --git a/pkgs/LoadMore/src/getFeed.ts b/pkgs/Scripts/src/loadmore/getFeed.ts similarity index 100% rename from pkgs/LoadMore/src/getFeed.ts rename to pkgs/Scripts/src/loadmore/getFeed.ts diff --git a/pkgs/LoadMore/src/index.ts b/pkgs/Scripts/src/loadmore/index.ts similarity index 100% rename from pkgs/LoadMore/src/index.ts rename to pkgs/Scripts/src/loadmore/index.ts diff --git a/pkgs/LoadMore/src/vite-env.d.ts b/pkgs/Scripts/src/loadmore/vite-env.d.ts similarity index 100% rename from pkgs/LoadMore/src/vite-env.d.ts rename to pkgs/Scripts/src/loadmore/vite-env.d.ts diff --git a/pkgs/LoadMore/tsconfig.json b/pkgs/Scripts/tsconfig.json similarity index 100% rename from pkgs/LoadMore/tsconfig.json rename to pkgs/Scripts/tsconfig.json diff --git a/pkgs/ui/package.json b/pkgs/ui/package.json index fbc0ed4..a925b4c 100644 --- a/pkgs/ui/package.json +++ b/pkgs/ui/package.json @@ -39,6 +39,7 @@ "@muryp/vite-html": "^1.0.6", "@storybook/addon-console": "^3.0.0", "@storybook/test": "^8.3.6", - "configs": "workspace:^" + "configs": "workspace:^", + "myscript": "workspace:^" } } diff --git a/pkgs/ui/src/assets/css/main.css b/pkgs/ui/src/assets/css/main.css index 295cffb..b580abd 100644 --- a/pkgs/ui/src/assets/css/main.css +++ b/pkgs/ui/src/assets/css/main.css @@ -1,7 +1,6 @@ @tailwind base; @tailwind components; @tailwind utilities; - /* default */ h1, h2, diff --git a/pkgs/ui/src/view/pages/post/index.ts b/pkgs/ui/src/view/pages/post/index.ts index 5cf5da4..b5b0100 100644 --- a/pkgs/ui/src/view/pages/post/index.ts +++ b/pkgs/ui/src/view/pages/post/index.ts @@ -1,3 +1,4 @@ +import Scripts from 'myscript/giscus?raw' export default function Post({ Content, title, @@ -20,10 +21,19 @@ export default function Post({ ${Content} + + + ${NextPrev}

Baca Juga :

${RelatedPost}
` -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8bb4fb2..8aba5f0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,7 +23,7 @@ importers: version: 8.2.2 daisyui: specifier: ^4.12.14 - version: 4.12.14(postcss@8.4.49) + version: 4.12.14(postcss@8.4.47) eslint: specifier: ^9.14.0 version: 9.14.0(jiti@1.21.6) @@ -58,6 +58,24 @@ importers: specifier: ^2.1.2 version: 2.1.4(@types/node@22.7.7)(terser@5.36.0) + pkgs/Scripts: + devDependencies: + configs: + specifier: workspace:^ + version: link:../configs + esbuild: + specifier: 0.20.1 + version: 0.20.1 + ui: + specifier: workspace:^ + version: link:../ui + vite: + specifier: ^5.4.8 + version: 5.4.11(@types/node@22.7.7)(terser@5.36.0) + vitest: + specifier: ^2.1.2 + version: 2.1.4(@types/node@22.7.7)(terser@5.36.0) + pkgs/configs: {} pkgs/ui: @@ -74,6 +92,9 @@ importers: configs: specifier: workspace:^ version: link:../configs + myscript: + specifier: workspace:^ + version: link:../Scripts devDependencies: '@chromatic-com/storybook': specifier: ^1.9.0 @@ -159,9 +180,9 @@ importers: astro: specifier: ^4.16.12 version: 4.16.12(@types/node@22.7.7)(rollup@4.26.0)(terser@5.36.0)(typescript@5.6.3) - loadmore: + myscript: specifier: workspace:^ - version: link:../../pkgs/LoadMore + version: link:../../pkgs/Scripts tailwindcss: specifier: ^3.4.14 version: 3.4.14 @@ -5657,13 +5678,13 @@ snapshots: chai: 5.1.2 tinyrainbow: 1.2.0 - '@vitest/mocker@2.1.4(vite@5.4.9(@types/node@22.7.7)(terser@5.36.0))': + '@vitest/mocker@2.1.4(vite@5.4.11(@types/node@22.7.7)(terser@5.36.0))': dependencies: '@vitest/spy': 2.1.4 estree-walker: 3.0.3 magic-string: 0.30.12 optionalDependencies: - vite: 5.4.9(@types/node@22.7.7)(terser@5.36.0) + vite: 5.4.11(@types/node@22.7.7)(terser@5.36.0) '@vitest/pretty-format@2.0.5': dependencies: @@ -6226,12 +6247,12 @@ snapshots: culori@3.3.0: {} - daisyui@4.12.14(postcss@8.4.49): + daisyui@4.12.14(postcss@8.4.47): dependencies: css-selector-tokenizer: 0.8.0 culori: 3.3.0 picocolors: 1.1.1 - postcss-js: 4.0.1(postcss@8.4.49) + postcss-js: 4.0.1(postcss@8.4.47) transitivePeerDependencies: - postcss @@ -7724,11 +7745,6 @@ snapshots: camelcase-css: 2.0.1 postcss: 8.4.47 - postcss-js@4.0.1(postcss@8.4.49): - dependencies: - camelcase-css: 2.0.1 - postcss: 8.4.49 - postcss-load-config@4.0.2(postcss@8.4.47): dependencies: lilconfig: 3.1.2 @@ -8564,7 +8580,7 @@ snapshots: cac: 6.7.14 debug: 4.3.7 pathe: 1.1.2 - vite: 5.4.9(@types/node@22.7.7)(terser@5.36.0) + vite: 5.4.11(@types/node@22.7.7)(terser@5.36.0) transitivePeerDependencies: - '@types/node' - less @@ -8603,7 +8619,7 @@ snapshots: vitest@2.1.4(@types/node@22.7.7)(terser@5.36.0): dependencies: '@vitest/expect': 2.1.4 - '@vitest/mocker': 2.1.4(vite@5.4.9(@types/node@22.7.7)(terser@5.36.0)) + '@vitest/mocker': 2.1.4(vite@5.4.11(@types/node@22.7.7)(terser@5.36.0)) '@vitest/pretty-format': 2.1.4 '@vitest/runner': 2.1.4 '@vitest/snapshot': 2.1.4 @@ -8619,7 +8635,7 @@ snapshots: tinyexec: 0.3.1 tinypool: 1.0.1 tinyrainbow: 1.2.0 - vite: 5.4.9(@types/node@22.7.7)(terser@5.36.0) + vite: 5.4.11(@types/node@22.7.7)(terser@5.36.0) vite-node: 2.1.4(@types/node@22.7.7)(terser@5.36.0) why-is-node-running: 2.3.0 optionalDependencies: diff --git a/web/blogger/package.json b/web/blogger/package.json index daecd49..6890e5f 100644 --- a/web/blogger/package.json +++ b/web/blogger/package.json @@ -13,7 +13,7 @@ "@astrojs/check": "^0.9.4", "@astrojs/tailwind": "^5.1.2", "astro": "^4.16.12", - "loadmore": "workspace:^", + "myscript": "workspace:^", "tailwindcss": "^3.4.14", "typescript": "^5.6.3", "ui": "workspace:^" diff --git a/web/blogger/src/component/pages/List.ts b/web/blogger/src/component/pages/List.ts index b1b4b7e..f2fde2b 100644 --- a/web/blogger/src/component/pages/List.ts +++ b/web/blogger/src/component/pages/List.ts @@ -1,4 +1,4 @@ -import script from 'loadmore?raw' +import script from 'myscript/loadmore?raw' export default html`
@@ -9,4 +9,4 @@ export default html` ${script} //]]> -` +` \ No newline at end of file