Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Nov 20 18:07
    elmasse closed #323
  • Nov 20 18:07
    elmasse closed #321
  • Nov 20 18:07
    elmasse closed #320
  • Nov 20 18:07
    elmasse closed #319
  • Nov 20 18:07
    elmasse closed #267
  • Nov 20 18:07
    elmasse closed #14
  • Nov 20 17:46
    elmasse closed #324
  • Nov 20 17:46
    elmasse closed #325
  • Nov 20 17:46
    elmasse opened #325
  • Nov 15 01:12
    elmasse labeled #324
  • Nov 15 01:12
    elmasse assigned #324
  • Nov 15 01:12
    elmasse milestoned #324
  • Nov 15 01:12
    elmasse opened #324
  • Oct 13 12:11
    elmasse demilestoned #323
  • Oct 12 14:17
    elmasse assigned #323
  • Oct 12 14:17
    elmasse milestoned #323
  • Oct 12 14:17
    elmasse opened #323
  • Oct 09 19:17
    elmasse opened #322
  • Oct 05 14:20
    elmasse commented #14
  • Oct 05 12:24
    elmasse milestoned #14
Joseph Knoebel
@knoebelja
hm
give me like 20 minutes, can i share something with you then?
Max Fierro
@elmasse
sure
Joseph Knoebel
@knoebelja
we can move to a pm
Max Fierro
@elmasse
:+1:
Joseph Knoebel
@knoebelja
@elmasse Is there a way to change the permalink of a folder (not just a post)?
For example, 02-clothes has a permalink of clothes so all posts in the folder become clothes/post-title
Max Fierro
@elmasse
hmmm, the permalink by default is the :category/:name
if no category is assigned the folder name becomes the category
so if your folder is named 02-clothes then it should create 02-clothes/post-title
Joseph Knoebel
@knoebelja
categories are assigned in the post front matter, so I’m curious if there’s a way to set it for the folder itself.
Max Fierro
@elmasse
if you remove the category from the post front matter that will make the container folder name as the category
Max Fierro
@elmasse
If you are using beta you could create a custom transform plugin that given a configuration, inspect each post data._entry and modify the category based in the path, but that might be much simpler by just removing the category in the post front matter if you don't need to set a category different than the folder name.
Max Fierro
@elmasse
Hi @IceOnFire! welcome
Matteo Antony Mistretta
@IceOnFire
Thank you @elmasse! Sorry I didn't try your beta 1 yet, will do asap
Max Fierro
@elmasse
Awesome, please let me know how that goes. It was really odd that loading a huge css such as the highlight-theme blocked the next dev model. It was taking so long to process it that the export was taking +2m to compile client code :/
I'd recommend to use it from the CDN, that's what I did for nextein site
Matteo Antony Mistretta
@IceOnFire
hey @elmasse, I'm trying your beta.1
actually I don't see any difference :/
moreover, I tried creating another "Blogz" page to test what you mentioned on Github, but I cannot seem to navigate there neither
you're right, the highlight theme is quite heavy. but I'm trying to keep my webapp fully offline-capable by design and relying only on itself
Matteo Antony Mistretta
@IceOnFire
oh btw exporting now breaks the 'post' page with the usual 'cannot read data of undefined'
oh ok I saw your edits on Github: so there is no fix with /blog -> /blogz
you say it's a matter of highlight.js
thanks for all the time your putting into it!
Matteo Antony Mistretta
@IceOnFire
found the related issue: zeit/next-plugins#282
thank you for spotting it!
thanks for all the time your putting into it! you're
Matteo Antony Mistretta
@IceOnFire
TL;DR: beta.1 breaks export on the 'post' page (problem seems to be moved from blog to post)
Max Fierro
@elmasse
Try removing out/ and .next/ folders then run dev or export. It worked out just fine for me, I only commented out next-ga in _app.js and the highlight theme css in Pre component.
  ingloriouscoderz.github.io git:(v2) ✗ npm run dev

> ingloriouscoderz.github.io@2.0.0 dev /Users/elmasse/tmp/ingloriouscoderz.github.io
> nextein

Defining routes from exportPathMap
> Using "webpackDevMiddleware" config function defined in default.

✔ success server compiled in 522ms

Compiling

