log4brains icon indicating copy to clipboard operation
log4brains copied to clipboard

links in index.html does not contain `.html` suffix, but generated html files has

Open dawncold opened this issue 4 years ago • 3 comments
trafficstars

Bug Report

Description

links in index.html does not contain .html suffix, but generated html files has.

Steps to Reproduce

log4brains build -o public

Expected Behavior

should generated links with .html suffix

Context

Environment

  • Log4brains version: (v1.0.0-beta.11)
  • Node.js version:
  • OS and its version:
  • Browser information: Chrome latest

Possible Solution

found this question: https://stackoverflow.com/questions/62867105/how-to-deal-with-nextjs-exporting-files-with-html-extension-but-inlink-there

maybe we should add this for Next framework.

dawncold avatar Jul 19 '21 08:07 dawncold

At a basic level, setting trailingSlash: true, fixes the issue for me. As noted in the stack overflow threads, it does mean ADRs are rendered as directories, such as http://localhost/adr/0001-record-architecture-decisions/. However, that could actually be a good thing if we get inline images working, because then those assets could be included in the ADR path.

deviantintegral avatar Oct 15 '21 13:10 deviantintegral

How do you enable that?

@deviantintegral

fire avatar Jan 09 '22 10:01 fire

You can set it in next.config.js: https://nextjs.org/docs/api-reference/next.config.js/trailing-slash

deviantintegral avatar Jan 09 '22 23:01 deviantintegral

For anyone coming to this issue looking to apply this fix, you can use patch-package while we wait for this change to be merged:

The autogenerated output from patch-package is below :)


Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @log4brains/[email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@log4brains/web/dist/next.config.js b/node_modules/@log4brains/web/dist/next.config.js
index a5dd2e9..4d14fab 100644
--- a/node_modules/@log4brains/web/dist/next.config.js
+++ b/node_modules/@log4brains/web/dist/next.config.js
@@ -13,6 +13,16 @@ module.exports = withBundleAnalyzer({
   reactStrictMode: true,
   target: "serverless",
   poweredByHeader: false,
+  /**
+   * This patch is to ensure that next outputs page/index.html instead of page.html
+   * Without this, links to pages other than the index file will not work on s3
+   * 
+   * without:
+   *   .log4brains/out/adr/2022022-document-frontend-infra-decisions.html
+   * with:
+   *   .log4brains/out/adr/2022022-document-frontend-infra-decisions/index.html
+   */
+  trailingSlash: true,
   serverRuntimeConfig: {
     PROJECT_ROOT: __dirname, // https://github.com/vercel/next.js/issues/8251
     VERSION: process.env.HIDE_LOG4BRAINS_VERSION ? "" : packageJson.version

This issue body was partially generated by patch-package.

llwt avatar Sep 21 '22 12:09 llwt

LGTM. Thank you all

thomvaill avatar Sep 22 '22 16:09 thomvaill