Git Product home page Git Product logo

blogview's People

Contributors

github-actions[bot] avatar mkizka avatar

Stargazers

 avatar  avatar

Watchers

 avatar

blogview's Issues

blogview CLIのWindows環境でのパス解決について

blogviewのCLIツールにおいてWindows環境で使用すると、正しくentryを作っていてもプレビューのページ http://localhost:8000Cannot GET / を返すという現象に遭遇しました。
同様に blogview -vpkg.version を拾えないという問題が発生していることもわかり、勝手ながら問題調査をしました。

結論としてファイルパスの解決に問題があり、現在のコードだとWindowsの場合、先頭が /C: などで始まってしまい不正なパスとなっているようでした。
解決策としては現在はurlモジュールの fileURLToPath() を使って変換をすることが推奨のようです。
nodejs/node#28114

Linuxでの動作確認はしてないので、あくまで当方ではWindows上のみの動作確認となるのですが、よければ以下の修正を取り込んでいただければと思います。
0001-Change-to-get-filepath-using-fileURLToPath.patch

diff --git a/packages/blogview/src/server/utils/helper.ts b/packages/blogview/src/server/utils/helper.ts
index e35ca56..265c2d7 100644
--- a/packages/blogview/src/server/utils/helper.ts
+++ b/packages/blogview/src/server/utils/helper.ts
@@ -1,5 +1,6 @@
 import fs from "fs";
 import path from "path";
+import { fileURLToPath } from 'node:url';
 
 export function loadJson(filepath: string) {
   try {
@@ -10,7 +11,7 @@ export function loadJson(filepath: string) {
   }
 }
 
-const dirname = path.dirname(new URL(import.meta.url).pathname);
+const dirname = path.dirname(fileURLToPath(import.meta.url));
 
 const pkgRootDir = path.join(dirname, "..", "..", "..");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.