theowenyoung / foam-template-gatsby-theme-primer-wiki

Another Foam template that use gatsby-theme-primer-wiki
https://demo-foam.owenyoung.com/
MIT License
38 stars 13 forks source link

pathPrefix issues #1

Closed Casyfill closed 3 years ago

Casyfill commented 3 years ago

Hey! first of all, thanks for an awesome theme, just what we were looking for.

I have some hard time (first time Gatsby user) deploying it onto gitlab pages, though. Perhaps you can spot where is the issue - I have everything built and deployed properly, so I can check pages directly via URL. However, the links on the pages are incorrect, bypassing my team/repo in the URL path, so it is clearly an issue with pathPrefix.

However, it seems that everything set up correctly: I run everything via ./node_modules/.bin/gatsby build --prefix-paths and have the correct variable defined in the gatsby-config.js:

const path = require("path");
const pathPrefix = "/se_data_data_product/zgny_dp_knowledge_base";
const siteMetadata = {
  title: "ZGNY Data Product Wiki",
  shortName: "ZGNY",
  description: "ZGNY Wiki based on FOAM and Gatsby Wiki Theme",
  author: `ZGNY Data Products Team`,
  imageUrl: "/graph-visualisation.jpg",
  siteUrl: "https://streeteasy.pages.zgtools.net",
};
module.exports = {
  siteMetadata,
  pathPrefix,
  flags: {
    DEV_SSR: true,
  },
  plugins: [
...

My (private) url path should be http://streeteasy.pages.zgtools.net/se_data_data_product/zgny_dp_knowledge_base/, but all links have http://streeteasy.pages.zgtools.net/getting-started/ and similar instead....

theowenyoung commented 3 years ago

Hi, it seems the config is just correct, do you test it locally? You can run gatsby build --prefix-paths, then run gatsby serve --prefix-paths.

Tell me the results, thanks!

On Wed, Oct 13, 2021 at 4:17 Philipp Kats @.***> wrote:

Hey! first of all, thanks for an awesome theme, just what we were looking for.

I have some hard time (first time Gatsby user) deploying it onto gitlab pages, though. Perhaps you can spot where is the issue - I have everything built and deployed properly, so I can check pages directly via URL. However, the links on the pages are incorrect, bypassing my team/repo in the URL path, so it is clearly an issue with pathPrefix.

However, it seems that everything set up correctly: I run everything via ./node_modules/.bin/gatsby build --prefix-paths and have the correct variable defined in the gatsby-config.js:

const path = require("path"); const pathPrefix = "/se_data_data_product/zgny_dp_knowledge_base"; const siteMetadata = { title: "ZGNY Data Product Wiki", shortName: "ZGNY", description: "ZGNY Wiki based on FOAM and Gatsby Wiki Theme", author: ZGNY Data Products Team, imageUrl: "/graph-visualisation.jpg", siteUrl: "https://streeteasy.pages.zgtools.net", }; module.exports = { siteMetadata, pathPrefix, flags: { DEV_SSR: true, }, plugins: [ ...

My (private) url path should be http://streeteasy.pages.zgtools.net/se_data_data_product/zgny_dp_knowledge_base/, but all links have http://streeteasy.pages.zgtools.net/getting-started/ and similar instead....

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/theowenyoung/foam-template-gatsby-theme-primer-wiki/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO4UMQ3RSYVLG2G3HPIZFG3UGSJVJANCNFSM5F3PI2EA .

Casyfill commented 3 years ago

Thanks Owen! Indeed, that was me not properly using rsync (it wasn't overriding old files). Thing is, Gitlab REQUIRES publishing stuff to be in root ./public, and it cannot be a symlink. So for now I went to banal rm -rf ./public; cp .layouts/public ./public, even though I don't really like it. Perhaps, if we'd know an ideal way, this could be built into package.json as a build script?

I also have another proposal in #2

Here is my pipeline for reference

image: node:latest
# This folder is cached between builds
# https://docs.gitlab.com/ce/ci/yaml/README.html#cache

variables:
  GIT_SUBMODULE_STRATEGY: recursive
  NODE_OPTIONS: "--max-old-space-size=8192"
  # BUILD_PATH: public

cache:
  key: $CI_COMMIT_REF_SLUG
  paths:
    - node_modules/
    - .layouts/.npm/
    - .layouts/.cache/
    - public/
    - .layouts/public/

before_script:
  - export NODE_OPTIONS="--max-old-space-size=8192"
  - npm i -g npm

test:
  tags:
    - high-memory
  script:
    - cd .layouts/
    - npm i
    - npm test
  artifacts:
    paths:
      - test
  except:
    variables:
      - $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

pages:
  tags:
      - high-memory

  script:
    - rm -rf ./public
    - cd .layouts/
    - npm i
    - ./node_modules/.bin/gatsby build --prefix-paths
    - cp -r ./public ../public

  artifacts:
    paths:
      - ./public
  only:
    variables:
      - $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
Casyfill commented 3 years ago

Perhaps I should use something like this

theowenyoung commented 3 years ago

I like using some bash script to let the thing done.

So as you refer, until gatsby.js supporting to specify the output directory, I think using bash script is perfect.

theowenyoung commented 3 years ago

fixed. please use gatsby-theme-primer-wiki@1.13.1

https://github.com/theowenyoung/gatsby-theme-primer-wiki/releases/tag/gatsby-theme-primer-wiki%401.13.1