Skip to content

Commit

Permalink
refactor: refactor theme path
Browse files Browse the repository at this point in the history
  • Loading branch information
izhichao committed Mar 27, 2024
1 parent 3bcbf6f commit f0682cb
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfigWithTheme } from 'vitepress';
import { ThemeConfig } from './theme/src/types';
import { getPosts } from './theme/src/utils/getPosts';
import type { ThemeConfig } from '../src/types';
import { getPosts } from '../src/utils/getPosts';

const { posts, rewrites } = await getPosts({ pageSize: 7, index: false, folder: 'posts' });

Expand Down
27 changes: 2 additions & 25 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
import DefaultTheme from 'vitepress/theme';
import mediumZoom from 'medium-zoom';
import { onMounted, watch, nextTick } from 'vue';
import { useRoute } from 'vitepress';
import { registerComponents, ThemeLayout } from './src';
import Theme from '../../src/index';

export default {
...DefaultTheme,
Layout: ThemeLayout,
enhanceApp({ app }) {
registerComponents(app);
},
setup() {
const route = useRoute();
const initZoom = () => {
mediumZoom('.main img', { background: 'rgba(0,0,0,0.2)' });
};
onMounted(() => {
initZoom();
});
watch(
() => route.path,
() => nextTick(() => initZoom())
);
}
};
export default Theme;
14 changes: 0 additions & 14 deletions .vitepress/theme/src/index.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { onMounted, watch, nextTick } from 'vue';
import { useRoute } from 'vitepress';
import DefaultTheme from 'vitepress/theme';
import mediumZoom from 'medium-zoom';
import Home from './views/HomeView.vue';
import Archives from './views/ArchivesView.vue';
import Tags from './views/TagsView.vue';
import Page from './views/PageView.vue';
import ThemeLayout from './views/ThemeLayout.vue';
import './styles/index.less';

export default {
extends: DefaultTheme,
Layout: ThemeLayout,
enhanceApp({ app }) {
app.component('Home', Home);
app.component('Tags', Tags);
app.component('Archives', Archives);
app.component('Page', Page);
},
setup() {
const route = useRoute();
const initZoom = () => {
mediumZoom('.main img', { background: 'rgba(0,0,0,0.2)' });
};
onMounted(() => {
initZoom();
});
watch(
() => route.path,
() => nextTick(() => initZoom())
);
}
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions .vitepress/theme/src/types.ts → src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
WalineTeXRenderer,
WalineSearchOptions
} from '@waline/client';

export interface IPost {
title: string;
datetime: string;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import DefaultTheme from 'vitepress/theme';
import CommentItem from './components/CommentItem.vue';
import CommentItem from '../components/CommentItem.vue';
const { Layout } = DefaultTheme;
</script>

Expand Down

0 comments on commit f0682cb

Please sign in to comment.