-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(div): update props and attributes
changed for markdown parser. Now we can write without indent. And recommend that the first line be a blank line.
- Loading branch information
Showing
2 changed files
with
36 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
<script setup lang="ts"> | ||
import { computed, useAttrs } from 'vue' | ||
import { useNetaBare } from '../composables/useNetaBare' | ||
interface Props { | ||
name?: string | ||
isBare?: boolean | ||
} | ||
const { name } = defineProps<Props>() | ||
// 初期値を設定しないと false になってしまうため undefined で設定する | ||
const { name, isBare } = withDefaults( defineProps<Props>(), { isBare: undefined }) | ||
const attrs = useAttrs() | ||
// isBare prop の値を優先し、なければ bare attribute があるかどうか | ||
// isBare prop が false なら bare attribute があっても false | ||
const bare = computed(() => isBare ?? Object.keys(attrs).includes('bare')) | ||
const { checked } = useNetaBare(name) | ||
</script> | ||
|
||
<template> | ||
<p v-if="checked"><slot name="bare">ネタバレの内容</slot></p> | ||
<p v-else><slot name="default">ネタバレに配慮した内容</slot></p> | ||
<div v-if="checked === bare"> | ||
<slot></slot> | ||
</div> | ||
</template> |