├── public ├── robots.txt ├── icon.png ├── large.jpg ├── OG-card.png ├── favicon.ico └── pwa │ ├── icon-192x192.png │ ├── icon-256x256.png │ ├── icon-384x384.png │ └── icon-512x512.png ├── .eslintignore ├── .env.example ├── components ├── user │ ├── avatar.png │ ├── UserLoginButton.vue │ └── UserLoginForm.vue ├── global │ ├── InfoBox.vue │ └── PrevNext.vue ├── SwitchLocaleSelect.vue ├── README.md ├── SwitchLocale.vue ├── MemoryUsageDemo.vue ├── AppSearchInput.vue ├── ReloadPrompt.vue ├── blog │ └── BlogList.vue ├── header │ ├── HeaderResponsiveMenu.vue │ └── HeaderMain.vue ├── MarkdownEditor.vue ├── DaisyuiThemeSwitcher.vue ├── FooterMain.vue ├── Logo.vue └── Tutorial.vue ├── CHANGELOG.md ├── postcss.config.js ├── api ├── example.ts ├── auth.ts ├── todos.ts └── useSoftware.ts ├── .gitignore ├── .vscode ├── extensions.json └── settings.json ├── pages ├── post1.md ├── about.vue ├── blog │ ├── index.vue │ └── [post].vue ├── profile.vue └── index.vue ├── content ├── blog │ ├── post2.md │ └── post1.md └── about.md ├── tsconfig.json ├── locales ├── en.yml ├── fr.yml └── es.yml ├── layouts ├── README.md ├── default.vue └── error.vue ├── middleware ├── auth.ts └── README.md ├── composables ├── states.ts ├── useSupabase.ts ├── README.md └── useAuth.ts ├── plugins ├── README.md ├── supabase.client.ts └── markdownit.js ├── styles ├── tailwind.css └── scrollbar-color.css ├── .eslintrc.js ├── server-middleware └── sw.js ├── package.json ├── tailwind.config.js ├── pwaConfiguration.ts ├── README.md └── nuxt.config.ts /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | .output 4 | .nuxt 5 | -------------------------------------------------------------------------------- /public/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctwhome/top-nuxt3/HEAD/public/icon.png -------------------------------------------------------------------------------- /public/large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctwhome/top-nuxt3/HEAD/public/large.jpg -------------------------------------------------------------------------------- /public/OG-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctwhome/top-nuxt3/HEAD/public/OG-card.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctwhome/top-nuxt3/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | SUPABASE_URL = https://.supabase.co 2 | SUPABASE_KEY = 3 | -------------------------------------------------------------------------------- /components/user/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctwhome/top-nuxt3/HEAD/components/user/avatar.png -------------------------------------------------------------------------------- /public/pwa/icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctwhome/top-nuxt3/HEAD/public/pwa/icon-192x192.png -------------------------------------------------------------------------------- /public/pwa/icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctwhome/top-nuxt3/HEAD/public/pwa/icon-256x256.png -------------------------------------------------------------------------------- /public/pwa/icon-384x384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctwhome/top-nuxt3/HEAD/public/pwa/icon-384x384.png -------------------------------------------------------------------------------- /public/pwa/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctwhome/top-nuxt3/HEAD/public/pwa/icon-512x512.png -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog Top Nuxt3, by @ctwhome 2 | 3 | ### Jan 8, 2022 4 | - 🎉 Add styled Markdown files 5 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /api/example.ts: -------------------------------------------------------------------------------- 1 | export default function hello ():string { 2 | const hello:string = 'Typescript' 3 | return hello 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | .nuxt 4 | nuxt.d.ts 5 | .output 6 | 7 | # Local Netlify folder 8 | .netlify 9 | .env 10 | .idea 11 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "bradlc.vscode-tailwindcss", 5 | "johnsoncodehk.volar" 6 | ] 7 | } -------------------------------------------------------------------------------- /pages/post1.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: post1 3 | myVar: this is my var in frontmatter 4 | title: My post 1 5 | --- 6 | # my post 1 7 | thanks everyone for joining the community. 8 | -------------------------------------------------------------------------------- /content/blog/post2.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: post2 3 | myVar: this is my var in frontmatter 4 | title: My post 2 5 | --- 6 | # my post 2 7 | thanks everyone for joining the community. 8 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.nuxt/tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ESNext", 5 | "types": [ 6 | "vite-plugin-pwa/client" 7 | ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /locales/en.yml: -------------------------------------------------------------------------------- 1 | lang: 2 | en: English 3 | es: Español 4 | fr: Français 5 | welcome: Welcome to 6 | about: About 7 | change-theme: Change Theme 8 | blog: Blog 9 | protected: Protected Profile 10 | -------------------------------------------------------------------------------- /locales/fr.yml: -------------------------------------------------------------------------------- 1 | lang: 2 | en: English 3 | es: Español 4 | fr: Français 5 | welcome: Bienvenue à 6 | about: Sur 7 | change-theme: Change le thème 8 | blog: Blog 9 | protected: Profile Protégé 10 | -------------------------------------------------------------------------------- /locales/es.yml: -------------------------------------------------------------------------------- 1 | lang: 2 | en: English 3 | es: Español 4 | fr: Français 5 | welcome: Bienvenido a 6 | about: Acerca de 7 | change-theme: Cambiar Estilos 8 | blog: Blog 9 | protected: Profile Protegido 10 | -------------------------------------------------------------------------------- /components/global/InfoBox.vue: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /components/SwitchLocaleSelect.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /layouts/README.md: -------------------------------------------------------------------------------- 1 | # LAYOUTS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your Application Layouts. 6 | 7 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/views#layouts). 8 | -------------------------------------------------------------------------------- /middleware/auth.ts: -------------------------------------------------------------------------------- 1 | import useAuth from '~/composables/useAuth' 2 | 3 | export default defineNuxtRouteMiddleware((to, from) => { 4 | const { isLoggedIn } = useAuth() 5 | if (!isLoggedIn()) { 6 | process.client && alert('This page requires authentication.') 7 | return navigateTo('/') 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /pages/about.vue: -------------------------------------------------------------------------------- 1 | 10 | 13 | -------------------------------------------------------------------------------- /composables/states.ts: -------------------------------------------------------------------------------- 1 | import { useState } from '#app' 2 | 3 | /** 4 | * States examples with Nuxt useState 5 | */ 6 | 7 | export const useCounter = () => useState('counter', () => 0) 8 | export const useColor = () => useState('color', () => 'pink') 9 | export const useText = () => useState('text', () => 'Hello') 10 | -------------------------------------------------------------------------------- /plugins/README.md: -------------------------------------------------------------------------------- 1 | # PLUGINS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains Javascript plugins that you want to run before mounting the root Vue.js application. 6 | 7 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins). 8 | -------------------------------------------------------------------------------- /components/README.md: -------------------------------------------------------------------------------- 1 | # COMPONENTS 2 | Important: keep the name of the nested components the same you name the partent folders: 3 | example: /components/blog/MyComponent = BlogMyComponent.vue 4 | 5 | **This directory is not required, you can delete it if you don't want to use it.** 6 | 7 | The components directory contains your Vue.js Components. 8 | 9 | _Nuxt.js doesn't supercharge these components._ 10 | -------------------------------------------------------------------------------- /middleware/README.md: -------------------------------------------------------------------------------- 1 | # MIDDLEWARE 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your application middleware. 6 | Middleware let you define custom functions that can be run before rendering either a page or a group of pages. 7 | 8 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware). 9 | -------------------------------------------------------------------------------- /plugins/supabase.client.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Work in progress 3 | */ 4 | 5 | import {defineNuxtPlugin} from '#app' 6 | // import { createClient } from '@supabase/supabase-js' 7 | 8 | export default defineNuxtPlugin(nuxtApp => { 9 | // const config = useRuntimeConfig() 10 | // const supabase = createClient(config.supabaseUrl, config.supabasePublicKey) 11 | // nuxtApp.provide('supabase',supabase) 12 | // return supabase 13 | }) 14 | -------------------------------------------------------------------------------- /components/SwitchLocale.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /composables/useSupabase.ts: -------------------------------------------------------------------------------- 1 | import { createClient } from '@supabase/supabase-js' 2 | 3 | const SUPABASE_URL = 'https://uduilifzyiujjrzlwyby.supabase.co' 4 | const SUPABASE_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYxNTIzNzkyMywiZXhwIjoxOTMwODEzOTIzfQ.morp5e9629xzWqRwcy1d6J3FbGbQKSwOyOAoK1URv1I' 5 | 6 | const supabase = createClient(SUPABASE_URL, SUPABASE_KEY) 7 | 8 | 9 | export default function useSupabase () { 10 | return { supabase } 11 | } 12 | -------------------------------------------------------------------------------- /content/blog/post1.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: post1 3 | myVar: this is my var in frontmatter 4 | title: My post 1 5 | --- 6 | # my post 1 7 | This post blog is not dynamic. It gets the data form the MarkdownFile, 8 | but it doesn't import the file dynamically from parameters. 9 | 10 | 11 | [Vite supports glob-type dynamic imports like import('./locales/*.json')but does not support dynamic string imports like import(`./locales/${locales}.json`)](https://github.com/vitejs/vite/issues/772#issuecomment-858993304) 12 | -------------------------------------------------------------------------------- /layouts/default.vue: -------------------------------------------------------------------------------- 1 | 8 | 20 | -------------------------------------------------------------------------------- /styles/tailwind.css: -------------------------------------------------------------------------------- 1 | @import './scrollbar-color.css'; 2 | 3 | @tailwind base; 4 | @tailwind components; 5 | @tailwind utilities; 6 | 7 | 8 | /* Base styles modifications 9 | * https://tailwindcss.com/docs/adding-base-styles 10 | */ 11 | @layer base { 12 | h1 { 13 | @apply text-3xl font-medium 14 | } 15 | h2 { 16 | @apply text-2xl; 17 | } 18 | h3 { 19 | @apply text-xl; 20 | } 21 | h3 { 22 | @apply text-lg; 23 | } 24 | 25 | ul.styled { 26 | @apply my-3 27 | } 28 | ul.styled li{ 29 | @apply list-disc ml-10 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /styles/scrollbar-color.css: -------------------------------------------------------------------------------- 1 | /* Import with */ 2 | /* @import './scrollbar-color.css'; */ 3 | 4 | :root { 5 | --scrollbarTrack: hsl(var(--b2)); 6 | --scrollbarThumb: hsl(var(--b3)); 7 | --scrollbarThumbHover: hsl(var(--b1)); 8 | } 9 | /* Scrollbar colors*/ 10 | /* width */ 11 | ::-webkit-scrollbar { 12 | width: 10px; 13 | } 14 | 15 | /* Track */ 16 | ::-webkit-scrollbar-track { 17 | background: var(--scrollbarTrack); 18 | } 19 | 20 | /* Handle */ 21 | ::-webkit-scrollbar-thumb { 22 | background: var(--scrollbarThumb); 23 | border-radius: 3px; 24 | } 25 | 26 | /* Handle on hover */ 27 | ::-webkit-scrollbar-thumb:hover { 28 | background: var(--scrollbarThumbHover); 29 | } 30 | -------------------------------------------------------------------------------- /components/global/PrevNext.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 31 | -------------------------------------------------------------------------------- /composables/README.md: -------------------------------------------------------------------------------- 1 | # Composables directory 2 | Nuxt 3 supports composables/ directory to automatically import your Vue composables into your application using auto-imports! 3 | 4 | Composables are used to store value. Vue 3 enables the creation of reactive variables outside the framework for reusability. 5 | 6 | - By convention, the composables names add the word "use" attached to the name. 7 | - Composable files only are executed at root level [VIdeo (6:24): 7 Important Vue 3 Composition and Composable Functions Explained](https://www.youtube.com/watch?v=z_1k0QC1HsE) 8 | - Nuxt 3 supports composables/ directory to automatically import your Vue composables into your application using auto-imports! 9 | - [Nuxt3 composables](https://v3.nuxtjs.org/docs/directory-structure/composables) 10 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'env': { 3 | 'browser': true, 4 | 'es2021': true 5 | }, 6 | 'extends': [ 7 | 'eslint:recommended', 8 | 'plugin:nuxt/recommended', 9 | 'plugin:@typescript-eslint/recommended' 10 | ], 11 | 'parserOptions': { 12 | 'ecmaVersion': 13, 13 | 'parser': '@typescript-eslint/parser', 14 | 'sourceType': 'module' 15 | }, 16 | 'plugins': [ 17 | 'vue', 18 | '@typescript-eslint' 19 | ], 20 | 'rules': { 21 | 'indent': ['error',2], 22 | 'linebreak-style': ['error','unix'], 23 | 'quotes': ['error','single'], 24 | 'semi': ['error','never'], 25 | // we want to avoid extraneous spaces 26 | 'no-trailing-spaces': 'error', 27 | 'no-multi-spaces': ['error'], 28 | 'no-multiple-empty-lines': 'error' 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /pages/blog/index.vue: -------------------------------------------------------------------------------- 1 | 13 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /layouts/error.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 38 | 39 | 44 | -------------------------------------------------------------------------------- /components/MemoryUsageDemo.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 33 | -------------------------------------------------------------------------------- /pages/blog/[post].vue: -------------------------------------------------------------------------------- 1 | 10 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // required to indicate that eslint project is not in the root 3 | // "eslint.workingDirectories": [ 4 | // ".", 5 | // ], 6 | // FORMAT ON SAVE for VSC 7 | // based on this acticle https://www.aleksandrhovhannisyan.com/blog/format-code-on-save-vs-code-eslint/ 8 | // define files to validate, can have more options 9 | // but in this project we use typescript and react 10 | "eslint.validate": [ 11 | "javascript", 12 | "javascriptvue", 13 | "typescript", 14 | "typescriptvue", 15 | ], 16 | // it tells VScode to use eslint plugin 17 | // Note! you might also need to disable Prettier or VSCode defaults 18 | "editor.formatOnSave": true, 19 | "editor.codeActionsOnSave": { 20 | "source.fixAll.eslint": true, 21 | }, 22 | // Tailwind plugin integration 23 | "css.validate": false, 24 | "editor.quickSuggestions": { 25 | "strings": true 26 | }, 27 | "tailwindCSS.includeLanguages": { 28 | "plaintext": "html" 29 | }, 30 | } -------------------------------------------------------------------------------- /server-middleware/sw.js: -------------------------------------------------------------------------------- 1 | import { resolve } from 'pathe' 2 | import { promises } from 'fs' 3 | 4 | export default async function(req, res, next) { 5 | // req is the Node.js http request object 6 | const url = req.url 7 | let resource = null 8 | if (url === '/sw.js' || url === '/manifest.webmanifest' || (url.startsWith('/workbox-') && url.endsWith('.js'))) 9 | resource = url.slice(1) 10 | 11 | if (resource) { 12 | const path = resolve(`./.output/public/_nuxt/${resource}`) 13 | const { mtime } = await promises.stat(path) 14 | const ifModifiedSinceH = req.headers['if-modified-since'] 15 | if (new Date(ifModifiedSinceH) >= new Date(mtime)) { 16 | res.statusCode = 304 17 | return res.end('Not Modified (mtime)') 18 | } 19 | if (resource.endsWith('.js')) 20 | res.setHeader('Content-Type', 'application/javascript') 21 | else 22 | res.setHeader('Content-Type', 'application/manifest+json') 23 | res.setHeader('Last-Modified', mtime) 24 | res.setHeader('Cache-Control', 'public, max-age=0, must-revalidate') 25 | return res.end(await promises.readFile(path)) 26 | } 27 | next() 28 | } 29 | -------------------------------------------------------------------------------- /components/user/UserLoginButton.vue: -------------------------------------------------------------------------------- 1 | 32 | 33 | 42 | -------------------------------------------------------------------------------- /api/auth.ts: -------------------------------------------------------------------------------- 1 | import { ref, computed } from 'vue' 2 | import { Provider, Session } from '@supabase/supabase-js' 3 | import supabase from '~/plugins/supabase' 4 | 5 | // state 6 | const userSession = ref() 7 | 8 | // Getter 9 | const isLoggedIn = computed( 10 | () => userSession.value?.user?.aud === 'authenticated' 11 | ) 12 | 13 | // Actions 14 | function loginWithProvider (provider:Provider = 'google', isDev:boolean) { 15 | supabase.auth.signIn({ provider }, { 16 | redirectTo: isDev ? 'http://localhost:3000' : undefined 17 | }) 18 | } 19 | 20 | async function loginWithEmail (email:string) { 21 | console.log('✉️ requesting email...') 22 | const { user, session, error } = await supabase.auth.signIn({ 23 | email 24 | }) 25 | console.log('🙋‍♂️', user, session) 26 | if (error) { 27 | console.log('🎹', error) 28 | } 29 | } 30 | 31 | async function logout () { 32 | await supabase.auth.signOut() 33 | } 34 | 35 | const setUserSession = (session: Session) => { 36 | userSession.value = session 37 | } 38 | 39 | // Handle Auth user changes 40 | supabase?.auth?.onAuthStateChange((event, session) => { 41 | console.log('Event', event) 42 | console.log('User ', session) 43 | userSession.value = session 44 | }) 45 | export { userSession, isLoggedIn, setUserSession, loginWithProvider, logout, loginWithEmail } 46 | -------------------------------------------------------------------------------- /components/AppSearchInput.vue: -------------------------------------------------------------------------------- 1 | 25 | 47 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "nuxi dev", 5 | "build": "nuxi build && esno build-pwa.ts", 6 | "start": "node .output/server/index.mjs" 7 | }, 8 | "devDependencies": { 9 | "@iconify/vue": "^3.1.3", 10 | "@intlify/nuxt3": "^0.1.10", 11 | "@intlify/vite-plugin-vue-i18n": "^3.2.2", 12 | "@typescript-eslint/eslint-plugin": "^5.11.0", 13 | "@typescript-eslint/parser": "^5.11.0", 14 | "autoprefixer": "^10.4.2", 15 | "eslint": "^8.9.0", 16 | "eslint-plugin-nuxt": "^3.1.0", 17 | "esno": "^0.14.1", 18 | "https-localhost": "^4.7.0", 19 | "nuxt3": "^3.0.0-27409835.c53c736", 20 | "postcss": "^8.4.6", 21 | "tailwindcss": "^3.0.22", 22 | "typescript": "^4.5.5", 23 | "vite-plugin-md": "^0.11.8", 24 | "vite-plugin-pages": "^0.20.2", 25 | "vite-plugin-pwa": "^0.11.13" 26 | }, 27 | "dependencies": { 28 | "@supabase/supabase-js": "^1.30.0", 29 | "@tailwindcss/typography": "^0.5.1", 30 | "@vueuse/nuxt": "^7.6.1", 31 | "daisyui": "^1.25.4", 32 | "highlight.js": "^11.4.0", 33 | "markdown-it": "^12.3.2", 34 | "markdown-it-container": "^3.0.0", 35 | "markdown-it-deflist": "^2.1.0", 36 | "markdown-it-emoji": "^2.0.0", 37 | "markdown-it-footnote": "^3.0.3", 38 | "markdown-it-ins": "^3.0.1", 39 | "markdown-it-sub": "^1.0.0", 40 | "markdown-it-sup": "^1.0.0", 41 | "theme-change": "^2.0.2", 42 | "vue3-markdown-it": "^1.0.10" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /components/ReloadPrompt.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 34 | 35 | 62 | -------------------------------------------------------------------------------- /plugins/markdownit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Thanks to [jyotirmaybarman](https://github.com/jyotirmaybarman) for developing this plugin 3 | */ 4 | 5 | import { defineNuxtPlugin } from '#app' 6 | 7 | 8 | import hljs from 'highlight.js' 9 | import mdit from 'markdown-it' 10 | 11 | import sub from 'markdown-it-sub' 12 | import sup from 'markdown-it-sup' 13 | import fn from 'markdown-it-footnote' 14 | import emo from 'markdown-it-emoji' 15 | import def from 'markdown-it-deflist' 16 | import ins from 'markdown-it-ins' 17 | import container from 'markdown-it-container' 18 | 19 | 20 | const markdownit = new mdit({ 21 | html: true, 22 | xhtmlOut: false, 23 | breaks: false, 24 | langPrefix: 'language-', 25 | linkify: true, 26 | typographer: true, 27 | quotes: '“”‘’', 28 | highlight: function (str, lang) { 29 | if (lang && hljs.getLanguage(lang)) { 30 | try { 31 | return '
' +
32 |           hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
33 |           '
' 34 | } catch (error) {console.log(error)} 35 | } 36 | 37 | return '
' + mdit.utils.escapeHtml(str) + '
' 38 | } 39 | }) 40 | .use(sub) 41 | .use(sup) 42 | .use(fn) 43 | .use(emo) 44 | .use(def) 45 | .use(ins) 46 | .use(container,'codeblock',{marker:'@'}) 47 | 48 | markdownit.linkify.set({ fuzzyEmail: false }) 49 | 50 | 51 | export default defineNuxtPlugin(nuxtApp => { 52 | nuxtApp.provide('mdit',markdownit) 53 | }) 54 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | const tailwindTypography =require('@tailwindcss/typography') 2 | const daisyui= require('daisyui') 3 | 4 | module.exports = { 5 | content: [ 6 | './components/**/*.{vue,js}', 7 | './layouts/**/*.vue', 8 | './pages/**/*.vue', 9 | './plugins/**/*.{js,ts}' 10 | ], 11 | theme: { 12 | extend: {}, 13 | }, 14 | variants: { 15 | extend: {}, 16 | }, 17 | plugins: [ 18 | tailwindTypography, 19 | daisyui 20 | ], 21 | daisyui: { 22 | themes: [ 23 | { 24 | ctw: { 25 | primary: '#ffb83d', 26 | 'primary-focus': '#db8b00', 27 | 'primary-content': '#ffffff', 28 | secondary: '#5e9c91', 29 | 'secondary-focus': '#3e655f', 30 | 'secondary-content': '#FFFFFF', 31 | accent: '#37cdbe', 32 | 'accent-focus': '#2aa79b', 33 | 'accent-content': '#FFFFFF', 34 | neutral: '#3d4451', 35 | 'neutral-focus': '#2a2e37', 36 | 'neutral-content': '#ffffff', 37 | 'base-100': '#1C202F', 38 | 'base-200': '#30374F', 39 | 'base-300': '#474f6b', 40 | 'base-content': '#E8E8E8', 41 | info: '#2094f3', 42 | success: '#009485', 43 | warning: '#FF9900', 44 | error: '#ff5724' 45 | } 46 | }, 47 | 'light', 48 | 'dark', 49 | 'cupcake', 50 | 'bumblebee', 51 | 'emerald', 52 | 'corporate', 53 | 'synthwave', 54 | 'retro', 55 | 'cyberpunk', 56 | 'valentine', 57 | 'halloween', 58 | 'garden', 59 | 'forest', 60 | 'aqua', 61 | 'lofi', 62 | 'pastel', 63 | 'fantasy', 64 | 'wireframe', 65 | 'black', 66 | 'luxury', 67 | 'dracula' 68 | ] 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /components/blog/BlogList.vue: -------------------------------------------------------------------------------- 1 | 43 | 44 | 56 | -------------------------------------------------------------------------------- /components/header/HeaderResponsiveMenu.vue: -------------------------------------------------------------------------------- 1 | 32 | 41 | 58 | -------------------------------------------------------------------------------- /components/MarkdownEditor.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 26 | 27 | 52 | -------------------------------------------------------------------------------- /components/header/HeaderMain.vue: -------------------------------------------------------------------------------- 1 | 51 | 52 | 59 | 60 | 65 | -------------------------------------------------------------------------------- /pages/profile.vue: -------------------------------------------------------------------------------- 1 | 49 | 80 | -------------------------------------------------------------------------------- /pages/index.vue: -------------------------------------------------------------------------------- 1 | 77 | 78 | 85 | -------------------------------------------------------------------------------- /components/DaisyuiThemeSwitcher.vue: -------------------------------------------------------------------------------- 1 | 41 | 42 | 79 | -------------------------------------------------------------------------------- /pwaConfiguration.ts: -------------------------------------------------------------------------------- 1 | import {VitePWAOptions} from 'vite-plugin-pwa' 2 | 3 | const pwaConfiguration: Partial = { 4 | includeManifestIcons: false, 5 | includeAssets: [ 6 | 'favicon.ico', 7 | 'icon.png', 8 | 'OG-card.png', 9 | 'robots.txt', 10 | '/pwa/icon-192x192.png', 11 | '/pwa/icon-512x512.png' 12 | ], 13 | // should be fixed (base + scope), since the root for nuxt is `/_nuxt/` folder and not `/` 14 | base: '/', 15 | scope: '/', 16 | manifest: { 17 | // should be fixed (id + scope + start_url), since the root for nuxt is `/_nuxt/` folder and not `/` 18 | id: '/', 19 | scope: '/', 20 | start_url: '/', 21 | background_color: '#f69435', 22 | theme_color: '#f69435', 23 | icons: [ 24 | {src: '/pwa/icon-192x192.png', sizes: '192x192', type: 'image/png' }, 25 | {src: '/pwa/icon-512x512.png', sizes: '512x512', type: 'image/png' }, 26 | {src: '/pwa/icon-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'any maskable' } 27 | ] 28 | }, 29 | workbox: { 30 | navigateFallback: '/', 31 | globPatterns: ['**/*.{js,mjs,css,html,ico,png,svg}'], 32 | globIgnores: ['**/sw*', '**/workbox-*', '**/manifest.webmanifest'], 33 | // for static generation (html files) 34 | // manifestTransforms: [async(entries) => { 35 | // // manifest.webmanifest is added always by pwa plugin, so we remove it. 36 | // // EXCLUDE from the sw precache sw and workbox-* 37 | // const manifest = entries.filter(({ url }) => 38 | // url !== 'manifest.webmanifest' && !url.endsWith('sw.js') && !url.startsWith('workbox-') 39 | // ).map((e) => { 40 | // let url = e.url 41 | // if (url && url.endsWith('.html')) { 42 | // if (url.startsWith('/')) 43 | // url = url.slice(1) 44 | // 45 | // e.url = url === 'index.html' ? '/' : `/${url.substring(0, url.lastIndexOf('/'))}` 46 | // console.log(`${url} => ${e.url}`) 47 | // } 48 | // 49 | // return e 50 | // }) 51 | // return { manifest } 52 | // }] 53 | } 54 | } 55 | 56 | const pwaConfigurationFactory = ( 57 | build: boolean, 58 | pages?: Array<{ url: string, revision?: string }>, 59 | siteName = 'Ctw Top-Nuxt3 - Template', 60 | siteShortName = 'Nuxt Template', 61 | siteDescription = 'Ctw Nuxt base template with TailwindCss, content RSS, Supabase Auth, Composition API and many other goodies', 62 | ) => { 63 | const newPwaConfiguration: Partial = { ...pwaConfiguration } 64 | newPwaConfiguration.manifest['name'] = siteName 65 | newPwaConfiguration.manifest['short_name'] = siteShortName 66 | newPwaConfiguration.manifest['description'] = siteDescription 67 | 68 | if (build) { 69 | newPwaConfiguration.workbox.globDirectory = '.output/public/' 70 | newPwaConfiguration.outDir = '.output/public/_nuxt/' 71 | pages && (newPwaConfiguration.workbox.additionalManifestEntries = pages.reduce((acc, me) => { 72 | acc.push(me) 73 | return acc 74 | }, [])) 75 | } 76 | else { 77 | newPwaConfiguration.workbox.globDirectory = '.nuxt/dist/client/' 78 | newPwaConfiguration.outDir = '.nuxt/dist/client/' 79 | } 80 | 81 | return newPwaConfiguration as VitePWAOptions 82 | } 83 | 84 | export default pwaConfigurationFactory 85 | -------------------------------------------------------------------------------- /composables/useAuth.ts: -------------------------------------------------------------------------------- 1 | import {Provider} from '@supabase/gotrue-js' 2 | import useSupabase from '~/composables/useSupabase' 3 | 4 | const user = ref(null) 5 | const {supabase} = useSupabase() 6 | 7 | /** 8 | * Listen for login state changes 9 | */ 10 | supabase.auth.onAuthStateChange((event, session) => { 11 | const { user } = useAuth() 12 | user.value = session?.user || null 13 | }) 14 | 15 | export default function useAuth() { 16 | /** 17 | * Login with email and password 18 | */ 19 | const login = async ({email, password}) => { 20 | const {user, error} = await supabase.auth.signIn({email, password}) 21 | if (error) throw error 22 | return user 23 | } 24 | 25 | /** 26 | * Login with email (magic) 27 | */ 28 | const loginWithEmail = async ({email}) => { 29 | const {user, error} = await supabase.auth.signIn({email}) 30 | if (error) throw error 31 | return user 32 | } 33 | 34 | 35 | /** 36 | * Login with google, github, etc 37 | */ 38 | 39 | const loginWithSocialProvider = async (provider: Provider) => { 40 | const {user, error} = await supabase.auth.signIn({provider}, { 41 | // redirect to localhost if you are running on dev mode 42 | redirectTo: process.dev ? 'http://localhost:3000': undefined 43 | }) 44 | if (error) throw error 45 | return user 46 | } 47 | 48 | /** 49 | * Logout 50 | */ 51 | const logout = async () => { 52 | const {error} = await supabase.auth.signOut() 53 | if (error) throw error 54 | } 55 | 56 | /** 57 | * Check if the user is logged in or not 58 | */ 59 | const isLoggedIn = () => { 60 | return !!user.value 61 | } 62 | 63 | /** 64 | * Register 65 | */ 66 | const register = async ({email, password, ...meta}) => { 67 | const {user, error} = await supabase.auth.signUp( 68 | {email, password}, 69 | { 70 | // arbitrary meta data is passed as the second argument under a data key 71 | // to the Supabase signUp method 72 | data: meta, 73 | // the to redirect to after the user confirms their email 74 | // window.location wouldn't be available if we were rendering server side 75 | // but since we're all on the client it will work fine 76 | redirectTo: `${window.location.origin}/me?fromEmail=registrationConfirmation"` 77 | }) 78 | if (error) throw error 79 | return user 80 | } 81 | 82 | /** 83 | * Update user email, password, or meta data 84 | */ 85 | const update = async (data) => { 86 | const {user, error} = await supabase.auth.update(data) 87 | if (error) throw error 88 | return user 89 | } 90 | 91 | /** 92 | * Send user an email to reset their password 93 | * (ie. support "Forgot Password?") 94 | */ 95 | const sendPasswordRestEmail = async (email) => { 96 | const {data, error} = await supabase.auth.api.resetPasswordForEmail(email) 97 | if (error) throw error 98 | return data 99 | } 100 | 101 | const resetPassword = async (accessToken, newPassword) => { 102 | const {user, error} = await supabase.auth.api.updateUser( 103 | accessToken, 104 | {password: newPassword} 105 | ) 106 | if (error) throw error 107 | return user 108 | } 109 | 110 | return { 111 | user, 112 | login, 113 | loginWithEmail, 114 | loginWithSocialProvider, 115 | isLoggedIn, 116 | logout, 117 | register, 118 | update, 119 | sendPasswordRestEmail, 120 | resetPassword 121 | // maybeHandleEmailConfirmation, 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://user-images.githubusercontent.com/4195550/147338199-cff47e80-f05c-4b3d-afe0-1c7b8aad08e4.png) 2 | 3 | # Top Nuxt 3 Starter Template 4 | 5 | ![Netlify Status](https://api.netlify.com/api/v1/badges/76c6759d-35ef-4432-816a-a45faa514aa7/deploy-status) 6 | 7 | The fastest and most comfortable development experience started template. 8 | Everything comes installed for a speedy staring with examples. Simply remove what you don't need and you are good to go :) 9 | 10 | With 💚  from  [@ctwhome](https://github.com/ctwhome), inspired by [@antfu vitesse](https://github.com/antfu/vitesse).  11 | 12 | ## Features 13 | 14 | * [x] [❇️  Nuxt 3](https://v3.nuxtjs.org) 15 | * [x] 🔥 The ` 82 | -------------------------------------------------------------------------------- /nuxt.config.ts: -------------------------------------------------------------------------------- 1 | import { defineNuxtConfig } from 'nuxt3' 2 | import Vue from '@vitejs/plugin-vue' 3 | import Markdown from 'vite-plugin-md' 4 | import { VitePWA } from 'vite-plugin-pwa' 5 | import pwaConfigurationFactory from './pwaConfiguration' 6 | 7 | /// ////////////////////////////////////////////// 8 | // Site config 9 | // Domain where the website will be deployed 10 | const productionUrl = 'MY-APP-DOMAIN.netlify.app' 11 | const useLocalSupabase = false 12 | const siteName = 'Ctw Top-Nuxt3 - Template' 13 | const siteShortName = 'Nuxt Template' 14 | const siteDescription = 'Ctw Nuxt base template with TailwindCss, content RSS, Supabase Auth, Composition API and many other goodies' 15 | const twitterUser = '@ctwhome' 16 | const isGithubPages = false // true if deployed to github pages 17 | const githubRepositoryName = 'nuxt' 18 | /// ////////////////////////////////////////////// 19 | 20 | const isDev = process.env.NODE_ENV === 'development' 21 | 22 | export default defineNuxtConfig({ 23 | // Environment variables 24 | 25 | publicRuntimeConfig: { 26 | supabaseUrl: process.env.SUPABASE_URL, 27 | supabasePublicKey: process.env.SUPABASE_PUBLIC_KEY 28 | }, 29 | 30 | 31 | // env: { 32 | // supabaseUrl: isDev && useLocalSupabase ? 'http://localhost:8000' : process.env.SUPABASE_URL, 33 | // supabaseKey: isDev && useLocalSupabase 34 | // super-secret-jwt-token-with-at-least-32-characters-long 35 | // ? 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJhdWQiOiIiLCJzdWIiOiIiLCJSb2xlIjoicG9zdGdyZXMifQ.magCcozTMKNrl76Tj2dsM7XTl_YH0v0ilajzAvIlw3U' 36 | // : process.env.SUPABASE_KEY 37 | // }, 38 | 39 | 40 | meta: { 41 | title: siteName, 42 | meta: [ 43 | { charset: 'utf-8' }, 44 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 45 | // required theme-color: pwa 46 | { name: 'theme-color', content: '#f69435' }, 47 | { name: 'format-detection', content: 'telephone=no' }, 48 | // OG Social Media Cards 49 | { hid: 'description', name: 'description', content: siteDescription }, 50 | { property: 'og:site_name', content: siteName }, 51 | { hid: 'og:type', property: 'og:type', content: 'website' }, 52 | { hid: 'og:url', property: 'og:url', content: `https://${productionUrl}` }, 53 | { hid: 'og:title', property: 'og:title', content: siteName }, 54 | { hid: 'og:description', property: 'og:description', content: siteDescription }, 55 | { hid: 'og:image', property: 'og:image', content: `https://${productionUrl}/OG-card.png` }, 56 | { property: 'og:image:width', content: '740' }, 57 | { property: 'og:image:height', content: '300' }, 58 | { name: 'twitter:site', content: twitterUser }, 59 | { name: 'twitter:card', content: 'summary_large_image' }, 60 | { hid: 'twitter:url', name: 'twitter:url', content: `https://${productionUrl}` }, 61 | { hid: 'twitter:title', name: 'twitter:title', content: siteName }, 62 | { hid: 'twitter:description', name: 'twitter:description', content: siteDescription }, 63 | {hid: 'twitter:image', name: 'twitter:image', content: `https://${productionUrl}/OG-card.png`} 64 | ], 65 | link: [ 66 | {rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}, 67 | // required manifest, apple-touch-icon and mask-icon: pwa 68 | // add manifest.webmanifest only on build? 69 | {rel: 'manifest', href: '/manifest.webmanifest'}, 70 | {rel: 'apple-touch-icon', href: '/pwa/icon-512x512.png', sizes: '180x180'}, 71 | {rel: 'mask-icon', href: '/pwa/icon-512x512.png', color: '#FFF'}, 72 | ], 73 | scripts: [ 74 | 'https://buttons.github.io/buttons.js' 75 | ], 76 | htmlAttrs: { 77 | 'lang': 'en', 78 | 'data-theme': 'light' // https://daisyui.com/docs/default-themes 79 | } 80 | }, 81 | css: ['~/styles/tailwind.css'], 82 | 83 | // server middleware to serve sw.js, workbox-**.js and manifest.webmanifest 84 | serverMiddleware: [ 85 | { path: '/', handler: '~/server-middleware/sw.js'}, 86 | ], 87 | 88 | build: { 89 | postcss: { 90 | postcssOptions: { 91 | plugins: { 92 | tailwindcss: {}, 93 | autoprefixer: {}, 94 | }, 95 | }, 96 | }, 97 | }, 98 | 99 | buildModules: [ 100 | // Internationalization with https://github.com/intlify/nuxt3 101 | '@intlify/nuxt3' 102 | ], 103 | 104 | vite: { 105 | plugins: [ 106 | Vue({ 107 | include: [/\.md$/], // <-- 108 | }), 109 | Markdown({ 110 | headEnabled: false 111 | }), 112 | VitePWA(pwaConfigurationFactory(false, undefined, siteName, siteShortName, siteDescription)) 113 | ] 114 | } 115 | }) 116 | -------------------------------------------------------------------------------- /api/useSoftware.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Using Composition API in Vue 2 3 | * https://github.com/vuejs/composition-api 4 | */ 5 | 6 | /** 7 | * Table creation SQL 8 | * 9 | CREATE TABLE software ( 10 | id varchar primary key NOT NULL, 11 | text text, 12 | done boolean, 13 | created_at TIMESTAMP DEFAULT(now()) NOT NULL 14 | ) 15 | */ 16 | 17 | import { reactive, set, computed } from 'vue' 18 | import { nanoid } from 'nanoid' 19 | import { supabase } from '~/plugins/supabase' 20 | 21 | // Reactive 'global' variable 22 | const software = reactive({ 23 | data: [] as array, 24 | count: null as null | number, 25 | error: null as null | string, 26 | fetching: false 27 | }) 28 | /** 29 | * == REALTIME == 30 | * Listen for realtime changes 31 | */ 32 | supabase 33 | // ['*', 'tableName'] 34 | .from('software') 35 | // [INSERT | UPDATE | DELETE | *] 36 | .on('*', (payload) => { 37 | // Check if the payload.new is in the software.list 38 | // if yes, delete it. That means that it comes from outside 39 | if (payload.eventType === 'DELETE') { 40 | const deletedIdx = software.data.findIndex(i => i.id === payload.old.id) as number 41 | deletedIdx !== -1 && software.data.splice(deletedIdx, 1) 42 | return 43 | } 44 | 45 | // If the updated element is the same that the one existing in state, 46 | // do not update the local state 47 | let localIdx = software.data.findIndex(i => i.id === payload.new.id) 48 | const eq = isequal(software.data[localIdx], payload.new) 49 | if (eq) { 50 | return 51 | } 52 | localIdx = localIdx === -1 ? software.data.length : localIdx 53 | set(software.data, localIdx, payload.new) 54 | }) 55 | .subscribe() 56 | 57 | /** 58 | * Retrieve all software for the signed in user 59 | */ 60 | const fetchSoftware = async () => { 61 | try { 62 | software.fetching = true 63 | const { data, count, error } = await supabase 64 | .from('software') 65 | .select('id, title, description, version, mentions', { count: 'exact' }) 66 | .order('id') 67 | .limit(30) 68 | if (error) { 69 | console.log('error', error) 70 | return 71 | } 72 | software.data = data 73 | software.count = count 74 | } catch (err) { 75 | software.error = err 76 | console.error('Error retrieving data from db', err) 77 | } finally { 78 | software.fetching = false 79 | } 80 | } 81 | const fetchSoftwareId = async (id) => { 82 | try { 83 | software.fetching = true 84 | const { data, error } = await supabase 85 | .from('software') 86 | .select('*') 87 | .eq('id', id) 88 | if (error) { 89 | console.log('error', error) 90 | return 91 | } 92 | return data[0] 93 | } catch (err) { 94 | console.error(`Error retrieving id: ${id} from db`, err) 95 | return null 96 | } 97 | } 98 | const searchText = async (text:string = 'Key') => { 99 | try { 100 | software.fetching = true 101 | const { data, count, error } = await supabase 102 | .from('software') 103 | .select() 104 | .textSearch('description', text) 105 | // .limit(30) 106 | software.fetching = false 107 | console.log('🎹', data, error) 108 | software.data = data 109 | software.count = count 110 | } catch (err) { 111 | software.error = err 112 | console.error('Error searching data from db', err) 113 | } finally { 114 | software.fetching = false 115 | } 116 | } 117 | 118 | /** 119 | * Add a new software to supabase 120 | */ 121 | const addSoftware = async (softwareText) => { 122 | try { 123 | if (!softwareText) { 124 | return 125 | } 126 | const now = new Date().toISOString().slice(0, -1) 127 | const software = { 128 | id: nanoid(), // custom ID 129 | text: softwareText, 130 | done: false, 131 | created_at: now 132 | } 133 | // Update local state 134 | software.data.push(software) 135 | 136 | // Save data in DB 137 | // Returns the new software in case it's needed 138 | await supabase.from('software').insert(software).single() 139 | } catch (err) { 140 | console.error('Unknown problem inserting to db', err) 141 | // remove local software in case of error 142 | return null 143 | } 144 | } 145 | 146 | const removeSoftware = async (software, index) => { 147 | try { 148 | // update current state (Optimistic UI) 149 | software.data.splice(index, 1) 150 | // Update database 151 | await supabase.from('software').delete().match({ id: software.id }) 152 | } catch (e) { 153 | console.error(e) 154 | } 155 | } 156 | // Workaround for Vue2 to make this property readonly with composition API 157 | // It is important to compute the reactive variables to make 158 | // them readonly. In vue 3 this step is not necessary. 159 | const softwareData = computed(() => software.data) 160 | const softwareCount = computed(() => software.count) 161 | const softwareFetching = computed(() => software.fetching) 162 | const softwareError = computed(() => software.error) 163 | 164 | export { 165 | softwareData, 166 | softwareCount, 167 | softwareError, 168 | softwareFetching, 169 | fetchSoftware, 170 | fetchSoftwareId, 171 | addSoftware, 172 | removeSoftware, 173 | searchText 174 | } 175 | -------------------------------------------------------------------------------- /components/FooterMain.vue: -------------------------------------------------------------------------------- 1 | 55 | -------------------------------------------------------------------------------- /content/about.md: -------------------------------------------------------------------------------- 1 | --- 2 | myVar: This is a Frontmatter variable! 3 | --- 4 | ### This file is being render from a Markdown file, and it contains HTML and Vue components inside it! 5 | 6 | with support for Vue Components: 7 | 8 | 9 | 10 | and html iframe embeded: 11 | 12 | 13 | 14 | 15 |

