Skip to content

Commit

Permalink
feat: changing the way of fetching random image.
Browse files Browse the repository at this point in the history
  • Loading branch information
tong committed May 28, 2024
1 parent dcc1963 commit 38c2694
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
29 changes: 29 additions & 0 deletions dev/global-components/BaseListLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,41 @@ import PostsList from "@theme/components/PostsList.vue";
import About from "@theme/components/About.vue";
import FeaturedPosts from "@theme/components/FeaturedPosts";
import { Pagination, SimplePagination } from '@vuepress/plugin-blog/lib/client/components'
// import { createApi } from 'unsplash-js';
export default {
components: { PostsList, Pagination, FeaturedPosts, About },
created () {
this.paginationComponent = this.getPaginationComponent()
},
mounted() {
// const unsplash = createApi({
// accessKey: 'WOJPvx7_24kOgjn16FQy1rz-xV8_5KrhBR5m-yRXzaE',
// fetch: fetch,
// });
// unsplash.photos.getRandom({
// w: 1200,
// h: 800,
// featured: true,
// count: 1
// }).then(result => {
// console.log(result);
// })
// fetch("https://unsplash.com/oauth/authorize", {
// header: {
// client_id: "WOJPvx7_24kOgjn16FQy1rz-xV8_5KrhBR5m-yRXzaE",
// response_type: "",
// scope: "public read_photos"
// }
// })
// .then(res => res.json())
// .then(data => {
// return data.token;
// })
},
// data: {
// bgImgUrl: ""
// },
computed: {
pages () {
return this.$pagination.pages;
Expand Down
2 changes: 1 addition & 1 deletion dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (themeConfig, ctx) => {
});

themeConfig.heroImage =
themeConfig.heroImage || "https://source.unsplash.com/featured/1200x800";
themeConfig.heroImage || "https://picsum.photos/1200/800";

const defaultBlogPluginOptions = {
directories: [
Expand Down
1 change: 1 addition & 0 deletions dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"element-ui": "^2.13.0",
"flexsearch": "^0.6.32",
"remove-markdown": "^0.3.0",
"unsplash-js": "^7.0.19",
"vue-feather-icons": "^4.21.0",
"vuepress-plugin-disqus": "^0.1.1",
"vuepress-plugin-reading-progress": "^1.0.7",
Expand Down

0 comments on commit 38c2694

Please sign in to comment.