Suppose we have the standard simple linear regression model: $$ Y_i = \beta_0 + \beta_1 X_i + \varepsilon_i, $$ with $E[\varepsilon_i|X_i] = 0$ and $\text{Var}[\varepsilon_i|X_i] = \sigma^2$.
I'm trying to show that $$ E[\hat \beta_1 | \mathbf{X}] = \beta_1, $$ directly using the definition of $\hat \beta_1$, where $\mathbf{X}$ is the vector of $X_i$'s. I know there are other ways to show it but I am trying to do it this way so that I can practise working with conditional expectation. The definition of $\hat \beta_1$ is $$ \hat \beta_1 = \frac{\sum (X_i - \bar X)(Y_i - \bar Y)}{\sum (X_i - \bar X)^2}. $$
Define $$ g_i(\mathbf{X}) := \frac{X_i - \bar X}{\sum (X_i - \bar X)^2}. $$
Here's what I've done: $$ \begin{align} E[\hat \beta_1 | \mathbf{X}] & = E\bigg[\frac{\sum (X_i - \bar X)(Y_i - \bar Y)}{\sum (X_i - \bar X)^2} \bigg| \mathbf{X}\bigg] \\ & = E\bigg[\sum_i g_i(\mathbf{X})(Y_i - \bar Y) \bigg| \mathbf{X} \bigg] \\ & = \sum_i E\bigg[g_i(\mathbf{X})(Y_i - \bar Y) \bigg| \mathbf{X} \bigg] \\ & = \sum_i E[g_i(\mathbf{X})Y_i| \mathbf{X}] - \sum_i E[g_i(\mathbf{X}) \bar Y | \mathbf{X} ] \\ & = \sum_i g_i(\mathbf{X}) E[Y_i| \mathbf{X} ] - \sum_i g_i(\mathbf{X}) E[\bar Y | \mathbf{X}] \\ \end{align} $$ Because I can take the $g(\mathbf{X})$ out of the expectation it seems we can never get a constant $\beta_1$ as the final result? Where have I gone wrong? How can we show $E[\hat \beta_1 | \mathbf{X}] = \beta_1$ using this approach?