+2
-2
@@ -114,8 +114,8 @@ export default class App extends Vue
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass">
|
<style lang="sass">
|
||||||
@import "css/global"
|
@use "css/global"
|
||||||
@import "css/animations"
|
@use "css/animations"
|
||||||
|
|
||||||
#nav
|
#nav
|
||||||
position: fixed
|
position: fixed
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export default class BlogIndexLinks extends Vue
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
@import 'src/css/colors'
|
@use '../css/colors'
|
||||||
|
|
||||||
.index
|
.index
|
||||||
*
|
*
|
||||||
@@ -55,7 +55,7 @@ export default class BlogIndexLinks extends Vue
|
|||||||
|
|
||||||
.index-categories
|
.index-categories
|
||||||
font-size: 0.8em
|
font-size: 0.8em
|
||||||
color: $color-text-special
|
color: colors.$color-text-special
|
||||||
|
|
||||||
*
|
*
|
||||||
text-decoration: underline
|
text-decoration: underline
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ const date = moment(p.meta.date)
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
@import 'src/css/colors'
|
@use '../css/colors'
|
||||||
|
|
||||||
#BlogPostPreview
|
#BlogPostPreview
|
||||||
text-align: left
|
text-align: left
|
||||||
@@ -121,7 +121,7 @@ const date = moment(p.meta.date)
|
|||||||
|
|
||||||
#date
|
#date
|
||||||
font-size: 0.7em
|
font-size: 0.7em
|
||||||
color: $color-text-light
|
color: colors.$color-text-light
|
||||||
|
|
||||||
> * + *, #content > * + *
|
> * + *, #content > * + *
|
||||||
padding-top: 10px
|
padding-top: 10px
|
||||||
@@ -150,7 +150,7 @@ const date = moment(p.meta.date)
|
|||||||
|
|
||||||
#subtitle
|
#subtitle
|
||||||
font-size: 0.8em
|
font-size: 0.8em
|
||||||
color: $color-text-light
|
color: colors.$color-text-light
|
||||||
|
|
||||||
img
|
img
|
||||||
$margin: 10px
|
$margin: 10px
|
||||||
@@ -171,7 +171,7 @@ const date = moment(p.meta.date)
|
|||||||
#expand
|
#expand
|
||||||
font-size: 0.8em
|
font-size: 0.8em
|
||||||
padding-top: 10px
|
padding-top: 10px
|
||||||
color: $color-text-light
|
color: colors.$color-text-light
|
||||||
|
|
||||||
// Put image on top
|
// Put image on top
|
||||||
#BlogPostPreview.image-top
|
#BlogPostPreview.image-top
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ export default class MetaTable extends Vue
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
@import "src/css/colors"
|
@use "../css/colors"
|
||||||
|
|
||||||
.meta
|
.meta
|
||||||
td:first-child
|
td:first-child
|
||||||
text-align: right
|
text-align: right
|
||||||
color: $color-text-light
|
color: colors.$color-text-light
|
||||||
|
|
||||||
td:last-child
|
td:last-child
|
||||||
display: inline-block
|
display: inline-block
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ const props = defineProps({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
@import src/css/colors
|
@use "../css/colors"
|
||||||
|
|
||||||
$tag-height: 20px
|
$tag-height: 20px
|
||||||
$tag-color: $color-bg-6
|
$tag-color: colors.$color-bg-6
|
||||||
$text-color: $color-text-light
|
$text-color: colors.$color-text-light
|
||||||
|
|
||||||
$padding: calc($tag-height / 2)
|
$padding: calc($tag-height / 2)
|
||||||
$triangle-width: calc($tag-height / 2) * 0.8
|
$triangle-width: calc($tag-height / 2) * 0.8
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@import "src/css/colors"
|
@import "../css/colors"
|
||||||
|
|
||||||
$width: 600px
|
$width: 600px
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
def extract_and_migrate_sass(file_path):
|
||||||
|
"""Extracts <style lang="sass"> block from a Svelte file, runs sass-migrator on it, and replaces the original style block."""
|
||||||
|
|
||||||
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||||||
|
content = file.read()
|
||||||
|
|
||||||
|
# Regex pattern to match <style lang="sass">...</style>
|
||||||
|
style_pattern = re.compile(r'<style\s+lang\s*=\s*["\']sass["\']( scoped)*>(.*?)</style>', re.DOTALL)
|
||||||
|
|
||||||
|
# Extract all matching style blocks
|
||||||
|
matches = list(style_pattern.finditer(content))
|
||||||
|
|
||||||
|
if not matches:
|
||||||
|
print(f"No <style lang='sass'> block found in {file_path}")
|
||||||
|
return
|
||||||
|
|
||||||
|
updated_content = content
|
||||||
|
|
||||||
|
for match in matches:
|
||||||
|
original_style_block = match.group(0) # The full <style>...</style> block
|
||||||
|
scoped = match.group(1) # The scoped attribute if present
|
||||||
|
sass_content = match.group(2) # The content inside the <style> block
|
||||||
|
|
||||||
|
# Create a temporary file in the same directory as the .svelte file
|
||||||
|
temp_file_path = Path(file_path).parent / f"{Path(file_path).stem}_temp.sass"
|
||||||
|
|
||||||
|
# Write the SASS content to the temporary file
|
||||||
|
with open(temp_file_path, 'w', encoding='utf-8') as temp_file:
|
||||||
|
# Calculate relative path depth
|
||||||
|
depth = len(Path(file_path).parent.relative_to(Path(__file__).parent).parts)
|
||||||
|
print(Path(file_path).parent.relative_to(Path(__file__).parent).parts)
|
||||||
|
temp_file.write(sass_content.replace("src/", "../" * depth))
|
||||||
|
|
||||||
|
# Run the sass-migrator on the temporary file
|
||||||
|
try:
|
||||||
|
subprocess.run(['sass-migrator', 'module', str(temp_file_path)], check=True)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Error while running sass-migrator on {file_path}: {e}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Read back the migrated content
|
||||||
|
with open(temp_file_path, 'r', encoding='utf-8') as temp_file:
|
||||||
|
migrated_sass_content = temp_file.read()
|
||||||
|
|
||||||
|
# Create the new <style> block with the migrated SASS content
|
||||||
|
new_style_block = f'<style lang="sass"{scoped or ''}>{migrated_sass_content}</style>'
|
||||||
|
|
||||||
|
# Replace the original style block with the new one
|
||||||
|
updated_content = updated_content.replace(original_style_block, new_style_block)
|
||||||
|
|
||||||
|
# Remove the temporary file
|
||||||
|
temp_file_path.unlink()
|
||||||
|
|
||||||
|
# Write the updated content back to the original file
|
||||||
|
with open(file_path, 'w', encoding='utf-8') as file:
|
||||||
|
file.write(updated_content)
|
||||||
|
|
||||||
|
print(f"Updated {file_path}")
|
||||||
|
|
||||||
|
def process_svelte_files(directory):
|
||||||
|
"""Recursively processes all .svelte files in the given directory."""
|
||||||
|
svelte_files = Path(directory).rglob("*.vue")
|
||||||
|
|
||||||
|
for svelte_file in svelte_files:
|
||||||
|
extract_and_migrate_sass(svelte_file)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Main function to process all .svelte files in the current directory."""
|
||||||
|
current_directory = Path(__file__).parent
|
||||||
|
process_svelte_files(current_directory)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
+1
-1
@@ -51,7 +51,7 @@ export default class About extends Vue
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass">
|
<style lang="sass">
|
||||||
@import "../css/colors"
|
@use "../css/colors"
|
||||||
|
|
||||||
#About
|
#About
|
||||||
width: min(600px, 80vw)
|
width: min(600px, 80vw)
|
||||||
|
|||||||
+3
-3
@@ -60,11 +60,11 @@ const activePost = computed(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
@import "src/css/colors"
|
@use "../css/colors"
|
||||||
@import "src/css/responsive"
|
@use "../css/responsive"
|
||||||
|
|
||||||
#breadcrumb
|
#breadcrumb
|
||||||
color: $color-text-light
|
color: colors.$color-text-light
|
||||||
margin-bottom: 20px
|
margin-bottom: 20px
|
||||||
|
|
||||||
span:not(.no-after):after
|
span:not(.no-after):after
|
||||||
|
|||||||
+2
-2
@@ -20,8 +20,8 @@ import 'tg-blog/dist/style.css'
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
@import "src/css/colors"
|
@use "../css/colors"
|
||||||
@import "src/css/responsive"
|
@use "../css/responsive"
|
||||||
|
|
||||||
.title
|
.title
|
||||||
text-align: left
|
text-align: left
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
@import "src/css/global"
|
@use "../css/global"
|
||||||
@import "src/css/colors"
|
@use "../css/colors"
|
||||||
@import "src/css/responsive"
|
@use "../css/responsive"
|
||||||
|
|
||||||
.links
|
.links
|
||||||
display: flex
|
display: flex
|
||||||
@@ -28,7 +28,7 @@ a
|
|||||||
@extend .card
|
@extend .card
|
||||||
@extend .clickable
|
@extend .clickable
|
||||||
|
|
||||||
color: $color-text-main
|
color: colors.$color-text-main
|
||||||
text-decoration: none
|
text-decoration: none
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ export default class Friends extends Vue
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
@import "src/css/colors"
|
@use "../../css/colors"
|
||||||
@import "src/css/responsive"
|
@use "../../css/responsive"
|
||||||
|
|
||||||
$card-min-width: 320px
|
$card-min-width: 320px
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ $card-min-width: 320px
|
|||||||
flex: 1
|
flex: 1
|
||||||
|
|
||||||
a
|
a
|
||||||
color: $color-text-main
|
color: colors.$color-text-main
|
||||||
|
|
||||||
a + a
|
a + a
|
||||||
margin-left: 10px
|
margin-left: 10px
|
||||||
|
|||||||
@@ -176,8 +176,8 @@ export default class Menu extends Vue
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
@import "src/css/colors"
|
@use "../../css/colors"
|
||||||
@import "src/css/responsive"
|
@use "../../css/responsive"
|
||||||
|
|
||||||
.columns
|
.columns
|
||||||
display: flex
|
display: flex
|
||||||
@@ -200,14 +200,14 @@ export default class Menu extends Vue
|
|||||||
.subtitle
|
.subtitle
|
||||||
font-size: 0.8em
|
font-size: 0.8em
|
||||||
margin-bottom: 0.5em
|
margin-bottom: 0.5em
|
||||||
color: $color-text-light
|
color: colors.$color-text-light
|
||||||
|
|
||||||
.items
|
.items
|
||||||
.sub
|
.sub
|
||||||
font-size: 0.7em
|
font-size: 0.7em
|
||||||
|
|
||||||
.item.recommend
|
.item.recommend
|
||||||
color: $color-text-special
|
color: colors.$color-text-special
|
||||||
|
|
||||||
.item.original:after
|
.item.original:after
|
||||||
content: '原创'
|
content: '原创'
|
||||||
|
|||||||
Reference in New Issue
Block a user