Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
feat: 规范文章结构
Browse files Browse the repository at this point in the history
  • Loading branch information
zkz098 committed Dec 23, 2023
1 parent ce740f2 commit e055dbd
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 38 deletions.
18 changes: 18 additions & 0 deletions theme/components/ShokaxArticle.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script lang="ts" setup>
import type { Post } from 'valaxy'
import ShokaxArticleInner from './ShokaxArticleInner.vue'
defineProps<{
frontmatter: Post
}>()
</script>

<template>
<main>
<div class="inner">
<div class="main">
<ShokaxArticleInner :frontmatter="frontmatter" />
</div>
</div>
</main>
</template>
33 changes: 33 additions & 0 deletions theme/components/ShokaxArticleInner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script setup lang="ts">
import { useThemeConfig } from 'composables'
import { type Post, useSiteConfig } from 'valaxy'
defineProps<{
frontmatter: Post
}>()
const siteConfig = useSiteConfig()
const themeConfig = useThemeConfig()
</script>

<template>
<article itemscope itemtype="http://schema.org/Article" class="post block" :lang="siteConfig.lang">
<link itemprop="mainEntityOfPage" :href="frontmatter.url">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" :content="siteConfig.author.avatar">
<meta itemprop="name" :content="siteConfig.author.name">
<meta itemprop="description" :content="frontmatter.title">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" :content="frontmatter.title">
</span>
<RouterView />
<slot name="main-footer-before" />
<footer>
<ShokaxPostFooter :frontmatter="frontmatter" />
<ShokaxPostReward v-if="themeConfig.reward" :post="frontmatter" />
<ShokaxPostCopyright v-if="siteConfig.license.enabled" :frontmatter="frontmatter" />
</footer>
<slot name="main-footer-after" />
</article>
</template>
51 changes: 13 additions & 38 deletions theme/components/ValaxyMain.vue
Original file line number Diff line number Diff line change
@@ -1,51 +1,26 @@
<script lang="ts" setup>
import type { PageData, Post } from 'valaxy'
import { useSiteConfig } from 'valaxy'
import { useThemeConfig } from 'composables/config'
import ShokaxPostFooterTags from './ShokaxPostFooterTags.vue'
import ShokaxPostFooter from './ShokaxPostFooter.vue'
import ShokaxPostReward from './ShokaxPostReward.vue'
import ShokaxPostCopyright from './ShokaxPostCopyright.vue'
defineProps<{
frontmatter: Post
data?: PageData
}>()
const siteConfig = useSiteConfig()
const themeConfig = useThemeConfig()
</script>

<template>
<article itemscope itemtype="http://schema.org/Article" class="post block" :lang="siteConfig.lang">
<link itemprop="mainEntityOfPage" :href="frontmatter.url">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" :content="siteConfig.author.avatar">
<meta itemprop="name" :content="siteConfig.author.name">
<meta itemprop="description" :content="frontmatter.title">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" :content="frontmatter.title">
</span>
<slot name="main-header" />
<div class="body md" itemprop="articleBody">
<!-- photos 部分 TODO -->
<!-- summary 部分 TODO -->
<Transition appear>
<ValaxyMd :frontmatter="frontmatter">
<slot name="main-content-md" />
<slot />
</ValaxyMd>
</Transition>
<slot name="main-header" />
<div class="body md" itemprop="articleBody">
<!-- photos 部分 TODO -->
<!-- summary 部分 TODO -->
<Transition appear>
<ValaxyMd :frontmatter="frontmatter">
<slot name="main-content-md" />
<slot />
</ValaxyMd>
</Transition>

<slot name="main-content-after" />
<ShokaxPostFooterTags :post="frontmatter" />
</div>
<slot name="main-footer-before" />
<footer>
<ShokaxPostFooter :frontmatter="frontmatter" />
<ShokaxPostReward v-if="themeConfig.reward" :post="frontmatter" />
<ShokaxPostCopyright v-if="siteConfig.license.enabled" :frontmatter="frontmatter" />
</footer>
<slot name="main-footer-after" />
</article>
<slot name="main-content-after" />
<ShokaxPostFooterTags :post="frontmatter" />
</div>
</template>

0 comments on commit e055dbd

Please sign in to comment.