diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..38f11c645 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmjs.org diff --git a/.yarnrc b/.yarnrc deleted file mode 100644 index 142dad817..000000000 --- a/.yarnrc +++ /dev/null @@ -1 +0,0 @@ -registry "https://registry.npmjs.org" diff --git a/package.json b/package.json index 73928223f..54483526c 100644 --- a/package.json +++ b/package.json @@ -15,15 +15,15 @@ "license": "MIT", "devDependencies": { "commitizen": "3.1.1", - "conf": "4.0.2", + "conf": "5.0.0", "cz-conventional-changelog": "2.1.0", "eslint-config-prettier": "4.3.0", "eslint-config-rem": "4.0.0", - "eslint-plugin-prettier": "3.0.1", - "husky": "2.2.0", - "lerna": "3.14.1", + "eslint-plugin-prettier": "3.1.0", + "husky": "3.0.0", + "lerna": "3.15.0", "lint-staged": "8.1.6", - "prettier": "1.17.0", + "prettier": "1.18.2", "xo": "0.24.0" }, "xo": { diff --git a/packages/create-blog/CHANGELOG.md b/packages/create-blog/CHANGELOG.md index 33b7448b2..884f341a2 100644 --- a/packages/create-blog/CHANGELOG.md +++ b/packages/create-blog/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.2.7](https://github.com/saberland/saber/compare/create-blog@0.2.6...create-blog@0.2.7) (2019-06-21) + +**Note:** Version bump only for package create-blog + ## [0.2.6](https://github.com/egoist/saber/compare/create-blog@0.2.5...create-blog@0.2.6) (2019-05-08) **Note:** Version bump only for package create-blog diff --git a/packages/create-blog/package.json b/packages/create-blog/package.json index 785f27170..137ae9ddc 100644 --- a/packages/create-blog/package.json +++ b/packages/create-blog/package.json @@ -1,12 +1,12 @@ { "name": "create-blog", - "version": "0.2.6", + "version": "0.2.7", "bin": "cli.js", "files": [ "cli.js" ], "dependencies": { - "create-site": "^0.3.0" + "create-site": "^0.3.1" }, "license": "MIT", "author": { diff --git a/packages/create-site/CHANGELOG.md b/packages/create-site/CHANGELOG.md index 7ec0300a8..57a67a5e6 100644 --- a/packages/create-site/CHANGELOG.md +++ b/packages/create-site/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.1](https://github.com/saberland/saber/compare/create-site@0.3.0...create-site@0.3.1) (2019-06-21) + +**Note:** Version bump only for package create-site + # [0.3.0](https://github.com/egoist/saber/compare/create-site@0.2.5...create-site@0.3.0) (2019-05-08) ### Features diff --git a/packages/create-site/cli.js b/packages/create-site/cli.js index 8e40cc826..e73945a92 100755 --- a/packages/create-site/cli.js +++ b/packages/create-site/cli.js @@ -18,9 +18,7 @@ Usage: create-site if (parseInt(process.versions.node, 10) < 8) { console.log( - `Node.js ${ - process.versions.node - } isn't supported, you need Node.js 8 or above.` + `Node.js ${process.versions.node} isn't supported, you need Node.js 8 or above.` ) process.exit(1) } diff --git a/packages/create-site/package.json b/packages/create-site/package.json index b480ecf8f..88f6f64c8 100644 --- a/packages/create-site/package.json +++ b/packages/create-site/package.json @@ -1,6 +1,6 @@ { "name": "create-site", - "version": "0.3.0", + "version": "0.3.1", "bin": "cli.js", "files": [ "cli.js", diff --git a/packages/saber-highlight-css/CHANGELOG.md b/packages/saber-highlight-css/CHANGELOG.md index c6e4c2d24..0a8359a7e 100644 --- a/packages/saber-highlight-css/CHANGELOG.md +++ b/packages/saber-highlight-css/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.1.0](https://github.com/saberland/saber/compare/saber-highlight-css@0.0.5...saber-highlight-css@0.1.0) (2019-07-27) + +**Note:** Version bump only for package saber-highlight-css + ## [0.0.5](https://github.com/saberland/saber/compare/saber-highlight-css@0.0.4...saber-highlight-css@0.0.5) (2019-05-29) ### Features diff --git a/packages/saber-highlight-css/package.json b/packages/saber-highlight-css/package.json index b84f82b9b..044bedd84 100644 --- a/packages/saber-highlight-css/package.json +++ b/packages/saber-highlight-css/package.json @@ -1,12 +1,12 @@ { "name": "saber-highlight-css", - "version": "0.0.5", + "version": "0.1.0", "description": "Default CSS for code highlighting in Saber", "files": [ "*.css" ], "license": "MIT", "peerDependencies": { - "saber": "^0.6.2" + "saber": ">=0.7.0" } } diff --git a/packages/saber-markdown/CHANGELOG.md b/packages/saber-markdown/CHANGELOG.md index 4023a16a5..825451306 100644 --- a/packages/saber-markdown/CHANGELOG.md +++ b/packages/saber-markdown/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.1.0](https://github.com/saberland/saber/compare/saber-markdown@0.0.9...saber-markdown@0.1.0) (2019-07-27) + +**Note:** Version bump only for package saber-markdown + +## [0.0.9](https://github.com/saberland/saber/compare/saber-markdown@0.0.8...saber-markdown@0.0.9) (2019-06-21) + +**Note:** Version bump only for package saber-markdown + +## [0.0.8](https://github.com/saberland/saber/compare/saber-markdown@0.0.7...saber-markdown@0.0.8) (2019-06-15) + +**Note:** Version bump only for package saber-markdown + ## [0.0.7](https://github.com/egoist/saber/compare/saber-markdown@0.0.6...saber-markdown@0.0.7) (2019-05-08) **Note:** Version bump only for package saber-markdown diff --git a/packages/saber-markdown/package.json b/packages/saber-markdown/package.json index 1c454b228..940b1b266 100644 --- a/packages/saber-markdown/package.json +++ b/packages/saber-markdown/package.json @@ -1,6 +1,6 @@ { "name": "saber-markdown", - "version": "0.0.7", + "version": "0.1.0", "files": [ "dist" ], @@ -11,11 +11,11 @@ }, "license": "MIT", "devDependencies": { - "@babel/core": "7.4.5", + "@babel/core": "7.5.4", "builtin-modules": "3.1.0", - "markdown-it": "8.4.2", - "rollup": "1.11.3", - "rollup-plugin-babel": "4.3.2", + "markdown-it": "9.0.1", + "rollup": "1.17.0", + "rollup-plugin-babel": "4.3.3", "rollup-plugin-commonjs": "9.3.4", "rollup-plugin-json": "4.0.0", "rollup-plugin-node-resolve": "4.2.3", diff --git a/packages/saber-plugin-feed/CHANGELOG.md b/packages/saber-plugin-feed/CHANGELOG.md index 94a3c848a..c960e1e6d 100644 --- a/packages/saber-plugin-feed/CHANGELOG.md +++ b/packages/saber-plugin-feed/CHANGELOG.md @@ -3,6 +3,26 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.4.0](https://github.com/saberland/saber/compare/saber-plugin-feed@0.3.4...saber-plugin-feed@0.4.0) (2019-07-27) + +### Features + +- refactor page interface ([#345](https://github.com/saberland/saber/issues/345)) ([629c4a6](https://github.com/saberland/saber/commit/629c4a6)) + +## [0.3.4](https://github.com/saberland/saber/compare/saber-plugin-feed@0.3.3...saber-plugin-feed@0.3.4) (2019-06-21) + +### Bug Fixes + +- **saber-plugin-feed:** use page.excerpt ([d586c51](https://github.com/saberland/saber/commit/d586c51)) + +### Features + +- adding API for rendering page content ([#268](https://github.com/saberland/saber/issues/268)) ([ad8e76d](https://github.com/saberland/saber/commit/ad8e76d)) + +## [0.3.3](https://github.com/saberland/saber/compare/saber-plugin-feed@0.3.2...saber-plugin-feed@0.3.3) (2019-06-15) + +**Note:** Version bump only for package saber-plugin-feed + ## [0.3.2](https://github.com/saberland/saber/compare/saber-plugin-feed@0.3.1...saber-plugin-feed@0.3.2) (2019-05-24) **Note:** Version bump only for package saber-plugin-feed diff --git a/packages/saber-plugin-feed/example/pages/_posts/hello-world.md b/packages/saber-plugin-feed/example/pages/_posts/hello-world.md index a62e6e09b..b1cbb9633 100644 --- a/packages/saber-plugin-feed/example/pages/_posts/hello-world.md +++ b/packages/saber-plugin-feed/example/pages/_posts/hello-world.md @@ -4,4 +4,4 @@ date: 2018-02-12 layout: post --- -wtf is __this__ +wtf is __this__ {{ 1 + 1 }} diff --git a/packages/saber-plugin-feed/lib/index.js b/packages/saber-plugin-feed/lib/index.js index dbc47c38a..a7487da1c 100644 --- a/packages/saber-plugin-feed/lib/index.js +++ b/packages/saber-plugin-feed/lib/index.js @@ -48,30 +48,32 @@ exports.apply = (api, options = {}) => { async function generateFeed(localePath) { // Prepare posts const posts = [] - for (const page of api.pages.values()) { - if (page.attributes.type !== 'post' || page.attributes.draft) { - continue - } - - const matchedLocalePath = api.pages.getMatchedLocalePath( - page.attributes.permalink - ) - if (localePath !== matchedLocalePath) { - continue - } - - const { excerpt } = page.attributes - posts.push({ - title: page.attributes.title, - id: page.attributes.permalink, - link: resolveURL(siteConfig.url, page.attributes.permalink), - // Strip HTML tags in excerpt and use it as description (a.k.a. summary) - description: excerpt && excerpt.replace(/<(?:.|\n)*?>/gm, ''), - content: page.content, - date: page.attributes.updatedAt, - published: page.attributes.createdAt + + await Promise.all( + [...api.pages.values()].map(async page => { + if (page.type !== 'post' || page.draft) { + return + } + + const matchedLocalePath = api.pages.getMatchedLocalePath(page.permalink) + if (localePath !== matchedLocalePath) { + return + } + + const content = await api.renderer.renderPageContent(page.permalink) + posts.push({ + title: page.title, + id: page.permalink, + link: resolveURL(siteConfig.url, page.permalink), + // Strip HTML tags in excerpt and use it as description (a.k.a. summary) + description: + page.excerpt && page.excerpt.replace(/<(?:.|\n)*?>/gm, ''), + content, + date: page.updatedAt, + published: page.createdAt + }) }) - } + ) // Order by published const items = posts diff --git a/packages/saber-plugin-feed/package.json b/packages/saber-plugin-feed/package.json index cfa887e2d..0dd01015e 100644 --- a/packages/saber-plugin-feed/package.json +++ b/packages/saber-plugin-feed/package.json @@ -1,6 +1,6 @@ { "name": "saber-plugin-feed", - "version": "0.3.2", + "version": "0.4.0", "description": "Generate Atom, RSS2, or JSON feed for your Saber app", "license": "MIT", "main": "lib/index.js", @@ -12,9 +12,9 @@ ], "xo": false, "dependencies": { - "feed": "^2.0.4" + "feed": "^4.0.0" }, "peerDependencies": { - "saber": "^0.6.2" + "saber": ">=0.7.0" } } diff --git a/packages/saber-plugin-git-modification-time/CHANGELOG.md b/packages/saber-plugin-git-modification-time/CHANGELOG.md index 6c5e3f04a..9617035c8 100644 --- a/packages/saber-plugin-git-modification-time/CHANGELOG.md +++ b/packages/saber-plugin-git-modification-time/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.1.0](https://github.com/saberland/saber/compare/saber-plugin-git-modification-time@0.0.3...saber-plugin-git-modification-time@0.1.0) (2019-07-27) + +### Features + +- refactor page interface ([#345](https://github.com/saberland/saber/issues/345)) ([629c4a6](https://github.com/saberland/saber/commit/629c4a6)) + ## [0.0.3](https://github.com/egoist/saber/compare/saber-plugin-git-modification-time@0.0.2...saber-plugin-git-modification-time@0.0.3) (2019-05-21) ### Bug Fixes diff --git a/packages/saber-plugin-git-modification-time/README.md b/packages/saber-plugin-git-modification-time/README.md index 509fea532..1bac07fe8 100644 --- a/packages/saber-plugin-git-modification-time/README.md +++ b/packages/saber-plugin-git-modification-time/README.md @@ -1,10 +1,10 @@ # saber-plugin-git-modification-time -> Use the author time of the last commit as page.attributes.updatedAt +> Use the author time of the last commit as `page.updatedAt` Why? See [#9785](https://github.com/gatsbyjs/gatsby/issues/9785). -**tl;dr** `page.attributes.updatedAt` defaults to `file.mtime` which will change on platforms like Netlify. We restore the value to author time of the last commit instead. +**tl;dr** `page.updatedAt` defaults to `file.mtime` which will change on platforms like Netlify. We restore the value to author time of the last commit instead. ## Install diff --git a/packages/saber-plugin-git-modification-time/lib/index.js b/packages/saber-plugin-git-modification-time/lib/index.js index 043fd34d4..9aa979d68 100644 --- a/packages/saber-plugin-git-modification-time/lib/index.js +++ b/packages/saber-plugin-git-modification-time/lib/index.js @@ -15,7 +15,7 @@ exports.apply = api => { page.internal.absolute ]) if (stdout) { - page.attributes.updatedAt = new Date(stdout) + page.updatedAt = new Date(stdout) } } }) diff --git a/packages/saber-plugin-git-modification-time/package.json b/packages/saber-plugin-git-modification-time/package.json index 4d55678c7..be1c55982 100644 --- a/packages/saber-plugin-git-modification-time/package.json +++ b/packages/saber-plugin-git-modification-time/package.json @@ -1,7 +1,7 @@ { "name": "saber-plugin-git-modification-time", - "version": "0.0.3", - "description": "Use the author time of the last commit as page.attributes.updatedAt", + "version": "0.1.0", + "description": "Use the author time of the last commit as page.updatedAt", "license": "MIT", "main": "lib/index.js", "files": [ @@ -9,9 +9,9 @@ ], "xo": false, "dependencies": { - "execa": "^1.0.0" + "execa": "^2.0.3" }, "peerDependencies": { - "saber": "^0.6.2" + "saber": ">=0.7.0" } } diff --git a/packages/saber-plugin-google-analytics/CHANGELOG.md b/packages/saber-plugin-google-analytics/CHANGELOG.md index 6de2717ea..d5814aad6 100644 --- a/packages/saber-plugin-google-analytics/CHANGELOG.md +++ b/packages/saber-plugin-google-analytics/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.1.0](https://github.com/saberland/saber/compare/saber-plugin-google-analytics@0.0.6...saber-plugin-google-analytics@0.1.0) (2019-07-27) + +**Note:** Version bump only for package saber-plugin-google-analytics + ## [0.0.6](https://github.com/egoist/saber/compare/saber-plugin-google-analytics@0.0.5...saber-plugin-google-analytics@0.0.6) (2019-05-21) ### Bug Fixes diff --git a/packages/saber-plugin-google-analytics/package.json b/packages/saber-plugin-google-analytics/package.json index a7faa1795..63318569e 100644 --- a/packages/saber-plugin-google-analytics/package.json +++ b/packages/saber-plugin-google-analytics/package.json @@ -1,12 +1,12 @@ { "name": "saber-plugin-google-analytics", - "version": "0.0.6", + "version": "0.1.0", "main": "index.js", "files": [ "index.js", "saber-browser.js" ], "peerDependencies": { - "saber": "^0.6.2" + "saber": ">=0.7.0" } } diff --git a/packages/saber-plugin-image/CHANGELOG.md b/packages/saber-plugin-image/CHANGELOG.md index ad11e1a62..58dcda231 100644 --- a/packages/saber-plugin-image/CHANGELOG.md +++ b/packages/saber-plugin-image/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.1.0](https://github.com/saberland/saber/compare/saber-plugin-image@0.0.4...saber-plugin-image@0.1.0) (2019-07-27) + +### Bug Fixes + +- **saber-plugin-image:** fix lazy load for images with `srcset` ([#264](https://github.com/saberland/saber/issues/264)) ([0cd1201](https://github.com/saberland/saber/commit/0cd1201)) + ## [0.0.4](https://github.com/egoist/saber/compare/saber-plugin-image@0.0.3...saber-plugin-image@0.0.4) (2019-05-21) ### Bug Fixes diff --git a/packages/saber-plugin-image/lib/saber-browser.js b/packages/saber-plugin-image/lib/saber-browser.js index ee01701a1..45057c878 100644 --- a/packages/saber-plugin-image/lib/saber-browser.js +++ b/packages/saber-plugin-image/lib/saber-browser.js @@ -3,7 +3,7 @@ import styles from './styles.module.css' export default ({ Vue }) => { const options = Object.assign( - (process.browser && __SABER_IMAGE_OPTIONS__) || {}, // eslint-disable-line no-undef + __SABER_IMAGE_OPTIONS__ || {}, // eslint-disable-line no-undef { lazyComponent: true } ) @@ -40,7 +40,7 @@ export default ({ Vue }) => { }) } - const { width, height, src, srcSet: srcset, placeholder } = this.src + const { width, height, src, srcSet, placeholder } = this.src const loading = (getOption('placeholder') && placeholder) || @@ -52,7 +52,7 @@ export default ({ Vue }) => { return h('img', { attrs: { ...$attrs, - srcset, + 'data-srcset': srcSet, width, height }, diff --git a/packages/saber-plugin-image/package.json b/packages/saber-plugin-image/package.json index b973a9d4c..0670a96bf 100644 --- a/packages/saber-plugin-image/package.json +++ b/packages/saber-plugin-image/package.json @@ -1,6 +1,6 @@ { "name": "saber-plugin-image", - "version": "0.0.4", + "version": "0.1.0", "main": "lib/index.js", "files": [ "lib" diff --git a/packages/saber-plugin-meta-redirect/CHANGELOG.md b/packages/saber-plugin-meta-redirect/CHANGELOG.md index b4cc7edbe..a36dca715 100644 --- a/packages/saber-plugin-meta-redirect/CHANGELOG.md +++ b/packages/saber-plugin-meta-redirect/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.1.0](https://github.com/saberland/saber/compare/saber-plugin-meta-redirect@0.0.5...saber-plugin-meta-redirect@0.1.0) (2019-07-27) + +**Note:** Version bump only for package saber-plugin-meta-redirect + ## [0.0.5](https://github.com/egoist/saber/compare/saber-plugin-meta-redirect@0.0.4...saber-plugin-meta-redirect@0.0.5) (2019-05-21) ### Bug Fixes diff --git a/packages/saber-plugin-meta-redirect/package.json b/packages/saber-plugin-meta-redirect/package.json index 1c1cebd83..fd51c0cd3 100644 --- a/packages/saber-plugin-meta-redirect/package.json +++ b/packages/saber-plugin-meta-redirect/package.json @@ -1,6 +1,6 @@ { "name": "saber-plugin-meta-redirect", - "version": "0.0.5", + "version": "0.1.0", "description": "Generates meta redirect html files for redirecting on any static file host", "license": "MIT", "main": "lib/index.js", @@ -16,6 +16,6 @@ "url-join": "^4.0.0" }, "peerDependencies": { - "saber": "^0.6.2" + "saber": ">=0.7.0" } } diff --git a/packages/saber-plugin-netlify-redirect/CHANGELOG.md b/packages/saber-plugin-netlify-redirect/CHANGELOG.md index 50f273ad9..9afe4ba43 100644 --- a/packages/saber-plugin-netlify-redirect/CHANGELOG.md +++ b/packages/saber-plugin-netlify-redirect/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.1.0](https://github.com/saberland/saber/compare/saber-plugin-netlify-redirect@0.0.6...saber-plugin-netlify-redirect@0.1.0) (2019-07-27) + +### Features + +- refactor page interface ([#345](https://github.com/saberland/saber/issues/345)) ([629c4a6](https://github.com/saberland/saber/commit/629c4a6)) + ## [0.0.6](https://github.com/egoist/saber/compare/saber-plugin-netlify-redirect@0.0.5...saber-plugin-netlify-redirect@0.0.6) (2019-05-21) ### Bug Fixes diff --git a/packages/saber-plugin-netlify-redirect/lib/index.js b/packages/saber-plugin-netlify-redirect/lib/index.js index 07d2d9d52..a976bd24e 100644 --- a/packages/saber-plugin-netlify-redirect/lib/index.js +++ b/packages/saber-plugin-netlify-redirect/lib/index.js @@ -38,9 +38,7 @@ exports.apply = api => { } } - const allPermalinks = [...api.pages.values()].map( - page => page.attributes.permalink - ) + const allPermalinks = [...api.pages.values()].map(page => page.permalink) for (const permalink of allPermalinks) { if (permalink.endsWith('.html')) { const fromPath = permalink.replace(/\.html$/, '') diff --git a/packages/saber-plugin-netlify-redirect/package.json b/packages/saber-plugin-netlify-redirect/package.json index 06cae3292..a6ddccb65 100644 --- a/packages/saber-plugin-netlify-redirect/package.json +++ b/packages/saber-plugin-netlify-redirect/package.json @@ -1,6 +1,6 @@ { "name": "saber-plugin-netlify-redirect", - "version": "0.0.6", + "version": "0.1.0", "description": "Automatically generate or update `_redirects` file in your public folder for Netlify.", "license": "MIT", "main": "lib/index.js", @@ -16,6 +16,6 @@ "url-join": "^4.0.0" }, "peerDependencies": { - "saber": "^0.6.2" + "saber": ">=0.7.0" } } diff --git a/packages/saber-plugin-pwa/CHANGELOG.md b/packages/saber-plugin-pwa/CHANGELOG.md index d35ed4d2f..c03eaaae8 100644 --- a/packages/saber-plugin-pwa/CHANGELOG.md +++ b/packages/saber-plugin-pwa/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.4.0](https://github.com/saberland/saber/compare/saber-plugin-pwa@0.3.3...saber-plugin-pwa@0.4.0) (2019-07-27) + +**Note:** Version bump only for package saber-plugin-pwa + ## [0.3.3](https://github.com/saberland/saber/compare/saber-plugin-pwa@0.3.2...saber-plugin-pwa@0.3.3) (2019-05-28) ### Bug Fixes diff --git a/packages/saber-plugin-pwa/package.json b/packages/saber-plugin-pwa/package.json index de7c0195a..ac6573352 100644 --- a/packages/saber-plugin-pwa/package.json +++ b/packages/saber-plugin-pwa/package.json @@ -1,6 +1,6 @@ { "name": "saber-plugin-pwa", - "version": "0.3.3", + "version": "0.4.0", "description": "Add PWA support for your Saber app.", "license": "MIT", "main": "lib/index.js", @@ -9,7 +9,7 @@ ], "xo": false, "peerDependencies": { - "saber": "^0.6.2" + "saber": ">=0.7.0" }, "dependencies": { "@egoist/snackbar": "^1.2.1", diff --git a/packages/saber-plugin-query-posts/CHANGELOG.md b/packages/saber-plugin-query-posts/CHANGELOG.md index 679779622..1fcd2c69f 100644 --- a/packages/saber-plugin-query-posts/CHANGELOG.md +++ b/packages/saber-plugin-query-posts/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.4.0](https://github.com/saberland/saber/compare/saber-plugin-query-posts@0.3.2...saber-plugin-query-posts@0.4.0) (2019-07-27) + +### Features + +- refactor page interface ([#345](https://github.com/saberland/saber/issues/345)) ([629c4a6](https://github.com/saberland/saber/commit/629c4a6)) + ## [0.3.2](https://github.com/saberland/saber/compare/saber-plugin-query-posts@0.3.1...saber-plugin-query-posts@0.3.2) (2019-05-28) ### Features diff --git a/packages/saber-plugin-query-posts/README.md b/packages/saber-plugin-query-posts/README.md index 2cd045a7f..7c970e382 100644 --- a/packages/saber-plugin-query-posts/README.md +++ b/packages/saber-plugin-query-posts/README.md @@ -36,12 +36,12 @@ Then in the layout component `layouts/index.vue`, `page.posts` and `page.paginat ← Prev Page @@ -49,7 +49,6 @@ Then in the layout component `layouts/index.vue`, `page.posts` and `page.paginat Next Page → - @@ -62,7 +61,7 @@ export default { ## Tags -This plugin will automatically generate tag pages at `/tags/:tag` when you're using `tags` in page attributes, e.g. in a Markdown post: +This plugin will automatically generate tag pages at `/tags/:tag` when you're using `tags` in page data, e.g. in a Markdown post: ```markdown --- @@ -78,7 +77,7 @@ hello ### Data Injected in Post Pages -You can access the detailed info of the tags of a post page via `this.page.tags`, for instance: +You can access the detailed info of the tags of a post page via `this.page.tagsInfo`, for instance: ```yaml tags: @@ -109,7 +108,7 @@ You can access the tag name in the layout component via `this.page.tag`. ## Categories -This plugin will automatically generate category pages at `/categories/:tag` when you're using `categories` in page attributes, e.g. in a Markdown post: +This plugin will automatically generate category pages at `/categories/:tag` when you're using `categories` in page data, e.g. in a Markdown post: ```markdown --- @@ -126,7 +125,7 @@ Then there will be a `/categories/sports` page,`categories` is an array, so yo ### Data Injected in Post Pages -You can access the detailed info of the categories of a post page via `this.page.categories`, for instance: +You can access the detailed info of the categories of a post page via `this.page.categoriesInfo`, for instance: ```yaml categories: diff --git a/packages/saber-plugin-query-posts/lib/index.js b/packages/saber-plugin-query-posts/lib/index.js index 6b0bb8d9a..fd5496d86 100644 --- a/packages/saber-plugin-query-posts/lib/index.js +++ b/packages/saber-plugin-query-posts/lib/index.js @@ -51,33 +51,31 @@ exports.apply = (api, options = {}) => { categoriesMap = Object.assign({}, categoriesMap) for (const page of api.pages.values()) { - if (page.attributes.draft) { + if (page.draft) { continue } - const matchedLocalePath = api.pages.getMatchedLocalePath( - page.attributes.permalink - ) + const matchedLocalePath = api.pages.getMatchedLocalePath(page.permalink) if (matchedLocalePath !== currentLocalePath) { continue } - if (page.attributes.injectAllPosts) { + if (page.injectAllPosts) { injectPostsToPages.add(page) continue } - if (page.attributes.type === 'post') { + if (page.type === 'post') { const pagePublicFields = api.pages.getPagePublicFields(page) allPosts.add(pagePublicFields) // Group posts for tag pages - const tags = [].concat(page.attributes.tags || []) + const tags = [].concat(page.tags || []) if (tags.length > 0) { - page.tags = [] + page.tagsInfo = [] for (const tag of tags) { const tagSlug = getIdFromMap(tagsMap, tag) - page.tags.push({ + page.tagsInfo.push({ name: tag, permalink: renderPermalink(permalinks.tag, { name: tagSlug, @@ -92,18 +90,18 @@ exports.apply = (api, options = {}) => { // Group posts for category pages const categories = [] - .concat(page.attributes.categories || []) + .concat(page.categories || []) .map(v => (Array.isArray(v) ? v : v.split('/'))) if (categories.length > 0) { - page.categories = [] + page.categoriesInfo = [] for (const category of categories) { for (const index of category.keys()) { const categorySlug = category .slice(0, index + 1) .map(name => getIdFromMap(categoriesMap, name)) .join('/') - page.categories.push({ + page.categoriesInfo.push({ // The base name of the category name: category[index], permalink: renderPermalink(permalinks.category, { @@ -130,15 +128,13 @@ exports.apply = (api, options = {}) => { injectToPages( new Set([ { - attributes: { - isTagPage: true, - layout: 'tag', - permalink: renderPermalink(permalinks.tag, { - name: tag, - slug: tag - }), + isTagPage: true, + layout: 'tag', + permalink: renderPermalink(permalinks.tag, { + name: tag, slug: tag - }, + }), + slug: tag, internal: { id: `internal_blog__tag__${tag}`, // So that this page will be removed before next `onCreatePages` hook in watch mode @@ -158,15 +154,13 @@ exports.apply = (api, options = {}) => { injectToPages( new Set([ { - attributes: { - isCategoryPage: true, - layout: 'category', - permalink: renderPermalink(permalinks.category, { - name: category, - slug: category - }), + isCategoryPage: true, + layout: 'category', + permalink: renderPermalink(permalinks.category, { + name: category, slug: category - }, + }), + slug: category, internal: { id: `internal_blog__category__${category}`, // So that this page will be removed before next `onCreatePages` hook in watch mode @@ -188,23 +182,23 @@ exports.apply = (api, options = {}) => { if (pages.size > 0) { const date = new Date() const sortedPosts = [...posts].sort((a, b) => { - const aDate = new Date(a.attributes.date || a.attributes.createdAt) - const bDate = new Date(b.attributes.date || b.attributes.createdAt) + const aDate = new Date(a.createdAt) + const bDate = new Date(b.createdAt) return aDate > bDate ? -1 : 1 }) for (const page of pages) { const paginatedPosts = paginate( sortedPosts, - Object.assign({}, paginationOptions, page.attributes.injectAllPosts) + Object.assign({}, paginationOptions, page.injectAllPosts) ) const totalPages = paginatedPosts.length for (const [index, posts] of paginatedPosts.entries()) { const permalink = index === 0 - ? page.attributes.permalink - : urlJoin(page.attributes.permalink, `page/${index + 1}`) + ? page.permalink + : urlJoin(page.permalink, `page/${index + 1}`) const newPage = Object.assign({}, page, { internal: Object.assign({}, page.internal, { id: @@ -215,22 +209,17 @@ exports.apply = (api, options = {}) => { page.internal.parent || (index === 0 ? undefined : page.internal.id) }), - attributes: Object.assign({}, page.attributes, { - permalink, - createdAt: page.attributes.createdAt || date, - updatedAt: page.attributes.updatedAt || date - }), + permalink, + createdAt: page.createdAt || date, + updatedAt: page.updatedAt || date, posts, pagination: { hasPrev: index !== totalPages - 1, hasNext: index !== 0, total: totalPages, current: index + 1, - prevLink: getPaginationLink( - index + 2, - page.attributes.permalink - ), - nextLink: getPaginationLink(index, page.attributes.permalink) + prevLink: getPaginationLink(index + 2, page.permalink), + nextLink: getPaginationLink(index, page.permalink) } }) Object.assign(newPage, pageProp) diff --git a/packages/saber-plugin-query-posts/package.json b/packages/saber-plugin-query-posts/package.json index a0ff67cce..e438448e3 100644 --- a/packages/saber-plugin-query-posts/package.json +++ b/packages/saber-plugin-query-posts/package.json @@ -1,6 +1,6 @@ { "name": "saber-plugin-query-posts", - "version": "0.3.2", + "version": "0.4.0", "files": [ "lib" ], @@ -15,6 +15,6 @@ "url-join": "^4.0.0" }, "peerDependencies": { - "saber": "^0.6.2" + "saber": ">=0.7.0" } } diff --git a/packages/saber-plugin-transformer-html/CHANGELOG.md b/packages/saber-plugin-transformer-html/CHANGELOG.md index 57925e385..dceec7f8d 100644 --- a/packages/saber-plugin-transformer-html/CHANGELOG.md +++ b/packages/saber-plugin-transformer-html/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.1.0](https://github.com/saberland/saber/compare/saber-plugin-transformer-html@0.0.5...saber-plugin-transformer-html@0.1.0) (2019-07-27) + +### Features + +- refactor page interface ([#345](https://github.com/saberland/saber/issues/345)) ([629c4a6](https://github.com/saberland/saber/commit/629c4a6)) + ## [0.0.5](https://github.com/egoist/saber/compare/saber-plugin-transformer-html@0.0.4...saber-plugin-transformer-html@0.0.5) (2019-05-21) ### Bug Fixes diff --git a/packages/saber-plugin-transformer-html/lib/index.js b/packages/saber-plugin-transformer-html/lib/index.js index 34d2239e0..d0a49669d 100644 --- a/packages/saber-plugin-transformer-html/lib/index.js +++ b/packages/saber-plugin-transformer-html/lib/index.js @@ -10,9 +10,9 @@ exports.apply = api => { page.content ) const { html, blocks } = extractSFCBlocks(body) + Object.assign(page, frontmatter) page.content = html page.internal.hoistedTags = blocks - Object.assign(page.attributes, frontmatter) }, getPageComponent(page) { return `