✔ success client compiled in 2s 395ms


 DONE  Compiled successfully in 3042ms                                        12:57:52 AM

watching changes in folders: [ 'posts' ]
> Ready on http://localhost:3000
^C⏎
➜  ingloriouscoderz.github.io git:(v2) ✗ npm run export

> ingloriouscoderz.github.io@2.0.0 export /Users/elmasse/tmp/ingloriouscoderz.github.io
> nextein build && nextein export

[12:57:58 AM] Compiling client
[12:57:59 AM] Compiling server
> Using external babel configuration
> Location: "/Users/elmasse/tmp/ingloriouscoderz.github.io/.babelrc"
Total precache size is about 0 B for 0 resources.
[12:59:15 AM] Compiled server in 1m
Total precache size is about 0 B for 0 resources.
[12:59:39 AM] Compiled client in 2m
> using build directory: /Users/elmasse/tmp/ingloriouscoderz.github.io/.next
  copying "static" directory
  copying "static build" directory
Creating entries...
> posts--blog--2016-02-21-hello-world--Qm20YjNljHRpqrRe~dgxF.json
> posts--blog--2016-05-11-il-vaso-di-piva--Qm20YjNljHRpqrRe~dgxF.json
> posts--blog--2016-07-21-resistere-alla-tentazione-del-procedurale-in-redux--Qm20YjNljHRpqrRe~dgxF.json
> posts--blog--2016-07-22-pokemon-go-e-la-teoria-degli-effetti-collaterali--Qm20YjNljHRpqrRe~dgxF.json
> posts--blog--2016-11-16-componenti-react-redux-come-librerie--Qm20YjNljHRpqrRe~dgxF.json
> posts--blog--2018-02-08-migliorare-il-codice-con-il-currying--Qm20YjNljHRpqrRe~dgxF.json
> posts--blog--2018-10-23-loopback-porting-di-spring-boot--Qm20YjNljHRpqrRe~dgxF.json
> exporting path: /blog/hello-world
i18next: languageChanged it
i18next: initialized { debug: true,
  initImmediate: true,
  ns: [ 'translation' ],
  defaultNS: [ 'translation' ],
  fallbackLng: [ 'en' ],
  fallbackNS: false,
  whitelist: false,
  nonExplicitWhitelist: false,
  load: 'all',
  preload: false,
  simplifyPluralSuffix: true,
  keySeparator: false,
  nsSeparator: false,
  pluralSeparator: '_',
  contextSeparator: '_',
  saveMissing: false,
  updateMissing: false,
  saveMissingTo: 'fallback',
  saveMissingPlurals: true,
  missingKeyHandler: false,
  missingInterpolationHandler: false,
  postProcess: false,
  returnNull: true,
  returnEmptyString: true,
  returnObjects: false,
  joinArrays: false,
  returnedObjectHandler: [Function: returnedObjectHandler],
  parseMissingKeyHandler: false,
  appendNamespaceToMissingKey: false,
  appendNamespaceToCIMode: false,
  overloadTranslationOptionHandler: [Function: handle],
  interpolation: { escapeValue: false },
  resources:
   { en: { translation: [Object] }, it: { translation: [Object] } },
  lng: 'it' }
> exporting path: /blog/il-vaso-di-piva
> exporting path: /blog/resistere-alla-tentazione-del-procedurale-in-redux
> exporting path: /blog/pokemon-go-e-la-teoria-degli-effetti-collaterali
> exporting path: /blog/componenti-react-redux-come-librerie
> exporting path: /blog/migliorare-il-codice-con-il-currying
> exporting path: /blog/loopback-porting-di-spring-boot
> exporting path: /
> exporting path: /how
> exporting path: /what
> exporting path: /when
> exporting path: /where
> exporting path: /who
> exporting path: /why
> exporting path: /blog

Export successful
Matteo Antony Mistretta
@IceOnFire

No can do. I tried a few things:

  1. Removing .next and out before re-exporting
  2. Removing next-ga (although in my workspace next-ga works, and keeping it or removing it yields the same effect)
  3. Removing the highlight theme (although I found a workaround that allows me to keep it)
  4. Using nextein/link from blog to post (I saw a difference here: next/link reloads the page, while nextein/link navigates client-side)

In every test I could yarn dev successfully but couldn't export due to

