Skip to content

Commit

Permalink
Merge pull request #234 from nuxt-community/master
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Jan 24, 2021
2 parents 6182d67 + 6f25d48 commit 1e32032
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 40 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.5.4](https://github.com/nuxt-community/amp-module/compare/v0.5.3...v0.5.4) (2021-01-24)


### Bug Fixes

* **routes:** reorder routes to override AMP pages ([#233](https://github.com/nuxt-community/amp-module/issues/233)) ([a9c656d](https://github.com/nuxt-community/amp-module/commit/a9c656d64addc7bdc711cccdbef33566cc035d10))

### [0.5.3](https://github.com/nuxt-community/amp-module/compare/v0.5.2...v0.5.3) (2021-01-10)


Expand Down
5 changes: 5 additions & 0 deletions example/pages/amp/hello.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
Hello AMP
</div>
</template>
5 changes: 5 additions & 0 deletions example/pages/hello.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
Hello Everyone
</div>
</template>
5 changes: 4 additions & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ function processRoutes (options) {
}
})
this.extendRoutes((routes) => {
for (const route of routes) {
let head = 0
for (const [index, route] of routes.entries()) {
route.meta = route.meta || {}
route.alias = route.alias || []
if (typeof route.alias === 'string') {
route.alias = [route.alias]
}

if (route.path === '/amp' || route.path.indexOf('/amp/') === 0) {
routes.splice(head, 0, routes.splice(index, 1)[0])
head += 1
route.meta.amp = true
} else if (!Array.isArray(options.routeAliases) || options.routeAliases.includes(route.path)) {
route.alias.push('/amp' + route.path)
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nuxtjs/amp",
"version": "0.5.3",
"version": "0.5.4",
"description": "AMP Module for Nuxt",
"license": "MIT",
"contributors": [
Expand Down Expand Up @@ -41,24 +41,24 @@
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"codecov": "^3.8.1",
"eslint": "^7.17.0",
"eslint": "^7.18.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "4.1.0",
"eslint-plugin-vue": "^7.4.1",
"eslint-plugin-vue": "^7.5.0",
"get-port": "5.1.1",
"husky": "^4.3.7",
"husky": "^4.3.8",
"jest": "^26.6.3",
"jest-puppeteer": "^4.4.0",
"node-sass": "^5.0.0",
"nuxt-edge": "^2.14.8-26779714.3b19e3f4",
"nuxt-i18n": "^6.17.0",
"nuxt-i18n": "^6.18.0",
"puppeteer": "^5.5.0",
"request": "2.88.2",
"sass-loader": "^10.1.0",
"sass-loader": "^10.1.1",
"standard-version": "^9.1.0"
}
}
28 changes: 27 additions & 1 deletion test/module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ describe('Generates routes', () => {

test('Routes should be correctly localized', () => {
routes.forEach((route) => {
expect(route.alias).toEqual([`/amp${route.path}`])
if (!route.path.startsWith('/amp')) {
expect(route.alias).toEqual([`/amp${route.path}`])
}
})
})
})
Expand Down Expand Up @@ -123,6 +125,30 @@ describe('Render AMP version of home page', () => {
})
})

describe('Render hello page', () => {
let source
beforeAll(async () => {
const response = await page.goto(url('/hello'))
source = await response.text()
})

test('Hello Everyone', () => {
expect(source).toContain('Hello Everyone')
})
})

describe('Render AMP version of hello page', () => {
let source
beforeAll(async () => {
const response = await page.goto(url('/amp/hello'))
source = await response.text()
})

test('Hello AMP', () => {
expect(source).toContain('Hello AMP')
})
})

describe('Render AMP Story', () => {
let source, info
beforeAll(async () => {
Expand Down
64 changes: 32 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1112,10 +1112,10 @@
resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw==

"@eslint/eslintrc@^0.2.2":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.2.tgz#d01fc791e2fc33e88a29d6f3dc7e93d0cd784b76"
integrity sha512-EfB5OHNYp1F4px/LI/FEnGylop7nOqkQ1LRzCM0KccA2U8tvV8w01KBv37LbO7nW4H+YhKyo2LcJhRwjjV17QQ==
"@eslint/eslintrc@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.3.0.tgz#d736d6963d7003b6514e6324bec9c602ac340318"
integrity sha512-1JTKgrOKAHVivSvOYw+sJOunkBjUOvjqWk1DPja7ZFhIS2mX/4EgTT8M7eTK9jrKhL/FvXXEbQwIs3pg1xp3dg==
dependencies:
ajv "^6.12.4"
debug "^4.1.1"
Expand All @@ -1124,7 +1124,7 @@
ignore "^4.0.6"
import-fresh "^3.2.1"
js-yaml "^3.13.1"
lodash "^4.17.19"
lodash "^4.17.20"
minimatch "^3.0.4"
strip-json-comments "^3.1.1"

Expand Down Expand Up @@ -4817,15 +4817,15 @@ eslint-plugin-vue@^7.1.0:
semver "^7.3.2"
vue-eslint-parser "^7.2.0"

eslint-plugin-vue@^7.4.1:
version "7.4.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-7.4.1.tgz#2526ef0c010c218824a89423dbe6ddbe76f04fd6"
integrity sha512-W/xPNHYIkGJphLUM2UIYYGKbRw3BcDoMIPY9lu1TTa2YLiZoxurddfnmOP+UOVywxb5vi438ejzwvKdZqydtIw==
eslint-plugin-vue@^7.5.0:
version "7.5.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-7.5.0.tgz#cc6d983eb22781fa2440a7573cf39af439bb5725"
integrity sha512-QnMMTcyV8PLxBz7QQNAwISSEs6LYk2LJvGlxalXvpCtfKnqo7qcY0aZTIxPe8QOnHd7WCwiMZLOJzg6A03T0Gw==
dependencies:
eslint-utils "^2.1.0"
natural-compare "^1.4.0"
semver "^7.3.2"
vue-eslint-parser "^7.3.0"
vue-eslint-parser "^7.4.1"

eslint-scope@^4.0.3:
version "4.0.3"
Expand Down Expand Up @@ -4870,13 +4870,13 @@ eslint-visitor-keys@^2.0.0:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8"
integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==

eslint@^7.17.0:
version "7.17.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.17.0.tgz#4ccda5bf12572ad3bf760e6f195886f50569adb0"
integrity sha512-zJk08MiBgwuGoxes5sSQhOtibZ75pz0J35XTRlZOk9xMffhpA9BTbQZxoXZzOl5zMbleShbGwtw+1kGferfFwQ==
eslint@^7.18.0:
version "7.18.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.18.0.tgz#7fdcd2f3715a41fe6295a16234bd69aed2c75e67"
integrity sha512-fbgTiE8BfUJZuBeq2Yi7J3RB3WGUQ9PNuNbmgi6jt9Iv8qrkxfy19Ds3OpL1Pm7zg3BtTVhvcUZbIRQ0wmSjAQ==
dependencies:
"@babel/code-frame" "^7.0.0"
"@eslint/eslintrc" "^0.2.2"
"@eslint/eslintrc" "^0.3.0"
ajv "^6.10.0"
chalk "^4.0.0"
cross-spawn "^7.0.2"
Expand All @@ -4900,7 +4900,7 @@ eslint@^7.17.0:
js-yaml "^3.13.1"
json-stable-stringify-without-jsonify "^1.0.1"
levn "^0.4.1"
lodash "^4.17.19"
lodash "^4.17.20"
minimatch "^3.0.4"
natural-compare "^1.4.0"
optionator "^0.9.1"
Expand Down Expand Up @@ -6194,10 +6194,10 @@ human-signals@^1.1.1:
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==

husky@^4.3.7:
version "4.3.7"
resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.7.tgz#ca47bbe6213c1aa8b16bbd504530d9600de91e88"
integrity sha512-0fQlcCDq/xypoyYSJvEuzbDPHFf8ZF9IXKJxlrnvxABTSzK1VPT2RKYQKrcgJ+YD39swgoB6sbzywUqFxUiqjw==
husky@^4.3.8:
version "4.3.8"
resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.8.tgz#31144060be963fd6850e5cc8f019a1dfe194296d"
integrity sha512-LCqqsB0PzJQ/AlCgfrfzRe3e3+NvmefAdKQhRYpxS4u6clblBoDdzzvHi8fmxKRzvMxPY/1WZWzomPZww0Anow==
dependencies:
chalk "^4.0.0"
ci-info "^2.0.0"
Expand Down Expand Up @@ -8359,10 +8359,10 @@ nuxt-edge@^2.14.8-26779714.3b19e3f4:
"@nuxt/telemetry" "^1.2.3"
"@nuxt/webpack-edge" "2.14.8-26779714.3b19e3f4"

nuxt-i18n@^6.17.0:
version "6.17.0"
resolved "https://registry.yarnpkg.com/nuxt-i18n/-/nuxt-i18n-6.17.0.tgz#4d774f93c1ba76b89d380dd5b46888c9dd69e0c7"
integrity sha512-hP+ZWv+bB+OpgypL0RmFRRxPCDG0GgheeFE4877VqNxPKnTzPgKu1xyLRpa0m9Mj6DOGfCVHyqO4ER4RNFPo4A==
nuxt-i18n@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/nuxt-i18n/-/nuxt-i18n-6.18.0.tgz#e15d2fece238d03445366208dec017c43b203ff5"
integrity sha512-38pkBKyXC0UbI7KeBqD5XnKABtBXai1KzhQ/TL0fnlFgrLfrVpDnnnAEyAtfWpGyYOoVBqPB1yNnmqmhA5eitg==
dependencies:
"@babel/parser" "^7.5.5"
"@babel/traverse" "^7.5.5"
Expand Down Expand Up @@ -10370,10 +10370,10 @@ sass-graph@2.2.5:
scss-tokenizer "^0.2.3"
yargs "^13.3.2"

sass-loader@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-10.1.0.tgz#1727fcc0c32ab3eb197cda61d78adf4e9174a4b3"
integrity sha512-ZCKAlczLBbFd3aGAhowpYEy69Te3Z68cg8bnHHl6WnSCvnKpbM6pQrz957HWMa8LKVuhnD9uMplmMAHwGQtHeg==
sass-loader@^10.1.1:
version "10.1.1"
resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-10.1.1.tgz#4ddd5a3d7638e7949065dd6e9c7c04037f7e663d"
integrity sha512-W6gVDXAd5hR/WHsPicvZdjAWHBcEJ44UahgxcIE196fW2ong0ZHMPO1kZuI5q0VlvMQZh32gpv69PLWQm70qrw==
dependencies:
klona "^2.0.4"
loader-utils "^2.0.0"
Expand Down Expand Up @@ -11896,10 +11896,10 @@ vue-eslint-parser@^7.2.0:
esquery "^1.0.1"
lodash "^4.17.15"

vue-eslint-parser@^7.3.0:
version "7.3.0"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-7.3.0.tgz#894085839d99d81296fa081d19643733f23d7559"
integrity sha512-n5PJKZbyspD0+8LnaZgpEvNCrjQx1DyDHw8JdWwoxhhC+yRip4TAvSDpXGf9SWX6b0umeB5aR61gwUo6NVvFxw==
vue-eslint-parser@^7.4.1:
version "7.4.1"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-7.4.1.tgz#e4adcf7876a7379758d9056a72235af18a587f92"
integrity sha512-AFvhdxpFvliYq1xt/biNBslTHE/zbEvSnr1qfHA/KxRIpErmEDrQZlQnvEexednRHmLfDNOMuDYwZL5xkLzIXQ==
dependencies:
debug "^4.1.1"
eslint-scope "^5.0.0"
Expand Down

0 comments on commit 1e32032

Please sign in to comment.