gethyas / doks

Everything you need to build a stellar documentation website. Fast, accessible, and easy to use.
https://getdoks.org
MIT License
1.99k stars 352 forks source link

imge url not correct if baseurl defined #1218

Open simonstumpf opened 2 months ago

simonstumpf commented 2 months ago

Description

When building with a baseUrl (https://myservice.test.ch/abc/ in my case), the image paths don't seem quiet right. The links are then: <img src=https://myservice.test.ch/abc/abc/docs/artifactory/art.... As you can see /abc is duplicated in the path (if this duplication is removed, it works fine).

Steps to reproduce

define a baseurl with a subpath and use some local pictures. ![myPicutre](artifactory-user-passwordgen.png)

Expected result

the baseurl should be correct applied and not twice.

Actual result

the baseurl got applied twice https://myservice.test.ch/abc/abc/

Environment

Paste the information here as shown by npm run info

> test@0.0.0 preinfo
> npm version

{
  test: '0.0.0',
  npm: '10.2.0',
  node: '21.1.0',
  acorn: '8.10.0',
  ada: '2.7.2',
  ares: '1.20.1',
  base64: '0.5.0',
  brotli: '1.1.0',
  cjs_module_lexer: '1.2.2',
  cldr: '43.1',
  icu: '73.2',
  llhttp: '9.1.2',
  modules: '120',
  napi: '9',
  nghttp2: '1.57.0',
  openssl: '3.1.3',
  simdutf: '3.2.18',
  tz: '2023c',
  undici: '5.26.4',
  unicode: '15.0',
  uv: '1.46.0',
  uvwasi: '0.0.19',
  v8: '11.8.172.15-node.14',
  zlib: '1.2.12'
}

> test@0.0.0 info
> npm list

test@0.0.0 /Users/simonstumpf/raiffeisen/git/pace-customer-docs
├── @hyas/doks-core@1.4.1
├── @hyas/images@3.1.0
├── @hyas/inline-svg@1.0.5
├── @hyas/seo@2.2.0
├── @tabler/icons@2.47.0
├── exec-bin@1.0.0
├── gethyas@2.2.2
├── hugo-installer@4.0.1
└── shx@0.3.4

> test@0.0.0 postinfo
> exec-bin node_modules/.bin/hugo/hugo version

hugo v0.123.7-312735366b20d64bd61bff8627f593749f86c964+extended darwin/amd64 BuildDate=2024-03-01T16:16:06Z VendorInfo=gohugoio
h-enk commented 2 months ago

In config/_default/hugo.toml with

baseurl = "http://localhost/"

running

pnpm dev --baseURL="http://localhost/subdir/"

works for me OK

Snag_a7ed028

simonstumpf commented 2 months ago

I agree that works. But if I execute npm run build (baseurl="https://myservice.test.ch/abc/" in production/config.toml), the generated public folder holds these incorrect URLs:

<img src=https://myservice.test.ch/abc/abc/docs/artifactory/artifactory-overview_hu1dbfdd588fb0cc2f17a368000f94ac4d_78905_1897x751_resize_q85_h2_lanczos_3.webp width=1897 height=751 decoding=async fetchpriority=auto loading=lazy alt="Manage Permission" id=h-rh-i-2></p>
h-enk commented 2 months ago

Yes, you'll also need publishDir. In config/production/hugo.toml, set:

# Overrides for production environment
baseurl = "http://172.21.64.1:8080/subdir/"
publishDir= "/public/subdir/"

Snag_d0b3c5c