TypeError: Cannot read property 'data' of undefined
    at /home/antony/ingloriouscoderz.github.io/.next/server/static/1Ot7g708GPGusjwGsThCe/pages/post.js:814:11
I see a path that in your console doesn't show, but does in mine:
> exporting path: /blog/il-vaso-di-piva
> exporting path: /blog/resistere-alla-tentazione-del-procedurale-in-redux
> exporting path: /blog/pokemon-go-e-la-teoria-degli-effetti-collaterali
> exporting path: /blog/componenti-react-redux-come-librerie
> exporting path: /blog/migliorare-il-codice-con-il-currying
> exporting path: /blog/loopback-porting-di-spring-boot
> exporting path: /
> exporting path: /blog
> exporting path: /how
> exporting path: /index
> exporting path: /post
The last one is where it fails
Matteo Antony Mistretta
@IceOnFire
I wonder why it tries to export /post
I had to change the exportPathMap to exclude that path
exportPathMap: defaultPathMap => ({
    // ...defaultPathMap, no thanks
    '/how': { page: '/how' },
    '/what': { page: '/what' },
    '/when': { page: '/when' },
    '/where': { page: '/where' },
    '/who': { page: '/who' },
    '/why': { page: '/why' },
    '/blog': { page: '/blog' },
  }),
Max Fierro
@elmasse
Oh. Lol yes I forgot about that. I commented it out too. The defaultPathMap will export everything in the /pages dir. and for post you don’t want to export it as a page
Matthias Prieth
@matthiasprieth

Hey @elmasse ! Thanks for the recent bugfixes! As we discussed in elmasse/nextein-starter#7 I'm trying to build a hybrid application (SSR nextjs/static markup Blog with netlify cms connection).

Only thing I'm still struggling a bit is the static exporting with nextein export. Here is what I've tried so far:

  • When I set exportPathMap like below, exporting works, but i get 404 for the detail view of my posts. Links from my blog index to my posts page work though.
      exportPathMap: (defaultPathMap) => ({
          '/blog': { page: '/blog' }
      })
  • When I don't set exportPathMap at all, exporting of my posts work, but I can't deploy to AWS because of compiling errors, because it tries to export all of my pages (also my dynamic/SSR pages, which I don't want to export)
  • When I want to export my posts specifically I get the TypeError: Cannot read property 'data' of undefinederror mentioned above. But I don't know how to specify exportPathMap for dynamic posts
      exportPathMap: (defaultPathMap) => ({
          '/blog/:slug': { page: '/post'} //TypeError: Cannot read property 'data' of undefined error
          '/blog/:slug': { page: '/post', query: { title: ':slug' } } //infinite loop
          '/blog/first-post': { page: '/post', query: { title: 'first-post' } } //TypeError: Cannot read property 'data' of undefined error
      })
    So I'm trying to find a way to export my /blog page and my posts, which should be reachable under /blog/name-of-my-post and none of my other SSR pages. Do you have any idea how I can do that?
Max Fierro
@elmasse
Hey @matthiasprieth
You need to return the defaultPathMap or a subset if you specify the exportPathMap since v2.5
so, my advice will be to put a console.log on the exportPathMap to show the content of defaultPathMap, and then eliminate from there all entries you don't want to export and return the modified object.
one thing worth to mention is do this console log when you run nextein export, for some reason the defaultPathMap in dev is not the same object as in prod
the defaultPathMap will contain also all your posts entries generated by nextein
Max Fierro
@elmasse
Maybe I could add a config that can do that for you so you can define some sort of excludedPagesInExport
Let me know if that works, or if I can take a look on repo
What I'm not quite sure is that current nextein version will properly support the nextein start as in prod. It will let some watcher opened so maybe I need to get a new version for this.
Matthias Prieth
@matthiasprieth
Awesome thanks, didn't know about this defaultPathMap stuff! The solution with eliminating entries is a bit ugly in my case, but it works for this project. Thanks!
    exportPathMap: (defaultPathMap) => {
        let defaultPathArray = Object.values(defaultPathMap)
        defaultPathArray.filter(obj => {
            if(!Object.keys(obj).includes("query"))
                delete defaultPathMap[ obj.page ]      
        })
        return {
            ...defaultPathMap
        }
    }
Max Fierro
@elmasse
Glad it worked!