16 | Until now, trying to style an article, document, or blog post with Tailwind has been a tedious 17 | task that required a keen eye for typography and a lot of complex custom CSS. 18 |

19 | 20 | By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive. 21 | 22 | We get lots of complaints about it actually, with people regularly asking us things like: 23 | 24 | > Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too? 25 | 26 | We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful. 27 | 28 | The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles. 29 | 30 | It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document: 31 | 32 | ```html 33 |
34 |

Garlic bread with cheese: What the science tells us

35 |

36 | For years parents have espoused the health benefits of eating garlic bread with cheese to their 37 | children, with the food earning such an iconic status in our culture that kids will often dress 38 | up as warm, cheesy loaf for Halloween. 39 |

40 |

41 | But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases 42 | springing up around the country. 43 |

44 | 45 |
46 | ``` 47 | 48 | For more information about how to use the plugin and the features it includes, [read the documentation](https://github.com/tailwindcss/typography/blob/master/README.md). 49 | 50 | --- 51 | 52 | ## What to expect from here on out 53 | 54 | What follows from here is just a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of, like **bold text**, unordered lists, ordered lists, code blocks, block quotes, _and even italics_. 55 | 56 | It's important to cover all of these use cases for a few reasons: 57 | 58 | 1. We want everything to look good out of the box. 59 | 2. Really just the first reason, that's the whole point of the plugin. 60 | 3. Here's a third pretend reason though a list with three items looks more realistic than a list with two items. 61 | 62 | Now we're going to try out another header style. 63 | 64 | ### Typography should be easy 65 | 66 | So that's a header for you — with any luck if we've done our job correctly that will look pretty reasonable. 67 | 68 | Something a wise person once told me about typography is: 69 | 70 | > Typography is pretty important if you don't want your stuff to look like trash. Make it good then it won't be bad. 71 | 72 | It's probably important that images look okay here by default as well: 73 | 74 |
75 | 79 |
80 | Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of 81 | classical Latin literature from 45 BC, making it over 2000 years old. 82 |
83 |
84 | 85 | Now I'm going to show you an example of an unordered list to make sure that looks good, too: 86 | 87 | - So here is the first item in this list. 88 | - In this example we're keeping the items short. 89 | - Later, we'll use longer, more complex list items. 90 | 91 | And that's the end of this section. 92 | 93 | ## What if we stack headings? 94 | 95 | ### We should make sure that looks good, too. 96 | 97 | Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be. 98 | 99 | ### When a heading comes after a paragraph … 100 | 101 | When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let's see what a more complex list would look like. 102 | 103 | - **I often do this thing where list items have headings.** 104 | 105 | For some reason I think this looks cool which is unfortunate because it's pretty annoying to get the styles right. 106 | 107 | I often have two or three paragraphs in these list items, too, so the hard part is getting the spacing between the paragraphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argument that you just shouldn't write this way. 108 | 109 | - **Since this is a list, I need at least two items.** 110 | 111 | I explained what I'm doing already in the previous list item, but a list wouldn't be a list if it only had one item, and we really want this to look realistic. That's why I've added this second list item so I actually have something to look at when writing the styles. 112 | 113 | - **It's not a bad idea to add a third item either.** 114 | 115 | I think it probably would've been fine to just use two items but three is definitely not worse, and since I seem to be having no trouble making up arbitrary things to type, I might as well include it. 116 | 117 | After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading. 118 | 119 | ## Code should look okay by default. 120 | 121 | I think most people are going to use [highlight.js](https://highlightjs.org/) or [Prism](https://prismjs.com/) or something if they want to style their code blocks but it wouldn't hurt to make them look _okay_ out of the box, even with no syntax highlighting. 122 | 123 | Here's what a default `tailwind.config.js` file looks like at the time of writing: 124 | 125 | ```js 126 | module.exports = { 127 | purge: [], 128 | theme: { 129 | extend: {}, 130 | }, 131 | variants: {}, 132 | plugins: [], 133 | } 134 | ``` 135 | 136 | Hopefully that looks good enough to you. 137 | 138 | ### What about nested lists? 139 | 140 | Nested lists basically always look bad which is why editors like Medium don't even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work. 141 | 142 | 1. **Nested lists are rarely a good idea.** 143 | - You might feel like you are being really "organized" or something but you are just creating a gross shape on the screen that is hard to read. 144 | - Nested navigation in UIs is a bad idea too, keep things as flat as possible. 145 | - Nesting tons of folders in your source code is also not helpful. 146 | 2. **Since we need to have more items, here's another one.** 147 | - I'm not sure if we'll bother styling more than two levels deep. 148 | - Two is already too much, three is guaranteed to be a bad idea. 149 | - If you nest four levels deep you belong in prison. 150 | 3. **Two items isn't really a list, three is good though.** 151 | - Again please don't nest lists if you want people to actually read your content. 152 | - Nobody wants to look at this. 153 | - I'm upset that we even have to bother styling this. 154 | 155 | The most annoying thing about lists in Markdown is that `
  • ` elements aren't given a child `

    ` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too. 156 | 157 | - **For example, here's another nested list.** 158 | 159 | But this time with a second paragraph. 160 | 161 | - These list items won't have `

    ` tags 162 | - Because they are only one line each 163 | 164 | - **But in this second top-level list item, they will.** 165 | 166 | This is especially annoying because of the spacing on this paragraph. 167 | 168 | - As you can see here, because I've added a second line, this list item now has a `

    ` tag. 169 | 170 | This is the second line I'm talking about by the way. 171 | 172 | - Finally here's another list item so it's more like a list. 173 | 174 | - A closing list item, but with no nested list, because why not? 175 | 176 | And finally a sentence to close off this section. 177 | 178 | ## There are other elements we need to style 179 | 180 | I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier. 181 | 182 | We even included table styles, check it out: 183 | 184 | | Wrestler | Origin | Finisher | 185 | | ----------------------- | ------------ | ------------------ | 186 | | Bret "The Hitman" Hart | Calgary, AB | Sharpshooter | 187 | | Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner | 188 | | Randy Savage | Sarasota, FL | Elbow Drop | 189 | | Vader | Boulder, CO | Vader Bomb | 190 | | Razor Ramon | Chuluota, FL | Razor's Edge | 191 | 192 | We also need to make sure inline code looks good, like if I wanted to talk about `` elements or tell you the good news about `@tailwindcss/typography`. 193 | 194 | ### Sometimes I even use `code` in headings 195 | 196 | Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really. 197 | 198 | Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it. 199 | 200 | #### We haven't used an `h4` yet 201 | 202 | But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`. 203 | 204 | We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks. 205 | 206 | ### We still need to think about stacked headings though. 207 | 208 | #### Let's make sure we don't screw that up with `h4` elements, either. 209 | 210 | Phew, with any luck we have styled the headings above this text and they look pretty good. 211 | 212 | Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document. 213 | 214 | What I've written here is probably long enough, but adding this final sentence can't hurt. 215 | -------------------------------------------------------------------------------- /components/Logo.vue: -------------------------------------------------------------------------------- 1 | 53 | -------------------------------------------------------------------------------- /components/Tutorial.vue: -------------------------------------------------------------------------------- 1 | 2 | 63 | --------------------------------------------------------------------------------